Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm delete release and clear associated storage

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
like image 510
Carmine Avatar asked Jun 26 '19 08:06

Carmine


People also ask

How do I delete a release in Helm?

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.

What is the difference between Helm uninstall and Helm delete?

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.

Does helm uninstall remove PVC?

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.


1 Answers

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.

like image 164
AnjanaAK Avatar answered Oct 24 '22 00:10

AnjanaAK