New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I delete PVC related to StatefulSets? #5137
Comments
I found the answer. Helm does not have any ways to delete pvc related to statefulsets. |
@katsew Could you share your pre-delete hook? I'm having a hard time figuring out how to delete my PVC. I'm thinking of doing something like
But it runs inside a container that is not in the same context as helm (or tiller in this case), so I don't think it'll work. |
I think you should provide a service account with role binding to delete pvc. e.g.
|
I use following yaml:
|
#3313 explains why helm doesn't delete the PVCs automatically. I'm not sure this works in all cases, but for the postgreSQL database that I installed it with:
the pvc has this label:
So when I delete the release with:
I can delete the pvc-s afterwards with: # run with `--dry-run=client` first to see what I'm about to delete
$ kubectl delete pvc --dry-run=client -l app.kubernetes.io/instance=mydb
persistentvolumeclaim "data-mydb-postgresql-0" deleted (dry run)
# ok, looks like I'm deleting the right PVC(s) - lets do it
$ kubectl delete pvc -l app.kubernetes.io/instance=mydb
persistentvolumeclaim "data-mydb-postgresql-0" deleted |
Thank you for this! Worked like a charm on the first try. |
I deploy statefulset via helm, and it has a volumeClaimTemplates.
I check some issue similar to my case, but I couldn't get the answer.
I annotate
helm.sh/resource-policy: delete
to volumeClaimTemplates, but it does not work.Is there any way to delete pvc related to statefulsets by
helm del (--purge)
?Or do I have to delete pvc manually?
The text was updated successfully, but these errors were encountered: