Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to connect to postgresql on Kubernetes cluster?

I have deployed my crunchy db postgresq on my Kubernetes cluster.

However, I am not sure how to connect to the database remotely.

What command can I use to connect remotely so I can create a new database?

Is there a kubectl command to go with psql?

like image 732
Katlock Avatar asked Mar 14 '17 21:03

Katlock


People also ask

How do I connect to a cluster in PostgreSQL?

To connect to the cluster with the pgAdmin clientOpen the context (right-click) menu for Servers, and then choose Create, Server. Enter information in the Create - Server dialog box. On the Connection tab, add the Aurora PostgreSQL cluster address for Host and the PostgreSQL port number (by default, 5432) for Port.

Can you run Postgres in Kubernetes?

Create and Apply PostgreSQL Deployment Deployments are a way to manage rolling out and updating applications in a Kubernetes cluster. They provide a declarative way to define how an application should be deployed and updated, and can be used to roll back to previous versions if needed.


2 Answers

I was able to look at another forum and found what I needed. I executed with the pod name and gets me to a bash prompt.

kubectl exec -it  <POD_NAME> bash
like image 142
Katlock Avatar answered Nov 15 '22 11:11

Katlock


kubctl get pods
kubectl exec -it  <POD_NAME> bash
su postgres
psql

in the above postgres is user name. you will get:

postgres=#
like image 41
Lord Avatar answered Nov 15 '22 11:11

Lord