apiVersion: apps/v1
kind: Deployment
metadata:
  name: db
spec:
  replicas: 1
  selector:
    matchLabels:
      app: db
  template:
    metadata:
      labels:
        app: db
    spec:
      containers:
        - name: postgres
          image: postgres:10.4
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
          livenessProbe:
            exec:
              command:
              - pg_isready
              - -h
              - localhost
              - -U
              - postgres
            initialDelaySeconds: 30
            timeoutSeconds: 5
          readinessProbe:
            exec:
              command:
              - pg_isready
              - -h
              - localhost
              - -U
              - postgres
            initialDelaySeconds: 5
            timeoutSeconds: 1
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: db-persistent-storage
      volumes:
        - name: db-persistent-storage
          persistentVolumeClaim:
            claimName: db-pv-claim
