apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: db
spec:
  selector:
    matchLabels:
      app: db
  serviceName: db
  replicas: 1
  template:
    metadata:
      labels:
        app: db
    spec:
      # terminationGracePeriodSeconds: 10
      containers:
        - name: db
          image: db-image
          envFrom:
            - configMapRef:
                name: database-env
          ports:
            - containerPort: 5432
              name: postgres
          volumeMounts:
            - name: db-data
              mountPath: /var/lib/postgresql/data
              subPath: postgres
  volumeClaimTemplates:
    - metadata:
        name: db-data
      spec:
        accessModes: ["ReadWriteOnce"]
        storageClassName: local-path
        resources:
          requests:
            storage: 2G
