9
votes

I install the helm release by

helm install --name my-release .

And delete it by

helm delete --purge my-release

But I found out that kubernetes does not clear any storage associated to the containers of that release. I installed postgresql, did lot of things to it, deleted, and when I reinstalled it, all my data was there. How do I clear the storage via helm delete?

Edit: I'm using Postgresql Stable Chart version 5.3.10

Here's the only custom thing I have in my release

values.yaml

postgresql:
  postgresqlDatabase: test
  postgresqlUsername: test
  postgresqlPassword: test
2
Are you using any persistent volume for PostgreSQL?AnjanaAK
I didn't set any, although it does use some default as I see. But I wonder if there's any way to delete it using helm, and not doing a brute rm -rf on the clusterCarmine
Can you add the helm chart file in the question which sets the volume?AnjanaAK
I don't customize it at all, I just added a postgresql dependency, set username password, and installed the releaseCarmine
Are you using the postgresql helm chart from stable repo github.com/helm/charts/tree/master/stable/postgresql ?AnjanaAK

2 Answers

5
votes

Look at the helm chart file: https://github.com/helm/charts/blob/master/stable/postgresql/templates/statefulset.yaml

It is evident that if you don't specify the value for .Values.persistence.existingClaim in values.yaml, it will automatically create a persistent volume claim.

  • If you have a storage calss set for .Values.persistence.storageClass the created pvc will use that class to provision volumes.
  • If you set the storage class as "-", the dynamic provisioning will be disabled.
  • If you don't specify anything for .Values.persistence.storageClass, the automatically created pvc will not have a storage class field specified.

Since you are using the default values.yaml of the chart, you have the third case.

In kubernetes, if you don't specify a storage class in a persistent volume claim, it will use the default storage class of the cluster to provision volumes.

Check which is your cluster's stoage class:

kubectl get sc 

The default StorageClass will be marked by (default). Describe that storage class and find it's Reclaim Policy.

If the Reclaim Policy is Delete, the pv created by it will be automatically deleted when it's claim is removed (In your case, when the chart is uninstalled).

If the default storage class's Reclaim Policy is not Delete, you have to create your own storage class with Delete policy and then use it further.

0
votes

If you take a look at default value in default values.yaml here:

persistence:
  enabled: true

By setting it to false we can disable the persistence so that after uninstalling the helm release, the data is not persisted.

To achieve this, create your own values file with following contents:

persistence:
  enabled: false

#Sample command
helm install myrelease --values values-override.yaml bitnami/postgresql