#!/bin/bash ## ## Script to automate the Kubernetes CentOS client side pieces ## . .gce_kubernetes.config echo "######################################" echo "Set the gcloud compute region and zone" echo "######################################" gcloud config set compute/region $GCE_REGION gcloud config set compute/zone $GCE_ZONE gcloud config set project $GCE_PROJECT echo "Compute region and zone set" echo "" KUBE_CONTROLLERS=$((KUBE_CONTROLLERS-1)) KUBERNETES_PUBLIC_ADDRESS=$(gcloud compute addresses describe $KUBE_NETWORK --region $GCE_REGION --format 'value(address)') for (( i=0; i<=$KUBE_CONTROLLERS; i++ )); do if [ "$i" == "0" ]; then printf 'controller-'${i} > instance else printf ',controller-'${i} >> instance fi done INSTANCES=`cat instance` gcloud compute http-health-checks create $KUBE_NETWORK --description "Kubernetes Health Check" --host "kubernetes.default.svc.cluster.local" --request-path "/healthz" gcloud compute firewall-rules create $KUBE_NETWORK-allow-health-check --network $KUBE_NETWORK --source-ranges 209.85.152.0/22,209.85.204.0/22,35.191.0.0/16 --allow tcp gcloud compute target-pools create $KUBE_NETWORK-target-pool --http-health-check $KUBE_NETWORK gcloud compute target-pools add-instances kubernetes-target-pool --instances $INSTANCES gcloud compute forwarding-rules create $KUBE_NETWORK-forwarding-rule --address ${KUBERNETES_PUBLIC_ADDRESS} --ports 6443 --region $GCE_REGION --target-pool $KUBE_NETWORK-target-pool echo 'Verifying this has worked:' cd certs-dir curl --cacert ca.pem https://${KUBERNETES_PUBLIC_ADDRESS}:6443/version echo 'The next step is to configure the worker nodes'