Why do my databases disappear after deployments?

October 7, 2019 133 views
PostgreSQL

I have a 1 replica PostgreSQL (alpine:latest) instance running. It works great but every time I do a deployment or every time I scale to 0 then back to 1 pod my database disappears.

When I look in the logs I see that the init scripts in docker-entrypoint-initdb.d are run indicating that the PV is empty; these shoudl only be run if the directory is empty. When I look at the PV its been around for some time:

postgres-data   Bound    pvc-830e8f59-9628-11e9-88b9-36ca52c85694   3Gi        RWO            do-block-storage   104d

Nothing else seems to be impacted this way. For example I have minio running as an object store and it keeps its data after deployments or scaling.

Any tips appreciated.

1 Answer

Hello,

You need to make sure that you have your volumeMounts and mountPath set up correctly in your deployment file so that the PostgreSQL data folder is actually mounted on your PV.

If you wish you could share your yaml file here so that I could try to advise you further.

Regards,
Bobby

Have another answer? Share your knowledge.