apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: todo-application
  name: postgres-ss
spec:
  serviceName: postgres
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: postgres
          envFrom:
          - configMapRef:
              name: postgres-config
          env:
          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                name: postgres-password
                key: DB_PASSWORD
          ports:
            - name: postgredb
              containerPort: 5432
          volumeMounts:
            - name: postgredb
              mountPath: /var/lib/postgresql/data
              subPath: postgres
  volumeClaimTemplates:
    - metadata:
        name: postgredb
      spec:
        accessModes: ["ReadWriteOnce"]
        storageClassName: local-path
        resources:
          requests:
            storage: 100Mi