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 postgres-operator.crunchydata.com/cluster=hippo,postgres-operator.crunchydata.com/role=master)
  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

pgAdmin for All of Your Postgres Kubernetes Clusters

8 min readRead post

Announcing Crunchy Postgres for Kubernetes 5.5

5 min readRead post

Deploying Crunchy Postgres for Kubernetes in a Multi-Zone Cluster

6 min readRead post

Huge Pages and Postgres in Containers

4 min readRead post

Use CI/CD to Automatically Update Postgres Images with Argo CD

10 min readRead post
Read more posts