From 1a0adda9eda68e7d7d656a47f894237bb0a46595 Mon Sep 17 00:00:00 2001 From: Felix Kunde <felix-kunde@gmx.de> Date: Thu, 4 Apr 2019 19:37:06 +0200 Subject: [PATCH] update db connection part in user docs --- docs/user.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/user.md b/docs/user.md index a0569fe2..bab09f8c 100644 --- a/docs/user.md +++ b/docs/user.md @@ -43,13 +43,25 @@ $ kubectl get pods -w --show-labels ## Connect to PostgreSQL -We can use the generated secret of the `postgres` robot user to connect to our `acid-minimal-cluster` master running in Minikube: +With a `port-forward` on one of the database pods (e.g. the master) you can +connect to the PostgreSQL database. Use labels to filter for the master pod of +our test cluster. + +```bash +# get name of master pod of acid-minimal-cluster +export PGMASTER=$(kubectl get pods -o jsonpath={.items..metadata.name} -l application=spilo,version=acid-minimal-cluster,spilo-role=master) + +# set up port forward +kubectl port-forward $PGMASTER 6432:5432 +``` + +Open another CLI and connect to the database. Use the generated secret of the +`postgres` robot user to connect to our `acid-minimal-cluster` master running +in Minikube: ```bash -$ export PGHOST=db_host -$ export PGPORT=db_port $ export PGPASSWORD=$(kubectl get secret postgres.acid-minimal-cluster.credentials -o 'jsonpath={.data.password}' | base64 -d) -$ psql -U postgres +$ psql -U postgres -p 6432 ``` # Defining database roles in the operator -- GitLab