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
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.
.Values.persistence.storageClass
the created pvc will use that class to provision volumes..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.