apiVersion: apps/v1
kind: Deployment
metadata:
  name: codimd-db
spec:
  replicas: 1
  strategy:
    type: Recreate # 確保 RWO 磁碟順利切換節點
  selector:
    matchLabels:
      app: codimd-db
  template:
    metadata:
      labels:
        app: codimd-db
    spec:
      containers:
        - name: postgres
          image: postgres:17-alpine
          env:
            - name: POSTGRES_USER
              value: "codimd"
            - name: POSTGRES_DB
              value: "codimd"
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: codimd-secrets
                  key: POSTGRES_PASSWORD
            - name: PGDATA
              value: "/var/lib/postgresql/data/pgdata"
          volumeMounts:
            - mountPath: "/var/lib/postgresql/data"
              name: db-data
      volumes:
        - name: db-data
          persistentVolumeClaim:
            claimName: codimd-db-pvc
