apiVersion: postgresql.k8s.enterprisedb.io/v1 kind: Cluster metadata: name: cluster-example-pod-selector-refs spec: instances: 3 # Define named pod label selectors for dynamic pg_hba address resolution. # The operator resolves matching pod IPs and expands ${podselector:NAME} # references in pg_hba rules into one line per IP with /32 (IPv4) or /128 (IPv6) masks. podSelectorRefs: - name: app-pods selector: matchLabels: app: myapp - name: monitoring selector: matchLabels: role: monitoring postgresql: pg_hba: # These rules use ${podselector:NAME} syntax to reference podSelectorRefs. # Each reference is expanded to one line per matching pod IP. - "hostssl mydb myuser ${podselector:app-pods} scram-sha-256" - "hostssl postgres monitor ${podselector:monitoring} scram-sha-256" # Standard rules without expansion are passed through unchanged. - host all all 10.244.0.0/16 md5 primaryUpdateStrategy: unsupervised storage: size: 1Gi