CloudNativePG
CloudNativePG
PostgreSQL managé (socle DataOps, étape 1.6, ADR 0024). Un cluster HA servant deux usages via deux bases logiques : l’event log Dagster (1.7) et l’index pgvector (recherche sémantique, chargé par atlas). Sauvegardes vers S3 via le plugin Barman Cloud.
Géré par kubectl apply (comme les autres addons platform/), pas par Argo CD
(anti-bootstrap-circulaire,
ADR 0022).
Fichiers
| Fichier | Rôle | Lint |
|---|---|---|
operator.yaml | operator CNPG 1.29.1 vendored | exclu |
plugin-barman-cloud.yaml | plugin Barman Cloud v0.12.0 vendored (sauvegardes S3) | exclu |
cluster.yaml | CR Cluster (3 instances, PG18, pgvector, rôles, plugin) | linté |
database.yaml | CR Database ×2 (dagster, pgvector + extension vector) | linté |
objectstore.yaml | CR ObjectStore S3 (endpoint/creds paramétrables) | linté |
init-buckets.yaml | Job créant le bucket S3 (à lancer avant le Cluster) | linté |
backup.yaml | ScheduledBackup (plugin) | linté |
secret.example.yaml | patron creds S3 versionné (.example) | linté |
Prérequis impératifs
- cert-manager déployé (le plugin Barman exige du TLS plugin↔operator).
- Feature gate Kubernetes
ImageVolume=true(apiserver + kubelet) — requis par les Image Volume Extensions (la voie pgvector sans image custom). Beta en K8s 1.33+ mais NON activée par défaut. Le bootstrap l’active (config kubeadm, rôlek8s-initialization— cf. ADR 0006). Sans ce flag :extension "vector" is not available. - Un provisioner de stockage (RWO) pour les PVC.
Déploiement — ordre
# 1. operator (server-side : CRDs volumineuses) + plugin Barmankubectl apply --server-side -f platform/cloudnative-pg/operator.yamlkubectl -n cnpg-system rollout status deploy/cnpg-controller-managerkubectl apply --server-side -f platform/cloudnative-pg/plugin-barman-cloud.yaml
# 2. credentials S3 + bucket de sauvegarde (avant le Cluster, sinon NoSuchBucket)kubectl apply -f platform/cloudnative-pg/secret.example.yaml # renommer/surcharger selon la topologiekubectl apply -f platform/cloudnative-pg/init-buckets.yamlkubectl -n postgres wait --for=condition=complete job/cnpg-init-buckets
# 3. ObjectStore (S3) + Cluster (provisionne les 3 instances + pgvector)kubectl apply -f platform/cloudnative-pg/objectstore.yamlkubectl apply -f platform/cloudnative-pg/cluster.yaml
# 4. bases logiques (CREATE DATABASE + CREATE EXTENSION vector) + backup planifiékubectl apply -f platform/cloudnative-pg/database.yamlkubectl apply -f platform/cloudnative-pg/backup.yamlPoints de surcharge par topologie (jamais de valeur réelle versionnée — ADR 0023)
| Paramètre | Banc léger (Lima/kind) | Topologie bare-metal |
|---|---|---|
storage.storageClass (cluster.yaml) | standard/local-path | rook-ceph-block-replicated (RBD ×3, ADR 0001) |
endpointURL (objectstore.yaml) | SeaweedFS seaweedfs.s3.svc:8333 | RGW Ceph rook-ceph-rgw-datalake.rook-ceph:80 |
Secret pg-backup-s3 | secret.example.yaml (test) | Secret non versionné (config locale) |
Adaptations
- Images épinglées par digest d’index multi-arch (ADR 0006).
- 3 instances HA (1 primary + 2 replicas, réplication streaming).
- RBD réplication ×3, jamais EC 2+1 pour ce stateful (ADR 0001 : EC bloque l’I/O à la perte d’un hôte).
- pgvector via Image Volume Extension (
cluster.yamlpostgresql.extensions) ; nom SQL de l’extension =vector(paspgvector).
Validation
Sur le banc léger : Cluster Healthy, CREATE EXTENSION vector OK, colonne
vector(384) + requête kNN (<->), base dagster créée, et sauvegarde
testée (base + WAL archivés dans le bucket S3). Cf.
bootstrap/state.sh
(section CloudNativePG).
Régénérer les manifestes vendored
curl -sL https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.29/releases/cnpg-1.29.1.yaml -o operator.yamlcurl -sL https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v0.12.0/manifest.yaml -o plugin-barman-cloud.yaml# puis réinjecter les digests d'index multi-arch (cf. ADR 0006).