Gabriele B
Gabriele B

Reputation: 2685

Change GKE storage class without losing content

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?

Upvotes: 0

Views: 3290

Answers (1)

Dawid Kruk
Dawid Kruk

Reputation: 9885

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.

Upvotes: 4

Related Questions