Skip to content

Instantly share code, notes, and snippets.

@nrb
Last active Jan 27, 2020
Embed
What would you like to do?
#!/usr/bin/env sh
# This script lives in ~/bin
# It mostly automates the instructions found on https://heptio.github.io/ark/v0.9.0/gcp-config, except that creating the bucket and service account has already been done.
# Source the variables since they're private information
# Defines $PROJECT, $CREDS_FILE, $SERVICE_ACCOUNT_EMAIL, and $BUCKET.
source ~/bin/gke-vars.sh
# Spin up a GKE cluster and get the credentials for kubeconfig
# use --enable-kubernetes-alpha to get alpha features
gcloud beta container clusters create cluster-1 --release-channel=rapid --disk-size=30 --preemptible --no-enable-cloud-logging --no-enable-cloud-monitoring --no-enable-basic-auth --no-issue-client-certificate --enable-ip-alias --metadata disable-legacy-endpoints=true \
&& 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
fi
velero install --bucket $BUCKET --provider gcp --secret-file $CREDS_FILE --plugins velero/velero-plugin-for-gcp:v1.0.0
# Scale down replicas so that we can run locally
kubectl scale deploy/velero -n velero --replicas=0
#cat $VELERO/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.
# very quick hacky script to set up a kind cluster so I could test it against Duffie's CAPI backups.
kind create cluster --image=kindest/node:v1.16.4
#--image=kindest/node:v1.14.10
source $HOME/duffies-env
v=$HOME/go/src/github.com/vmware-tanzu/velero/_output/bin/darwin/amd64/velero
$v install --provider aws --plugins velero/velero-plugin-for-aws:v1.0.0 --bucket $BUCKET --backup-location-config region=$REGION --snapshot-location-config region=$REGION --secret-file $HOME/duffies-creds
kubectl scale deploy/velero -n velero --replicas=0
#kubectl apply -f crd.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment