Skip to content

Install and set up PostgreSQL#

  1. Add the Bitnami repository:
helm repo add bitnami https://charts.bitnami.com/bitnami
  1. Create and populate postgresql-values.yaml file:
   primary:
     persistence:
       enabled: true
       size: 10Gi
       storageClass: "<nameofstorageclass>"
     postgresql:
       password: "support"
       replicaCount: 3
       initdbScripts:
         create_databases.sh: |
           #!/bin/bash
           export PGPASSWORD=$(cat /opt/bitnami/postgresql/secrets/password)
           psql -U postgres -c "CREATE DATABASE harbor_core" && psql -U postgres -c "CREATE DATABASE clair" && psql -U postgres -c "CREATE DATABASE notary_signer" && psql -U postgres -c "CREATE DATABASE notary_server"
       resources:
         limits:
           cpu: 500m
           memory: 512Mi
         requests:
           cpu: 100m
           memory: 256Mi
  1. Install HA PostgreSQL with a helm install command:
helm install postgresql bitnami/postgresql-ha -f postgresql-values.yaml
  1. Obtain the PostgreSQL password:
export POSTGRES_PASSWORD=$(kubectl get secret --namespace default postgresql-postgresql-ha-postgresql -o jsonpath="{.data.password}" | base64 -d)
echo $POSTGRES_PASSWORD
  1. Login to PostgreSQL:
kubectl run postgresql-postgresql-ha-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql-repmgr:16.4.0-debian-12-r12 --env="PGPASSWORD=$POSTGRES_PASSWORD"  \
--command -- psql -h postgresql-postgresql-ha-pgpool -p 5432 -U postgres -d postgres
  1. Find the pool service and port:
kubectl get service

Example output:

postgresql-postgresql-ha-pgpool                ClusterIP   10.96.40.233    <none>        5432/TCP