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.

The following command to install the operator must be run twice, at least for now, due to a race condition with the way kubectl handles the CRD installation.

kubectl kustomize --enable-helm /opt/genestack/base-kustomize/postgres-operator | kubectl apply -f -
sleep 10
kubectl kustomize --enable-helm /opt/genestack/base-kustomize/postgres-operator | kubectl apply -f -

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 /opt/genestack/base-kustomize/postgres-cluster/base | kubectl apply -f -