0edbf0767f
None of the CNPG clusters had any backup configured, so a lost PVC or a bad migration meant permanent data loss. This adds continuous WAL archiving plus a nightly base backup to Ceph RGW for every cluster, with restore docs. - Add spec.backup.barmanObjectStore (in-tree; operator is CNPG 1.28, Barman Cloud Plugin not deployed) to each cnpg_cluster.yaml: WAL zstd, base bzip2, 30-day retention, endpointCA via the reflected vault-ca-cert. - Add cnpg_backup.yaml per app: a cephrgw ObjectStoreUser + Bucket (one dedicated s3://cnpg-<app> bucket and owner user per cluster, since cephrgw CRs and the CNPG credential Secret are namespace-scoped) and a staggered nightly ScheduledBackup. Credentials are minted by the operator; nothing is hardcoded. - Add the three ceph.unkin.net CRD schemas so kubeconform can validate the CRs. - Add docs/ (README index, cnpg-backups.md, cnpg-restore.md) covering config and full/PITR restore procedures. Claude-Session: https://claude.ai/code/session_015ur3i7D2azsMAWTSVABApv
88 lines
2.3 KiB
YAML
88 lines
2.3 KiB
YAML
---
|
|
apiVersion: postgresql.cnpg.io/v1
|
|
kind: Cluster
|
|
metadata:
|
|
name: postgres
|
|
namespace: grafana
|
|
spec:
|
|
affinity:
|
|
podAntiAffinityType: preferred
|
|
backup:
|
|
# 30-day retention (DEFAULT — adjust per cluster if needed). Enforced by CNPG
|
|
# against the object store on each successful base backup.
|
|
retentionPolicy: 30d
|
|
barmanObjectStore:
|
|
# Dedicated per-cluster Ceph RGW bucket (cephrgw-operator provisions it).
|
|
destinationPath: s3://cnpg-grafana
|
|
endpointURL: https://s3.ceph.unkin.net
|
|
# radosgw serves a Vault-PKI cert; trust the internal CA (reflected into
|
|
# every namespace as the vault-ca-cert Secret).
|
|
endpointCA:
|
|
name: vault-ca-cert
|
|
key: ca.crt
|
|
# Keys minted by the ObjectStoreUser in cnpg_backup.yaml; never hardcoded.
|
|
s3Credentials:
|
|
accessKeyId:
|
|
name: cnpg-grafana-backup-s3
|
|
key: AWS_ACCESS_KEY_ID
|
|
secretAccessKey:
|
|
name: cnpg-grafana-backup-s3
|
|
key: AWS_SECRET_ACCESS_KEY
|
|
# Path prefix within the bucket; keep stable across restores (see docs).
|
|
serverName: grafana
|
|
data:
|
|
compression: bzip2
|
|
jobs: 2
|
|
wal:
|
|
compression: zstd
|
|
maxParallel: 2
|
|
bootstrap:
|
|
initdb:
|
|
database: grafana
|
|
encoding: UTF8
|
|
localeCType: C
|
|
localeCollate: C
|
|
owner: grafana
|
|
secret:
|
|
name: postgres-credentials
|
|
enablePDB: true
|
|
enableSuperuserAccess: false
|
|
failoverDelay: 0
|
|
imageName: ghcr.io/cloudnative-pg/postgresql:18.1-system-trixie
|
|
instances: 2
|
|
logLevel: info
|
|
monitoring:
|
|
customQueriesConfigMap:
|
|
- key: queries
|
|
name: cnpg-default-monitoring
|
|
disableDefaultQueries: false
|
|
enablePodMonitor: false
|
|
postgresql:
|
|
parameters:
|
|
max_connections: "200"
|
|
shared_buffers: 128MB
|
|
primaryUpdateMethod: restart
|
|
primaryUpdateStrategy: unsupervised
|
|
replicationSlots:
|
|
highAvailability:
|
|
enabled: true
|
|
slotPrefix: _cnpg_
|
|
synchronizeReplicas:
|
|
enabled: true
|
|
updateInterval: 30
|
|
resources:
|
|
limits:
|
|
cpu: 500m
|
|
memory: 512Mi
|
|
requests:
|
|
cpu: 50m
|
|
memory: 256Mi
|
|
smartShutdownTimeout: 180
|
|
startDelay: 3600
|
|
stopDelay: 1800
|
|
storage:
|
|
resizeInUseVolumes: true
|
|
size: 10Gi
|
|
storageClass: cephrbd-fast-delete
|
|
switchoverDelay: 3600
|