I have a Docker volume that is a snapshot of a PostgreSQL container. I would like to apply this volume to a PostgreSQL container in a Kubernetes pod. Is there some way to do this? FYI I am using helm for Kubernetes installation, and I am using the Bitnami PostgreSQL helm chart.
Disclaimer: I'm not certain that I'm using the correct terminology, so please ask for clarification if necessary.
Unless the Kubernetes Cluster and your previous Docker Container have a physical host machine in common, you won't be able to "apply this volume" to a Kubernetes Pod since volumes are attached to the host machine they are created on (and it would still be pretty hard to do).
I think the easiest way would be to make and restore a dump of your database resp. using pg_dump and pg_restore.
Depending on the size of your dump (less than 1MiB), you could export your dump to an .sql
file that you would then mount inside your StatefulSet
using a ConfigMap
. Finally you would use pg_restore
on that file.
If it's bigger than 1MiB, then you would need to push the dump to an online storage, download it from within the Pod and then restore it. However, Bitnami Docker images are highly secured and therefore won't let you install any extra tool like wget
to download your dump. Therefore I would recommend you using the official Docker image that is less locked so you will be able to install wget
using apt
.