apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-deployment
  labels:
    app: database
    version: 1.0.0
spec:
  replicas: 1
  selector:
    matchLabels:
      component: database
  template:
    metadata:
      labels:
        component: database
        app: database
        version: 1.0.0
    spec:
      volumes:
        - name: postgres-storage
          persistentVolumeClaim:
              claimName: database-pvc
      containers:
      - name: postgres
        image: postgres:alpine
        ports:
        - containerPort: 5432
        volumeMounts:
          - name: postgres-storage
            mountPath: /var/lib/postgresql/data
            subPath: postgres
        env:
          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                name: vault
                key: POSTGRES_PASSWORD
        resources:
          limits:
            memory: "64Mi"
