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.2 Launch

3 min readRead post

Accelerating Spatial Postgres: Varnish Cache for pg_tileserv using Kustomize

5 min readRead post

Snap Clones with the Postgres Operator on Kubernetes

14 min readRead post

Effective PostgreSQL Cluster Configuration & Management Using PGO v5.1

5 min readRead post

Seamless pgAdmin 4 Deployments Using PGO v5.1

3 min readRead post
Read more posts