Install highly available PostgreSQL

  1. Install the Zalando Postgres Operator:

    helm install postgres-operator postgres-operator --repo https://opensource.zalando.com/postgres-operator/charts/postgres-operator
    
  2. Create and configure the msr-postgres-manifest.yaml file:

    Note

    Adjust numberOfInstances to match your desired cluster size.

    apiVersion: "acid.zalan.do/v1"
    kind: postgresql
    metadata:
      name: msr-postgres
    spec:
      teamId: "msr"
      volume:
        size: 1Gi
      numberOfInstances: 3
      users:
        msr:  # database owner
        - superuser
        - createdb
      databases:
        registry: msr  # dbname: owner
      postgresql:
        version: "17"
    
  3. Deploy the Postgres instance:

    kubectl create -f msr-postgres-manifest.yaml
    
  4. Retrieve connection details for the Postgres service:

    Get the service’s IP address:

    kubectl get svc \
      -l application=spilo,cluster-name=msr-postgres,spilo-role=master \
      -o jsonpath={.items..spec.clusterIP}
    

    Get the service’s port number:

    kubectl get svc \
      -l application=spilo,cluster-name=msr-postgres,spilo-role=master \
      -o jsonpath={.items..spec.ports..port}