Skip to content

Instantly share code, notes, and snippets.

Last active Sep 20, 2018
What would you like to do?
A helper scrip to spin up GKE clusters
#!/usr/bin/env sh
# This script lives in ~/bin
# It mostly automates the instructions found on, except that creating the bucket and service account has already been done.
# Source the variables since they're private information
source ~/bin/
# Spin up a GKE cluster and get the credentials for kubeconfig
gcloud container clusters create cluster-1 --cluster-version=1.10.7 --disk-size=30 --enable-autorepair --preemptible --no-enable-cloud-logging --no-enable-cloud-monitoring && gcloud container clusters get-credentials cluster-1 --zone us-east4-b --project $PROJECT
# Create a new credentials file if one isn't found.
if [[ ! -f $CREDS_FILE ]]; then
gcloud iam service-accounts keys create $CREDS_FILE --iam-account $SERVICE_ACCOUNT_EMAIL
kubectl apply -f examples/common/00-prereqs.yaml
kubectl create secret generic cloud-credentials --namespace $NAMESPACE --from-file cloud=$CREDS_FILE
# TODO: update with BackupStorageLocation
cat examples/gcp/00-ark-config.yaml | sed "s/<YOUR_BUCKET>/$BUCKET/" | kubectl apply -f -
# Only apply the deployment file if -d switch is provided. Otherwise, we'll run Ark locally.
if [[ "$1" == "-d" ]]; then
kubectl apply -f examples/gcp/10-deployment.yaml
kubectl apply -f examples/gcp/20-restic-daemonset.yaml
cat examples/nginx-app/with-pv.yaml | sed "s/<YOUR_STORAGE_CLASS_NAME>/standard/" | kubectl apply -f -
# When done, I delete the cluster with:
# gcloud container clusters delete cluster-1 --async
# --async can be left off if you want to wait for the cluster to teardown.
# TODO: Script to gather all snapshots and delete them, since those can add up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment