apiVersion: apps/v1
kind: Deployment
metadata:
  name: database
spec:
  replicas: 1
  selector:
    matchLabels:
      component: postgres
  template:
    metadata:
      labels:
        component: postgres
    spec:
      serviceAccountName: database
      volumes:
        - name: postgres-data
          persistentVolumeClaim:
            claimName: database
      containers:
        - name: postgres
          image: centos/postgresql-10-centos7@sha256:de1560cb35e5ec643e7b3a772ebaac8e3a7a2a8e8271d9e91ff023539b4dfb33
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              cpu: 500m
              memory: 2Gi
          ports:
            - containerPort: 5432
              protocol: TCP
          env:
            # postgres-config-secret is injected by the postgres controller
            # through a SecretGenerator, see file ctrls/postgres/postgres.go.
            - name: POSTGRESQL_USER
              valueFrom:
                secretKeyRef:
                  name: postgres-config-secret
                  key: database-username
            - name: POSTGRESQL_DATABASE
              valueFrom:
                secretKeyRef:
                  name: postgres-config-secret
                  key: database-name
            - name: POSTGRESQL_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-config-secret
                  key: database-root-password
            - name: POSTGRESQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-config-secret
                  key: database-password
            - name: POSTGRESQL_SHARED_BUFFERS
              value: 256MB
            - name: POSTGRESQL_MAX_CONNECTIONS
              value: "2000"
          volumeMounts:
            - name: postgres-data
              mountPath: /var/lib/pgsql/data
