2017-01-17 08:39:03 +03:00
|
|
|
#!/usr/bin/bash
|
|
|
|
set -x
|
|
|
|
|
2017-01-20 20:22:27 +03:00
|
|
|
if [[ -z ${NUM_CONTROLLERS} || -z ${NUM_WORKERS} || -z ${KUBERNETES_VERSION} ]]; then
|
|
|
|
echo "Must set NUM_CONTROLLERS, NUM_WORKERS and KUBERNETES_VERSION (e.g. 'vX.Y.Z') environment variables"
|
2017-01-17 08:39:03 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
(( NUM_CONTROLLERS-- ))
|
|
|
|
(( NUM_WORKERS-- ))
|
|
|
|
|
|
|
|
gcloud compute networks create kubernetes --mode custom
|
|
|
|
|
|
|
|
gcloud compute networks subnets create kubernetes \
|
|
|
|
--network kubernetes \
|
|
|
|
--range 10.240.0.0/24
|
|
|
|
|
|
|
|
gcloud compute firewall-rules create kubernetes-allow-icmp \
|
|
|
|
--allow icmp \
|
|
|
|
--network kubernetes \
|
|
|
|
--source-ranges 0.0.0.0/0
|
|
|
|
|
|
|
|
gcloud compute firewall-rules create kubernetes-allow-internal \
|
|
|
|
--allow tcp:0-65535,udp:0-65535,icmp \
|
|
|
|
--network kubernetes \
|
|
|
|
--source-ranges 10.240.0.0/24
|
|
|
|
|
2017-01-20 20:22:27 +03:00
|
|
|
gcloud compute firewall-rules create kubernetes-allow-internal-podcidr \
|
|
|
|
--allow tcp:0-65535,udp:0-65535,icmp \
|
|
|
|
--network kubernetes \
|
|
|
|
--source-ranges 10.200.0.0/16
|
|
|
|
|
2017-01-17 08:39:03 +03:00
|
|
|
gcloud compute firewall-rules create kubernetes-allow-rdp \
|
|
|
|
--allow tcp:3389 \
|
|
|
|
--network kubernetes \
|
|
|
|
--source-ranges 0.0.0.0/0
|
|
|
|
|
|
|
|
gcloud compute firewall-rules create kubernetes-allow-ssh \
|
|
|
|
--allow tcp:22 \
|
|
|
|
--network kubernetes \
|
|
|
|
--source-ranges 0.0.0.0/0
|
|
|
|
|
|
|
|
gcloud compute firewall-rules create kubernetes-allow-healthz \
|
|
|
|
--allow tcp:8080 \
|
|
|
|
--network kubernetes \
|
|
|
|
--source-ranges 130.211.0.0/22
|
|
|
|
|
|
|
|
gcloud compute firewall-rules create kubernetes-allow-api-server \
|
|
|
|
--allow tcp:6443 \
|
|
|
|
--network kubernetes \
|
|
|
|
--source-ranges 0.0.0.0/0
|
|
|
|
|
|
|
|
gcloud compute firewall-rules list --filter "network=kubernetes"
|
|
|
|
|
2017-01-20 21:42:53 +03:00
|
|
|
gcloud compute addresses create kubernetes --region=us-central1
|
2017-01-17 08:39:03 +03:00
|
|
|
|
|
|
|
gcloud compute addresses list kubernetes
|
|
|
|
|
|
|
|
# Kubernetes controller
|
|
|
|
for i in $(eval echo "{0..${NUM_CONTROLLERS}}"); do
|
|
|
|
gcloud compute instances create controller${i} \
|
|
|
|
--boot-disk-size 200GB \
|
|
|
|
--can-ip-forward \
|
|
|
|
--image ubuntu-1604-xenial-v20160921 \
|
|
|
|
--image-project ubuntu-os-cloud \
|
|
|
|
--machine-type n1-standard-1 \
|
|
|
|
--private-network-ip 10.240.0.1${i} \
|
|
|
|
--subnet kubernetes
|
|
|
|
done
|
|
|
|
|
|
|
|
# Kubernetes workers
|
|
|
|
for i in $(eval echo "{0..${NUM_WORKERS}}"); do
|
|
|
|
gcloud compute instances create worker${i} \
|
|
|
|
--boot-disk-size 200GB \
|
|
|
|
--can-ip-forward \
|
|
|
|
--image ubuntu-1604-xenial-v20160921 \
|
|
|
|
--image-project ubuntu-os-cloud \
|
|
|
|
--machine-type n1-standard-2 \
|
|
|
|
--private-network-ip 10.240.0.2${i} \
|
|
|
|
--subnet kubernetes
|
|
|
|
done
|