0

I've inherited a terraform/helm based GKE with a set of deployments and services in production environment. All of them use the default storage class as PVC.

I would like to switch to a more robust way of storage (default retain or even Filestore+NFS). I was wondering if there is a way to switch the storage class to the newer ones without loosing or manually move the content from the oldest default volumes. This eventually using terraform and updating the Helm charts for consistency.

Is there a way to do so?

johntellsall
  • 14,394
  • 4
  • 46
  • 40
Gabriele B
  • 2,665
  • 1
  • 25
  • 40
  • Hello. Do I understand correctly that your terraform/helm resources are creating your PVC with default options (`reclaimPolicy: Delete`) and you want to change it to `reclaimPolicy: Retain`? Please have a look here: https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/ . You could also create a `storageClass` that will have this `reclaimPolicy` set to `Retain` by default. Do you already have data that cannot be lost and you want to copy it to Filestore? – Dawid Kruk Jul 14 '20 at 15:20
  • Yes, but I'm quite sure that updating my tf scripts (with another storage class) i'm going to loose the content of the persistent storage, am I right? I was just wondering if a storage can change its class _in place_. – Gabriele B Jul 14 '20 at 16:26

1 Answers1

4

You cannot change your StorageClass to a different one and expect the data to not be lost.

Think about your StorageClass as a way to tell Kubernetes what are the available storage options for use. You could have a NFS storage and Ceph storage. Changing the StorageClass for a PVC that stores your data will not transfer the data to a new location.

You won't be even able to change most of the parameters in already created StorageClasses and PVC's.

You can read more about it by following below links:


I was wondering if there is a way to switch the storage class to the newer ones without loosing (the data I assume)

As said previously it's not possible to just change the StorageClass to a different one.

or manually move the content from the oldest default volumes.

Yes, this is possible and there are several ways to do it. The exact situation you are facing is unknown to us (what exact resources are you having, the data on it, the way they are deployed etc.).

Please take a look on below resources:

You can use above example with copying files between PVC's to create a Job that will do it automatically.

This eventually using terraform and updating the helm charts for consistency.

If you mean to create your resources supporting new storage you configured, it's possible. You will need to modify your existing resources/create new resources to support new storages. Please make sure you tested your solution before using it on production.

Dawid Kruk
  • 8,982
  • 2
  • 22
  • 45
  • many tnx, your answer is perfect and the resources you linked were crystal clear. Although I was limiting my question from just a subset of two of all the available storage classes choices: the default storage and the default retain. – Gabriele B Jul 23 '20 at 07:15
  • If you are thinking about changing the `ReclaimPolicy` of your `PVC's`, please take a look here: https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/ – Dawid Kruk Jul 24 '20 at 13:36