PostgreSQL RDS AWS
Connecting to an AWS RDS PostgreSQL instance directly and from within a Kubernetes pod using psql.
The first command connects to an RDS PostgreSQL instance from your local machine using the psql client. The second command executes a SQL statement from inside a Kubernetes pod, which is useful when your RDS instance is not publicly accessible and you need to reach it through a pod running in the same VPC.
1
2
3
4
psql -h mldb-postgres.cgpyiy4kedtv.us-west-2.rds.amazonaws.com -U postgres -d mldb
kubectl exec pod-demo-0 -it -- \
sh -c "echo 'DROP DATABASE fgh;' | PGPASSWORD=$PGPASSWORD /usr/bin/psql -h 127.0.0.1 -U postgres"
This post is licensed under CC BY 4.0 by the author.