Katlock
Katlock

Reputation: 1386

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?

Upvotes: 9

Views: 7598

Answers (2)

Rafiq
Rafiq

Reputation: 11445

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

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

postgres=#

Upvotes: 3

Katlock
Katlock

Reputation: 1386

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

Upvotes: 12

Related Questions