apiVersion: apps/v1 kind: StatefulSet metadata: name: postgres spec: serviceName: postgres replicas: 1 selector: matchLabels: app: postgres template: metadata: labels: app: postgres spec: # No _PORT=tcp://... env vars: apps like Paperless read # PAPERLESS_PORT as their own setting and crash. enableServiceLinks: false # Start directly as postgres (uid/gid 70 in the alpine image): the # entrypoint then skips gosu, which spins forever at 100% CPU on the # k3s nodes since their 2026-11-07 kernel upgrade. No fsGroup: it would # add group permissions to PGDATA and postgres refuses anything but 0700/0750. securityContext: runAsUser: 70 runAsGroup: 70 containers: - name: postgres image: postgres:17.11-alpine ports: - name: postgres containerPort: 5432 envFrom: - secretRef: name: postgres-secrets env: # Subdirectory: the volume's root holds ext4's lost+found. - name: PGDATA value: /var/lib/postgresql/data/pgdata volumeMounts: - name: data mountPath: /var/lib/postgresql/data - name: init mountPath: /docker-entrypoint-initdb.d readinessProbe: exec: command: ["pg_isready", "-U", "postgres"] periodSeconds: 10 resources: requests: cpu: 100m memory: 256Mi limits: memory: 1Gi volumes: - name: init configMap: name: postgres-init volumeClaimTemplates: - metadata: name: data spec: accessModes: ["ReadWriteOnce"] storageClassName: longhorn resources: requests: storage: 10Gi