If we can run the hoh postgres DB inside cluster as an operator to test/try our the Hub-of-Hubs setup.
- installs PostgreSQL Operator
- set up hoh database
- the database with 2 users created
./high-availability/ha-postgres.yaml:11,14
, these users will be used by the anisble-playbook as well. - all hoh related schema and tables will be created via
job/postgres-init
- make sure your
KUBECONFIG
is pointing the HoH cluster. Ask your cluster's admin to give you appropriate permissions. - set the
USER_NAME
environment variable to hold the username part of your docker image:$ export USER_NAME=...
- set the
IMAGE_TAG
environment variable to hold the tag of your image:$ export IMAGE_TAG=latest
- set the
IMAGE
environment variable to hold your docker image:$ export IMAGE=quay.io/$USER_NAME/postgresql-ansible:$IMAGE_TAG
- run
docker build -t $IMAGE .
and thendocker push $IMAGE
from the project root folder - run
./setup.sh
If the command above does not produce any errors, you should able to connect to the Hoh DB sits inside your hoh cluster.
You can use the following commands to get HoH DB credentials and to connect to the database.
PG_NAMESPACE="hoh-postgres"
DB_NAME="hoh"
HOH_PGBOUNCER="pgbouncer"
PGBOUNCER_SERVICE="hoh-pgbouncer"
PG_CLUSTER_USER_SECRET_NAME="$DB_NAME-pguser-hoh-process-user"
PGPASSWORD="$(kubectl get secrets -n "${PG_NAMESPACE}" "${PG_CLUSTER_USER_SECRET_NAME}" -o go-template='{{.data.password | base64decode}}')"
PGUSER="$(kubectl get secrets -n "${PG_NAMESPACE}" "${PG_CLUSTER_USER_SECRET_NAME}" -o go-template='{{.data.user | base64decode}}')"
PG_URI="$(kubectl get secrets -n "${PG_NAMESPACE}" "${PG_CLUSTER_USER_SECRET_NAME}" -o go-template='{{.data.uri | base64decode}}')"
kubectl expose service $PGBOUNCER_SERVICE -n $PG_NAMESPACE --port=5432 --target-port=5432 --name=$HOH_PGBOUNCER --type=LoadBalancer
PGHOST="$(kubectl get svc -n "${PG_NAMESPACE}" "${HOH_PGBOUNCER}" -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"
echo "postgres secret name: " $PG_CLUSTER_USER_SECRET_NAME
echo "postgres user: " $PGUSER
echo "postgres password: " $PGPASSWORD
echo "postgres host: "$PGHOST
# connect to db
PGPASSWORD=$PGPASSWORD PGSSLMODE=require psql -h $PGHOST -U $PGUSER -d $DB_NAME
kubectl exec -it $(kubectl get pods -n hoh-postgres -l postgres-operator.crunchydata.com/role=master -o jsonpath='{.items..metadata.name}') -n hoh-postgres -c database -- psql -d hoh
Run the Hoh deployments and play around.