0

I am running Ansible AWX based on Docker compose setup, I need to upgrade the version of AWX which supports only Kubernetes.

I need to export the DB from the docker setup into Kubernetes but I don't know how to import the postgres dump into K8S. Can any one help me out please ?

1
  • In its current form, this question is probably too broad to answer. If you get postgres running in your Kubernetes environment and expose the port, you can just use the regular dump and restore process. Commented Aug 5, 2021 at 12:12

1 Answer 1

2

You can call pg_restore command directly in the pod specifying path to your local file as a dump source.

kubectl exec -i POD_NAME -- pg_restore -U USERNAME -C -d DATABASE < dump.sql

(or)

cat database.sql | kubectl exec -i [pod-name] --psql -U [postgres-user] -d [database-name]

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot, is there a way to login to a pod docker and check what's inside same as we do with docker: docker exec -it <docker name> /bin/bash ?
You can attach to a running container almost the same way you do in docker - kubectl exec -i -t <pod-name> -- /bin/bash. If there is more than one container running you need to specify it with --container flag: kubectl exec -i -t <pod-name> --container <app-name> -- /bin/bash. If you are planning to run database in a pod, you may also want to look into Persistent Volumes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.