apiVersion: apps/v1 kind: StatefulSet metadata: name: postgresql spec: replicas: 1 serviceName: postgresql selector: matchLabels: app: postgresql template: metadata: labels: app: postgresql spec: containers: - name: postgresql image: postgres:14 ports: - containerPort: 5432 volumeMounts: - name: postgresql_data mountPath: /var/lib/postgresql/data env: - name: POSTGRES_USER value: "sonar" - name: POSTGRES_PASSWORD value: "sonar" - name: POSTGRES_DB value: "sonar" volumes: - name: postgresql_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: postgresql labels: app: postgresql spec: ports: - protocol: TCP port: 5432 targetPort: 5432 selector: app: postgresql type: ClusterIP