apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: forgejo-postgres-pvc
  namespace: forgejo
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: local-path
  resources:
    requests:
      storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  namespace: forgejo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: postgres:16-alpine
          env:
            - name: POSTGRES_USER
              value: forgejo
            - name: POSTGRES_PASSWORD
              value: forgejo
            - name: POSTGRES_DB
              value: forgejo
          volumeMounts:
            - name: postgres-data
              mountPath: /var/lib/postgresql/data
      volumes:
        - name: postgres-data
          persistentVolumeClaim:
            claimName: forgejo-postgres-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: postgres
  namespace: forgejo
spec:
  selector:
    app: postgres
  ports:
    - port: 5432
      targetPort: 5432
