Skip to content

Deploy PostgreSQL

PostgreSQL is used by Gnocchi to index the data collected and sent by Ceilometer.

Install the Postgres Operator

We are using the Zalando postgres-operator which offers easy to run and highly-available PostgreSQL clusters on Kubernetes.

Run the postgres-operator deployment Script bin/install-postgres-operator.sh

#!/bin/bash

# Directory to check for YAML files
CONFIG_DIR="/etc/genestack/helm-configs/postgres-operator"

pushd /opt/genestack/submodules/postgres-operator/charts || exit

# Base helm command setup
HELM_CMD="helm upgrade --install postgres-operator ./postgres-operator \
  --namespace=postgres-system \
  --create-namespace \
  --timeout 120m"

# Add the base overrides file
HELM_CMD+=" -f /opt/genestack/base-helm-configs/postgres-operator/postgres-operator-helm-overrides.yaml"

# Check if YAML files exist in the specified directory
if compgen -G "${CONFIG_DIR}/*.yaml" > /dev/null; then
    # Append all YAML files from the directory to the helm command
    for yaml_file in "${CONFIG_DIR}"/*.yaml; do
        HELM_CMD+=" -f ${yaml_file}"
    done
fi

# Run the helm command
eval "${HELM_CMD}"
echo "${HELM_CMD}"

popd || exit

Create the PostgreSQL Cluster

Customize as needed

Be sure to modify the cluster parameters to suit your needs. The below values should work fine for a small lab or staging envionrment, however more disk space and other changes may be required in production.

kubectl apply -f - <<EOF
apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
  name: postgres-cluster
  namespace: openstack
spec:
  dockerImage: ghcr.io/zalando/spilo-16:3.2-p3
  teamId: "acid"
  numberOfInstances: 3
  postgresql:
    version: "16"
    parameters:
      shared_buffers: "2GB"
      max_connections: "1024"
      log_statement: "all"
  volume:
    size: 40Gi
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
        - matchExpressions:
          - key: node-role.kubernetes.io/worker
            operator: In
            values:
            - worker
EOF

Two overlays exist - base which includes 3 replicas, and an aio overlay which has a single replica and less default resource utilization.

kubectl kustomize /etc/genestack/kustomize/postgres-cluster/overlay | kubectl apply -f -