apiVersion: apps/v1
kind: Deployment
metadata:
  name: pastebin-postgres
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pastebin-postgres
  template:
    metadata:
      labels:
        app: pastebin-postgres
    spec:
      containers:
        - name: postgres
          image: postgres:15
          ports:
            - containerPort: 5432
          env:
            - name: POSTGRES_USER
              value: "mypasteuser"
            - name: POSTGRES_PASSWORD
              value: "xxxxxxxxxxxx" 
          volumeMounts:
            - name: postgres-data
              mountPath: /var/lib/postgresql/data
              subPath: pgdata
      volumes:
        - name: postgres-data
          persistentVolumeClaim:
            claimName: pastebin-postgres-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: pastebin-postgres
  namespace: default
spec:
  ports:
    - port: 5432
      targetPort: 5432
  selector:
    app: pastebin-postgres

