apiVersion: v1
kind: Pod
metadata:
  name: postgresql
spec:
  containers:
    - name: postgresql
      image: postgres:14.1-alpine
      imagePullPolicy: IfNotPresent
      envFrom:
        - secretRef:
            name: postgresql-secret
      ports:
        - name: postgresql
          containerPort: 5432
          hostPort: 5432
      startupProbe:
        exec:
          command: ["/bin/sh", "-c", "exec pg_isready --user=postgres"]
        initialDelaySeconds: 5
        periodSeconds: 1
        successThreshold: 1
        failureThreshold: 55
      readinessProbe:
        exec:
          command: ["/bin/sh", "-c", "exec pg_isready --user=postgres"]
      livenessProbe:
        exec:
          command: ["/bin/sh", "-c", "exec pg_isready --user=postgres"]
      volumeMounts:
        - name: config
          mountPath: /docker-entrypoint-initdb.d/init.sh
          subPath: init.sh
          readOnly: true
        - name: data
          mountPath: /var/lib/postgresql/data
  automountServiceAccountToken: false
  terminationGracePeriodSeconds: 10
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: postgresql
    - name: config
      configMap:
        name: postgresql-config
