Created
August 30, 2017 18:59
-
-
Save kelseyhightower/712e8b781f3e265e487bf31f9e53c769 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CLUSTERS=$(gcloud container clusters list \ | |
--format 'value(name)[terminator=" "]') | |
NODE_PORT=32080 | |
gcloud compute health-checks create tcp hello-kubernetes-health-check --port ${NODE_PORT} | |
gcloud compute backend-services create hello-kubernetes-backend-services \ | |
--connection-draining-timeout 3600 \ | |
--enable-cdn \ | |
--health-checks hello-kubernetes-health-check \ | |
--global | |
for c in ${CLUSTERS}; do | |
INSTANCE_GROUP_NAME=$(gcloud container clusters describe ${c} \ | |
--zone ${c} \ | |
--format 'value(nodePools[0].instanceGroupUrls[0].basename())') | |
gcloud compute instance-groups set-named-ports ${INSTANCE_GROUP_NAME} \ | |
--named-ports=http:${NODE_PORT} \ | |
--zone ${c} | |
gcloud compute backend-services add-backend hello-kubernetes-backend-services \ | |
--balancing-mode RATE \ | |
--description "Hello Kubernetes ${c} Backend Service" \ | |
--instance-group ${INSTANCE_GROUP_NAME} \ | |
--instance-group-zone ${c} \ | |
--max-rate 500 \ | |
--global | |
done | |
gcloud compute url-maps create hello-kubernetes-global-services \ | |
--default-service hello-kubernetes-backend-services | |
gcloud compute target-http-proxies create hello-kubernetes-http-proxy \ | |
--url-map hello-kubernetes-global-services | |
gcloud compute forwarding-rules create hello-kubernetes-forwarding-rules \ | |
--target-http-proxy hello-kubernetes-http-proxy \ | |
--ports 80 \ | |
--global | |
gcloud compute firewall-rules create hello-kubernetes-backend-services \ | |
--allow tcp:${NODE_PORT} \ | |
--source-ranges 130.211.0.0/22,35.191.0.0/16 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment