apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgres
  labels:
    app: postgres
spec:
  serviceName: postgres
  replicas: 1
  template:
    metadata:
      name: postgres
      labels:
        app: postgres
    spec:
      volumes:
        - name: postgres
          persistentVolumeClaim:
            claimName: postgres-pc-volume-claim
      containers:
        - name: postgres
          image: postgres
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - mountPath: "/var/lib/postgresql/data"
              name: postgres
          envFrom:
            - configMapRef:
                name: postgres-config
          resources:
            requests:
              cpu: 100m
              memory: 256Mi
            limits:
              cpu: 500m
              memory: 512Mi
      restartPolicy: Always
  selector:
    matchLabels:
      app: postgres