apiVersion: apps/v1 kind: StatefulSet metadata: name: postgres spec: selector: matchLabels: app: postgres serviceName: postgres replicas: 1 template: metadata: labels: app: postgres spec: containers: - name: postgres image: postgres:latest resources: limits: memory: "500Mi" cpu: "250m" ports: - containerPort: 5432 env: - name: POSTGRES_DB value: sudobot - name: POSTGRES_USER value: postgres - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: sudobot key: db_password volumeMounts: - name: postgres-pv mountPath: /var/lib/postgresql/data - name: postgres-config mountPath: /etc/postgresql volumes: - name: postgres-pv persistentVolumeClaim: claimName: postgres-pvc - name: postgres-config configMap: name: postgres-config defaultMode: 0755 volumeClaimTemplates: - metadata: name: postgres-pv spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 5Gi