Quickstart¶
This guide takes you from an empty Kubernetes cluster to a running PostgreSQL database managed by keenPGO. It should take about ten minutes.
Just testing?
No cluster yet? Start a local one with Minikube and come back here.
Prerequisites for quickstart¶
- A running Kubernetes cluster, above version 1.31.x
kubectlconfigured to reach the cluster- You must have permission to create namespaces and custom resource definitions required for keenPGO
- The
psqlclient, if you want to connect from your own machine to perform operations on created keenPGO database instance.
Check that kubectl can reach your cluster:
Step 1: Install the operator¶
Create a namespace and install keenpgo-operator into it:
kubectl create namespace keenpgo-operator
kubectl apply -n keenpgo-operator -f <operator-manifest-url>
Prefer Helm, or running on OpenShift? See the installation guides.
Wait until the operator is running:
The operator pod should report Running and 1/1 ready:
Step 2: Create a PostgreSQL cluster¶
Save the following as my-cluster.yaml:
apiVersion: <api-group>/<version>
kind: keenpgcluster
metadata:
name: my-cluster
namespace: keenpg-test
spec:
postgresVersion: 16
instances:
- replicas: 2
storage:
size: 5Gi
Apply it:
Watch the cluster come up:
When the database pods show Running and ready, the cluster is up. Press
Ctrl+C to stop watching.
Step 3: Find your credentials¶
keenPGO creates a user for the cluster and stores the credentials in a
Kubernetes Secret named <secret-name-pattern>.
List the available fields:
The Secret contains these values:
| Key | Description |
|---|---|
user |
The database user name |
password |
The password for that user |
dbname |
The default database |
host |
The service name of the primary instance |
port |
The port the database listens on |
uri |
A ready-to-use connection string |
Read a single value, for example the password:
Warning
Treat these credentials like any other secret. Don't paste them into chat, tickets or source control.
Step 4: Connect to the database¶
In one terminal, forward the database port:
In a second terminal, connect with psql:
Once connected, test it:
Step 5: Connect an application¶
Applications should read connection details from the Secret rather than hard-coding them. Add environment variables to your Deployment that reference the Secret:
env:
- name: DB_HOST
valueFrom:
secretKeyRef:
name: <secret-name>
key: host
- name: DB_PORT
valueFrom:
secretKeyRef:
name: <secret-name>
key: port
- name: DB_NAME
valueFrom:
secretKeyRef:
name: <secret-name>
key: dbname
- name: DB_USER
valueFrom:
secretKeyRef:
name: <secret-name>
key: user
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: <secret-name>
key: password
Clean up¶
To remove the test cluster and the operator:
kubectl delete -f my-cluster.yaml
kubectl delete -n keenpg -f <operator-manifest-url>
kubectl delete namespace keenpg