db(portal): migrate WAL archiving to the CNPG-I Barman Cloud plugin

CloudNativePG 1.30 deprecates spec.backup.barmanObjectStore and 1.31 removes
it, so the pin on 1.30.0 was a hard gate. This closes that gate:

- Vendors plugin-barman-cloud v0.16.0 verbatim into
  infrastructure/databases/base/upstream/ (the operator manifest's pattern),
  with a kustomize patch only for --log-level=info and resource bounds.
  v0.16.0 requires CNPG >= 1.30 and is registered through Service
  annotations; its operator<->plugin mTLS pair comes from cert-manager
  (previous commit).
- Adds ObjectStore sirius-growth/portal-wal: the literal translation of the
  retired barmanObjectStore block, with retentionPolicy 14d moved off the
  Cluster (in the plugin, retention belongs to the store).
- Cluster portal drops spec.backup entirely and gains spec.plugins
  (barman-cloud.cloudnative-pg.io, isWALArchiver, barmanObjectName
  portal-wal, serverName portal). The server name is the barman prefix, so
  the plugin keeps writing s3://pg-wal-archive/portal/{base,wals}/... — the
  same objects the in-tree archiver left behind; the 14-day window stays
  readable.
- ScheduledBackup portal-daily switches to method: plugin.
- databases waits on cert-manager; apps waits on databases (the ObjectStore
  CRD ships with the plugin).
- CNPG dashboard: the backup timestamp metric family changes name under the
  plugin, so the panel now accepts both.
This commit is contained in:
devops 2026-11-19 17:58:12 -05:00
commit c45255242b
11 changed files with 1312 additions and 51 deletions

View file

@ -27,49 +27,35 @@ spec:
# ---------------------------------------------------------------------------
# Point-in-time recovery: continuous WAL archiving + daily base backups into
# Garage on the Linode hub (10.10.0.5), i.e. a different power and internet
# domain from this primary. Companion object: ScheduledBackup portal-daily.
# domain from this primary. Companion objects: ObjectStore portal-wal (the
# store + 14d retention) and ScheduledBackup portal-daily.
#
# This is the CNPG-I Barman Cloud **plugin** (Deployment cnpg-system/barman-cloud,
# vendored in infrastructure/databases/base), not the operator's in-tree
# barman-cloud support: 1.30 deprecates the in-tree path and 1.31 removes it
# (`Warning: Native support for Barman Cloud backups and recovery is
# deprecated ...`). See objectstore-portal-wal.yaml for the store definition.
#
# `serverName: portal` is the barman prefix and must stay exactly the cluster
# name: the plugin writes to s3://pg-wal-archive/portal/{base,wals}/... — the
# same objects the in-tree archiver left behind, so the existing 14-day window
# stays restorable. Changing it starts a new prefix and abandons that window.
#
# Credentials live in Secret sirius-growth/portal-wal-s3 (created out of band
# from the Garage key `cnpg-portal-wal`, id GK7f2b4bb1fc9abaec50fde37b, scope
# read+write on bucket `pg-wal-archive` only). Never commit the key values.
#
# This uses the operator's in-tree barman-cloud integration rather than the
# CNPG-I barman-cloud plugin: same barman-cloud binaries, no extra Deployment
# and TLS plugin registration to keep alive on a 3-node homelab. The plugin is
# the migration path when 1.30's in-tree support is finally removed.
#
# `pg_dump` in forgejo/cluster-backup still runs nightly for this database as
# a second, logical copy: a dump survives a barman-format regression or a
# store that has been emptied, and it is the only copy that is readable
# without barman. Belt and braces, not redundancy theatre — the RPO comes
# from the WAL archive, not from the dump.
backup:
retentionPolicy: "14d"
barmanObjectStore:
# Bucket root, not bucket/portal: barman appends the server name (which
# defaults to the Cluster name), so the archive lives at
# s3://pg-wal-archive/portal/{base,wals}/... — one prefix per cluster,
# which is what lets forgejo/pg share this bucket later without colliding.
destinationPath: s3://pg-wal-archive
endpointURL: http://10.10.0.5:3900
s3Credentials:
accessKeyId:
name: portal-wal-s3
key: ACCESS_KEY_ID
secretAccessKey:
name: portal-wal-s3
key: ACCESS_SECRET_KEY
region:
name: portal-wal-s3
key: REGION
# gzip on both: this is a WAL stream over the WireGuard mesh to a fixed
# 20 GB store, so bytes on the wire and in the bucket are the cost.
wal:
compression: gzip
maxParallel: 2
data:
compression: gzip
jobs: 2
plugins:
- name: barman-cloud.cloudnative-pg.io
isWALArchiver: true
parameters:
barmanObjectName: portal-wal
serverName: portal
# Scraped via podmonitor.yaml in this directory (hand-written; see the comment
# in apps/base/forgejo/podmonitor.yaml for why enablePodMonitor is false).
# Only the operator's default query set here — this database needs no custom

View file

@ -14,6 +14,8 @@ resources:
- service-blog.yaml
- service-portal-gate.yaml
- httproute.yaml
# The WAL archive store must exist before the Cluster references it.
- objectstore-portal-wal.yaml
- cluster.yaml
- scheduled-backup.yaml
- podmonitor.yaml

View file

@ -0,0 +1,51 @@
# The WAL archive for Cluster sirius-growth/portal, in the CNPG-I Barman Cloud
# plugin's own CR instead of Cluster.spec.backup.barmanObjectStore.
#
# Same store, same layout: destinationPath is the *bucket root* and the plugin
# appends the server name (Cluster.spec.plugins[].parameters.serverName, set to
# `portal`), so the existing objects stay exactly where the in-tree archiver put
# them — s3://pg-wal-archive/portal/{base,wals}/... . Anything that changes the
# prefix silently abandons the 14-day window that is already in the bucket.
#
# `spec.configuration` is the literal translation of the retired
# `spec.backup.barmanObjectStore` block (same schema, same Secret), and
# `retentionPolicy` moved here from Cluster.spec.backup.retentionPolicy — in the
# plugin architecture retention is a property of the store, not the cluster.
#
# Credentials: Secret sirius-growth/portal-wal-s3 (Garage key `cnpg-portal-wal`,
# id GK7f2b4bb1fc9abaec50fde37b, RW on bucket `pg-wal-archive` only), created
# out of band. The key values are deliberately not in git.
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
name: portal-wal
namespace: sirius-growth
spec:
configuration:
destinationPath: s3://pg-wal-archive
endpointURL: http://10.10.0.5:3900
s3Credentials:
accessKeyId:
name: portal-wal-s3
key: ACCESS_KEY_ID
secretAccessKey:
name: portal-wal-s3
key: ACCESS_SECRET_KEY
region:
name: portal-wal-s3
key: REGION
# gzip on both directions: this is a WAL stream over the WireGuard mesh into
# a 20 GB store on the Linode, so bytes on the wire and in the bucket are
# the cost. Must match what the in-tree archiver wrote (gzip) — the
# archive is read by segment, but a mismatch in base-backup compression
# would make the existing base backups unrestorable.
wal:
compression: gzip
maxParallel: 2
data:
compression: gzip
jobs: 2
# Enforced by the plugin instance sidecar every 30 min (default
# retentionPolicyIntervalSeconds) with barman-cloud's retention logic, i.e.
# the same 14-day window the in-tree archiver maintained.
retentionPolicy: "14d"

View file

@ -12,8 +12,13 @@ spec:
name: portal
# `self`: the Backup objects are owned by this ScheduledBackup, so deleting the
# schedule (or the namespace) does not leave orphaned Backups pointing at the
# cluster. Retention/cleanup of the archive itself is the Cluster's
# spec.backup.retentionPolicy (14d), enforced by barman-cloud on each backup.
# cluster. Retention/cleanup of the archive itself is the ObjectStore's
# spec.retentionPolicy (14d), enforced by the plugin's sidecar.
backupOwnerReference: self
method: barmanObjectStore
# Plugin method, not `barmanObjectStore`: the in-tree method is removed in
# CNPG 1.31. `pluginConfiguration` names the CNPG-I plugin, whose
# ObjectStore is referenced by the Cluster's spec.plugins.
method: plugin
pluginConfiguration:
name: barman-cloud.cloudnative-pg.io
immediate: false