-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_cluster.sh
More file actions
executable file
·66 lines (54 loc) · 2.68 KB
/
make_cluster.sh
File metadata and controls
executable file
·66 lines (54 loc) · 2.68 KB
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
64
65
66
# Script to make a cluster for testing unit files stuck in a "No such
# file or directory" state.
# We make 5 nodes, all set up with etcd & fleet on CoreOS, but
# otherwise nothing special.
# Note: The environment variable SSH_SOURCE_CIDR should be set to a
# CIDR where you'd like to ssh from. In our case, this is the external
# address of our corporate firewall; obviously it'll be something
# different for other people.
token=$(curl -s https://discovery.etcd.io/new)
cat << EOF > cloud-config.txt
#cloud-config
coreos:
etcd:
# generate a new token for each unique cluster from https://discovery.etcd.io/new
discovery: $token
# multi-region and multi-cloud deployments need to use \$public_ipv4
addr: \$private_ipv4:4001
peer-addr: \$private_ipv4:7001
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
EOF
# Make a network
gcloud compute networks create coreos-issue-8
# Make firewall rules
gcloud compute firewall-rules create ci8-internal --network coreos-issue-8 --allow icmp tcp:1-65535 udp:1-65535 --source-ranges 10.240.0.0/16 &
gcloud compute firewall-rules create ci8-allow-ssh --network coreos-issue-8 --allow tcp:22 --source-ranges $SSH_SOURCE_CIDR &
wait
if false; then
# Make 5 instances
gcloud compute instances create ci8-host-{a..e} \
--zone us-central1-a \
--metadata-from-file user-data=cloud-config.txt \
--network coreos-issue-8 \
--image coreos \
--scopes bigquery datastore sql storage-rw userinfo-email \
--machine-type n1-standard-1 \
--maintenance-policy MIGRATE &
wait
else
for id in a b c d e; do
gcloud compute instances create ci8-host-$id \
--zone us-central1-a \
--metadata-from-file user-data=cloud-config.txt \
--network coreos-issue-8 \
--image coreos \
--scopes bigquery datastore sql storage-rw userinfo-email \
--machine-type n1-standard-1 \
--maintenance-policy MIGRATE
sleep 2
done
fi