1

I have a small cluster on GKE, and I use dynamic provisioning to allocate persistent disks for Postgres. These disks are snapshotted on a regular schedule. When an accident happens, what's the best way to overwrite the contents of a dynamically created disk with the contents of a snapshot? I considered just deleting the disk and creating a new one with the same name, based on the snapshot. But since the disk is created and managed by k8s I'm worried that messing with it manually will break things.

I settled on creating a new instance, outside of k8s, attaching the target disk and a new one based on the snapshot to it, and using dd to copy the data, but this is much slower than I'd like it to be. (~38MB/s)

Is there a better way?

Echo Nolan
  • 138
  • 6
  • The dynamically provisioned persistent volumes are always deleted according to the [reclaim policy](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#reclaiming), as such, I suggest first to create GCE persistent disk for Postgres data, and mount it in the deployment [1](https://gist.github.com/wolfeidau/b55f321868ab6dac63f1), [2](https://medium.com/google-cloud/deploying-django-postgres-and-redis-containers-to-kubernetes-part-2-b287f7970a33). This will preserve the persistent disk when pods get restarted or rescheduled for reasons like crashes or node restarts. – Irina Jun 20 '17 at 19:37
  • @EchoNolan Were you able to set up as per the Irina's suggestion or have found another way to set this up? If so, Please post the self-answer so to benefit the community having similar setup. – N Singh Sep 19 '17 at 15:31

0 Answers0