apiVersion: apps/v1 kind: StatefulSet metadata: name: pg spec: replicas: 1 serviceName: pg selector: matchLabels: app: pg template: metadata: labels: app: pg spec: containers: - name: pg image: postgres:14 ports: - containerPort: 5432 volumeMounts: - name: pg_data mountPath: /var/lib/postgresql/data env: - name: POSTGRES_USER value: "sonar" - name: POSTGRES_PASSWORD value: "sonar" - name: POSTGRES_DB value: "sonar" volumes: - name: pg_data hostPath: path: /data/sonarqube/postgresql/data affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: "kubernetes.io/hostname" operator: In values: - bfs-k8snode-10-2-0-14.hetzner.base.beaconfireinc.com --- apiVersion: v1 kind: Service metadata: name: pg labels: app: pg spec: ports: - protocol: TCP port: 5432 targetPort: 5432 selector: app: pg type: ClusterIP