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
If you need to uninstall the deployed release, run the delete command on the Helm command line. The command removes all the Kubernetes components that are associated with the chart and deletes the release.
Show activity on this post. kubectl delete ... just removes the resource in the cluster. Doing helm uninstall ... won't just remove the pod, but it will remove all the resources created by helm when it installed the chart.
PVCs is one of those resources that don't get cleaned up by helm delete --purge , and I believe that's been the intended behaviour since v2. 0.0 in order to protect that data in case an operator needed to purge and re-install.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With