Published on

Kubernetes Deleting a PVC Backed by NFS

Authors

Generally in Kubernetes if you want to delete an app and all its data you would run:

kubectl delete all,pvc -lapp=yourAppLabel

Today I had to do this for a micro service with a db backed by an nfs pvc. But our database migration scripts were still failing after running this command once as according to the logs the db had already been changed. After running this by a colleague of mine (who is well versed in Kubernetes) he pointed out that this was caused by the fact that this pvc is backed by nfs.

The way to resolve this is to log into the db pod and drop the db or scrape the nfs container. After dropping the db and recreating the db schema the db migration went through without issue.