apiVersion: apps/v1
kind: Deployment
metadata:
  name: machina-database-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: machina-database
      app.kubernetes.io/instance: database
  template:
    metadata:
      labels:
        app: machina-database
    spec:
      containers:
        - name: postgres
          image: postgres:13.2
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
          env:
            - name: POSTGRES_DB
              valueFrom:
                secretKeyRef:
                  name: machina-postgres-secret
                  key: POSTGRES_DB
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: machina-postgres-secret
                  key: POSTGRES_USER
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: machina-postgres-secret
                  key: POSTGRES_PASSWORD
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgredb
      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: postgres-storage-pvc
