Skip to content

Instantly share code, notes, and snippets.

@cedbossneo
Created May 11, 2017 05:47
Show Gist options
  • Save cedbossneo/ef5d2a8b474efd2d3e86f756df48e46f to your computer and use it in GitHub Desktop.
Save cedbossneo/ef5d2a8b474efd2d3e86f756df48e46f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Create an environment variable for the correct distribution
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
# Add the Cloud SDK distribution URI as a package source
echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Import the Google Cloud Platform public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
# Update the package list and install the Cloud SDK
apt-get update && sudo apt-get install -y google-cloud-sdk kubectl nano unzip git
wget -O /usr/bin/kops https://github.com/kubernetes/kops/releases/download/1.5.3/kops-linux-amd64
chmod +x /usr/bin/kops
gcloud config set compute/zone europe-west1-b
gcloud container clusters create training-cluster-$1
cat <<EOF > /tmp/get-credential-cluster-$1.sh
#!/bin/bash
until gcloud container clusters list | grep training-cluster-$1 | grep RUNNING
do
echo "Wait for cluster provisionning"
sleep 1
done
gcloud container clusters get-credentials "training-cluster-$1" --zone europe-west1-b
kubectl proxy --address="0.0.0.0" --accept-hosts='.*' &
EOF
chmod +x /tmp/get-credential-cluster-$1.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment