By downloading you acknowledge and agree to the Crunchy Data Terms of Use and Data Collection Notice

Postgres OperatorGet Postgres up and running on your Kubernetes cluster

Self-service tools for developers and data scientists to easily get productive with PostgreSQL and Crunchy Data products.

Connect to Database

Now that you have created a Postgres Cluster let connect to the database using psql.

Connect Directly

This is obviously the easiest method to connect, but it only works if you are on the same network as the Postgres Cluster.

psql $(kubectl -n postgres-operator get secrets hippo-pguser-hippo -o go-template='{{.data.uri | base64decode}}')

Connect using Port-Forward (shown in terminal)

If you are not on the same network, then we will need to use a port-forward to connect.

  1. Create variable for pod

    PG_CLUSTER_PRIMARY_POD=$(kubectl get pod \  -n postgres-operator \  -o name \  -l,
  2. Create port-forward

    kubectl -n postgres-operator port-forward "${PG_CLUSTER_PRIMARY_POD}" 5432:5432
  3. Create variables for connection details

    PGPASSWORD=$(kubectl get secrets -n postgres-operator "hippo-pguser-hippo" -o go-template='{{.data.password | base64decode}}') \PGUSER=$(kubectl get secrets -n postgres-operator "hippo-pguser-hippo" -o go-template='{{.data.user | base64decode}}') \PGDATABASE=$(kubectl get secrets -n postgres-operator "hippo-pguser-hippo" -o go-template='{{.data.dbname | base64decode}}')
  4. Connect to database

    psql -h localhost

Resources, support, and more

Looking for more Postgres and Kubernetes Content?

Postgres Operator Docs

Dive into more advanced concepts and tutorials in our PGO documentation.

Get Started

Expert Help

No matter where your cluster is deployed get support from our PGO pros.

Learn More

Kubernetes Blog Posts

CI/CD with Crunchy Postgres for Kubernetes and Argo

8 min readRead post

Postgres GitOps with Argo and Kubernetes

11 min readRead post

Stateful Postgres Storage Using Kubernetes

11 min readRead post

Crunchy Postgres for Kubernetes 5.3 Release

3 min readRead post

Log Export Examples Using Crunchy Postgres for Kubernetes

13 min readRead post
Read more posts