hongbo-miao/hongbomiao.com

View on GitHub
kubernetes/manifests/postgres/postgres-statefulset.yaml

Summary

Maintainability
Test Coverage
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgres-statefulset
  namespace: hm-postgres
  labels:
    app.kubernetes.io/name: postgres
spec:
  serviceName: postgres-service
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: debezium/postgres:15-alpine
          env:
            - name: PGDATA
              valueFrom:
                configMapKeyRef:
                  name: postgres-configmap
                  key: pgdata
            - name: POSTGRES_DB
              valueFrom:
                configMapKeyRef:
                  name: postgres-configmap
                  key: postgres_db
            - name: POSTGRES_USER
              valueFrom:
                configMapKeyRef:
                  name: postgres-configmap
                  key: postgres_user
            - name: POSTGRES_PASSWORD
              valueFrom:
                configMapKeyRef:
                  name: postgres-configmap
                  key: postgres_password
          args: ["-c", "wal_level=logical"]
          ports:
            - name: postgres
              protocol: TCP
              containerPort: 5432
          volumeMounts:
            - name: postgres-volume
              mountPath: /var/lib/postgresql/data
  volumeClaimTemplates:
    - metadata:
        name: postgres-volume
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 1Gi