I'd like to schedule this command line to run every 12h on Google Container Engine:

gcloud compute --project "qvitoo-com" disks snapshot \
  "SPECIFIC_INSTANCE_ID" --zone "europe-west1-c" --snapshot-names \
  "DB-staging-$(date -u +"%Y-%m-%dT%H-%M-%SZ")"

We're running hosted Kubernetes.

This command line needs access to the gcloud API to succeed. How do I make this happen?

(I can't use gcloud cron because it's HTTP calls only, and Kubernetes cron jobs are in alpha, plus I don't know how to authenticate)


Our solution is built on an open source tool called k8s-snapshots. This toll requires the use of PersistentVolumes but with annotations performs a snapshot at an interval. It also manages retention. Our extension to it notifies via slack if that's useful to you. It runs as a separate service inside our k8s cluster and uses the authentication that's native on the GCE host the cluster is running on.


Another option is snapshot-controller. It's similar to k8s-snapshots, but has fewer fancy features. I couldn't get k8s-snapshots to work due to this bug.


Take a look here: https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver (beta on k8s 1.13) It support snapshot and restore as k8s resource.

  • 1
    Adding the info from the link would improve your answer – Dave M Mar 5 '19 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.