-
Notifications
You must be signed in to change notification settings - Fork 69
/
cluster.sh
executable file
·63 lines (44 loc) · 1.92 KB
/
cluster.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
rm -f .env
gum style --foreground 212 --border-foreground 212 --border normal --margin "1 2" --padding "1 2" \
'Create Kubernetes clusters in DigitalOcean with Pulumi'
echo "
# This script will create a Kubernetes cluster in DigitalOcean using Pulumi
## Prerequisites
You will need following tool installed:
| Name | Required | More info |
|------------|----------|-----------------------------------------------------|
| Pulumi CLI | Yes | \`https://www.pulumi.com/docs/iac/download-install/\` |
" | gum format
echo ""
gum confirm "Do you have Pulumi installed?" || exit 0
echo "
## Pulumi Authentication
To create Kubernetes clusters in DigitalOcean, you'll need to provide your Pulumi access token. You can generate one by following the instructions here: \`https://www.pulumi.com/docs/pulumi-cloud/access-management/access-tokens/\`.
Please enter your Pulumi access token below:
" | gum format
cd iac/do-cluster
rm -f .env
PULUMI_ACCESS_TOKEN=$(gum input --placeholder "Enter Pulumi access token" --value "$PULUMI_ACCESS_TOKEN" --password)
echo "export PULUMI_ACCESS_TOKEN=$PULUMI_ACCESS_TOKEN" > $(pwd)/.env
echo ""
echo "
## DigitalOcean Authentication
To create Kubernetes clusters in DigitalOcean, you'll need to provide your DigitalOcean access token. Use the one provided by the workshop organizers.
" | gum format
DIGITALOCEAN_TOKEN=$(gum input --placeholder "DigitalOcean token" --value "$DIGITALOCEAN_TOKEN" --password)
echo "export DIGITALOCEAN_TOKEN=$DIGITALOCEAN_TOKEN" >> $(pwd)/.env
echo ""
source .env
pulumi stack init dev || true
pulumi stack select dev
pulumi up -y -f
pulumi stack output kubeconfig --show-secrets > kubeconfig.yaml
export KUBECONFIG=$(pwd)/kubeconfig.yaml
echo "export KUBECONFIG=$(pwd)/kubeconfig.yaml" >> $(pwd)/.env
kubectl get nodes
echo ""
echo "
-> Head over to the next chapter by running the \`./setup.sh\` script
" | gum format