-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path20-instances.sh
executable file
·43 lines (37 loc) · 1.27 KB
/
20-instances.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
#!/bin/bash
# get public ip
public=$(gcloud compute addresses describe magicless-ip-address \
--region $(gcloud config get-value compute/region) \
--format 'value(address)')
# master nodes
for i in 0 1 2; do
# first controller gets a static ip
[ $i = 0 ] && addr_arg="--address $public" || addr_arg=""
gcloud compute instances create controller-${i} \
--async \
--boot-disk-size 200GB \
--can-ip-forward \
--image-family ubuntu-1804-lts \
--image-project ubuntu-os-cloud \
--machine-type n1-standard-2 \
--private-network-ip 10.254.254.10$i \
--scopes compute-rw,storage-ro,service-management,service-control,logging-write,monitoring \
--subnet magicless-subnet \
--tags magicless,controller $addr_arg
done
# worker nodes
for i in 0 1 2; do
gcloud compute instances create worker-${i} \
--async \
--boot-disk-size 200GB \
--can-ip-forward \
--image-family ubuntu-1804-lts \
--image-project ubuntu-os-cloud \
--machine-type n1-standard-1 \
--metadata pod-cidr=192.168.1${i}.0/24 \
--private-network-ip 10.254.254.20${i} \
--scopes compute-rw,storage-ro,service-management,service-control,logging-write,monitoring \
--subnet magicless-subnet \
--tags magicless,worker
done
gcloud compute instances list