Unintended persistent storage in PostgreSQL with Helm

4/3/2019

Short version: PostgreSQL deployed via Helm is persisting data between deployments unintentionally. How do I make sure data is cleared?

Long version: I'm currently deploying PostgreSQL via Helm this way, using it for a local development database for an application I'm building:

helm install stable/postgresql -n testpg \
    --set global.postgresql.postgresqlDatabase=testpg \
    --set global.postgresql.postgresqlUsername=testpg \
    --set global.postgresql.postgresqlPassword=testpg \
    --set global.postgresql.servicePort=5432 \
    --set service.type=LoadBalancer

When I'm done (or if I mess up the database so bad and need to clear it), I uninstall it:

helm del --purge testpg

(which confirms removal and kubectl get all confirms works)

However, when I spin the database up again, I'm surprised to see that the data and schema are still there when it has spun up.

How is the data persisting and how do I make sure I have a clean database each time?

Other details:

  • My Kubernetes Cluster is running in Docker Desktop v2.0.0.3
-- jeffmaher
kubernetes
kubernetes-helm
postgresql

1 Answer

4/3/2019

Your cluster may have a default volume provisioner configured.

https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/#defaulting-behavior

So even if you have no storage class configured a volume will be assigned.

You need to set helm value persistence.enabled to false.

The value is true by default:

https://github.com/helm/charts/blob/master/stable/postgresql/values.yaml

-- Frank Wilson
Source: StackOverflow