0

I am trying to deploy postgres on docker with PV and PVCs.

What is the purpose of using DB_USER and PASSWORD env variables?

(ref. https://severalnines.com/blog/using-kubernetes-deploy-postgresql)

I just want API to connect to service hosted with k8s with credentials known.

1 Answer 1

1

If you look inside the script docker-entrypoint.sh that runs inside the postgresql container on boot, you'll notice that it contains these paramaters:

--username "$POSTGRES_USER" --dbname "$POSTGRES_DB" --host "$POSTGRES_HOST" --password "$POSTGRES_PASSWORD"

If during boot of psql container, these environment variables are present, it initializes the psql server with those attributes else it initializes with default attributes.

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

5 Comments

Certainly helpful. I will check it out. Could you answer volume part ?
containers are by design state-less that means they cannot be relied upon to store critical information which might be needed later. For example, if a container goes down which had critical data and next time a new container come up from the same image you'll lose the data. Hence, we attach a persistent volume to it in order to store the schema and it's content safely in case of container failure. That way the data is preserved while making sure the containers are stateless. A good read - engineering.pivotal.io/post/stateful-apps-toc
PV is a persistent volume and PVC is PV-claim. A persistent volume could be mounted to a container/deployment via a PVC. If it served your curiosity you may accept the answer :), it might help others as well.
I am aware of PV and PVC but confused with how I mount it on deployment if PV is on EFS and given above docker run format. Will read more on PV with EFS or maybe another question altogether. Thank you for your answer.
Amazon EFS provides shared file storage for use with compute instances. Apps that require shared and reliable file storage delivering high aggregate throughput to thousands of clients simultaneously is preferred. EFS provides ReadWriteMany access mode as well. Amazon EBS is a cloud block storage service that provides direct access from a single Amazon EC2 instance to a dedicated storage volume. Apps that require persistent dedicated block access for a single host can use Amazon EBS as a highly available, low-latency block storage solution. EBS provides onlyReadWriteOnce access mode.

Your Answer

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