Introducing Crunchy Data Warehouse: A next-generation Postgres-native data warehouse. Crunchy Data Warehouse Learn more

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

Crunchy Postgres for Kubernetes 5.7: Faster Backups, Automated Snapshots, Postgres 17 and More

4 min readRead post

PostgreSQL Snapshots and Backups with pgBackRest in Kubernetes

6 min readRead post

Thin Provisioning with Crunchy Postgres for Kubernetes

4 min readRead post

Kubernetes Operator Meets Fully Managed Postgres

10 min readRead post

Announcing Crunchy Postgres for Kubernetes 5.6: New Features for Seamless Postgres Management

4 min readRead post
Read more posts