mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-01 20:56:02 +09:00
The chart generated every user's password at render time into <release>-credentials, which tenants could read again at any time and which Helm history kept for MaxHistory revisions, so a deployment whose policy requires a credential shown once could not run PostgreSQL here. The chart now renders a CredentialTemplate per user, and the users move under CloudNativePG's managed roles, each pointing at its account Secret, so the operator creates the role with the SCRAM verifier the Secret holds, applies a changed Secret live, and reverts a password set inside PostgreSQL. Every role is rendered as the init-script created it, because the operator reverts an attribute that differs, revokes a parent role missing from inRoles and clears a comment the spec leaves unset. The init-script stops creating, passwording and altering accounts, where it would be a second writer, and keeps the two things the operator has no field for: the marker membership and the reset of the createrole_self_grant an earlier chart set. Its marking pass waits a bounded time for CloudNativePG to create the declared roles before it marks them. users.app adopts the owner CloudNativePG bootstraps, whose password the instance manager applies again from the bootstrap secret on every pod start, so that secret is the app user's account Secret and both writers apply the one stored verifier. A users.<name>.password left in values draws an admission warning that points at a mint on the user's Credential. createRole is refused on every render path. A role a CREATEROLE user creates makes that user a member of it, CloudNativePG revokes every membership a managed role is not declared to hold, and the revoke fails on the dependent self-grant, so the user would sit in cannotReconcile on ordinary use; there is no per-role switch to leave memberships alone. The account-name checks render with the managed roles too, so a restore cannot bypass them: a user CloudNativePG or PostgreSQL reserves, a database whose derived <name>_admin or <name>_readonly role starts with pg_ or cnpg_ (which makes the CloudNativePG webhook reject the whole Cluster), and a user whose account name is no valid object name are refused. The chart's account naming is pinned to the API's on one table of names. A pre-upgrade hook refuses to let CloudNativePG adopt a role the chart did not mark, because the operator adopts a managed role within seconds of the spec reaching it, before any post-upgrade job could look. It reads the live Cluster first and connects to the database only when the upgrade adds a name CloudNativePG does not manage yet, so a database that is down does not block the resize that might fix it. For each absent declared database role it creates and marks the role as the superuser before the Cluster applies, so no tenant can plant it in the adoption window. The refusal and the create run in one psql session, keyed on a snapshot of the role's existence taken at the top, so a role planted in between collides with the CREATE and stops the hook; the statements are built with format() and \gexec, since psql does not substitute :'role' inside a DO $$ block. Verified on postgres:18: a fresh role is created NOINHERIT, commented and marked, a role planted after the snapshot fails the hook, and an existing unmarked role is refused. The hook reads the Cluster at run time with a ServiceAccount that may get only that Cluster, rather than through a template lookup, which nothing re-renders when the object changes. The flag an earlier chart set when a user held createRole is still read and never set, so such a release keeps refusing to adopt a role it did not mark. The EndpointAttachment e2e suite read testuser's password from that Secret to probe the attached addresses. It now mints one per probe and waits until the application's own Service accepts it, so the attached address is still queried exactly once. BREAKING CHANGE: PostgreSQL passwords are no longer readable from <release>-credentials. A password is issued once, by a mint on the account's Credential in core.cozystack.io, and replaced by the next mint. users.<name>.createRole is refused; a release that sets it keeps its previous chart version and passwords until it is false. Deleting a Postgres application whose release is suspended is refused. The conversion needs a platform variant with migrations enabled. Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Co-authored-by: Andrei Kvapil <kvapss@gmail.com> Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
417 lines
34 KiB
YAML
417 lines
34 KiB
YAML
##
|
|
## @section Common parameters
|
|
##
|
|
|
|
## @typedef {struct} Resources - Explicit CPU and memory configuration for each PostgreSQL replica.
|
|
## @field {quantity} [cpu] - CPU available to each replica.
|
|
## @field {quantity} [memory] - Memory (RAM) available to each replica.
|
|
|
|
## @enum {string} ResourcesPreset - Default sizing preset.
|
|
## @value t1.nano
|
|
## @value t1.micro
|
|
## @value t1.small
|
|
## @value t1.medium
|
|
## @value t1.large
|
|
## @value t1.xlarge
|
|
## @value t1.2xlarge
|
|
## @value t1.4xlarge
|
|
## @value c1.nano
|
|
## @value c1.micro
|
|
## @value c1.small
|
|
## @value c1.medium
|
|
## @value c1.large
|
|
## @value c1.xlarge
|
|
## @value c1.2xlarge
|
|
## @value c1.4xlarge
|
|
## @value s1.nano
|
|
## @value s1.micro
|
|
## @value s1.small
|
|
## @value s1.medium
|
|
## @value s1.large
|
|
## @value s1.xlarge
|
|
## @value s1.2xlarge
|
|
## @value s1.4xlarge
|
|
## @value u1.nano
|
|
## @value u1.micro
|
|
## @value u1.small
|
|
## @value u1.medium
|
|
## @value u1.large
|
|
## @value u1.xlarge
|
|
## @value u1.2xlarge
|
|
## @value u1.4xlarge
|
|
## @value m1.nano
|
|
## @value m1.micro
|
|
## @value m1.small
|
|
## @value m1.medium
|
|
## @value m1.large
|
|
## @value m1.xlarge
|
|
## @value m1.2xlarge
|
|
## @value m1.4xlarge
|
|
## @value nano
|
|
## @value micro
|
|
## @value small
|
|
## @value medium
|
|
## @value large
|
|
## @value xlarge
|
|
## @value 2xlarge
|
|
|
|
## @param {int} replicas - Number of Postgres replicas. Under active autoscaling this is the resting/seed count, not the live count — KEDA drives the live count via `/scale`. Disabling autoscaling does NOT automatically bring the live count back to `replicas`: the client-side merge writes `instances` only when the rendered value changes, so a cluster KEDA grew past `replicas` stays there with no autoscaler left to reduce it — lower `replicas` to the count you want and it rebases down (shedding the surplus replicas + PVCs). Lowering it below the live count, or disabling/dry-running while it sits below the live count, sheds in one step past the scaleDown pacing; stage it to the live count first (suspend the HelmRelease and `kubectl scale` if needed) to avoid a transient. Must stay greater than `quorum.maxSyncReplicas`.
|
|
replicas: 2
|
|
|
|
## @param {Resources} [resources] - Explicit CPU and memory configuration for each PostgreSQL replica. When omitted, the preset defined in `resourcesPreset` is applied.
|
|
resources: {}
|
|
|
|
## @param {ResourcesPreset} resourcesPreset="t1.micro" - Default sizing preset used when `resources` is omitted.
|
|
resourcesPreset: "t1.micro"
|
|
|
|
## @param {quantity} size - Persistent Volume Claim size available for application data.
|
|
size: 10Gi
|
|
|
|
## @param {string} storageClass - StorageClass used to store the data.
|
|
## @immutable
|
|
## @x-cozystack-options {source: storageclass}
|
|
storageClass: ""
|
|
|
|
## @param {bool} external - Enable external access from outside the cluster.
|
|
external: false
|
|
|
|
## @param {string} schedulingClass - Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`. Setting any other value is refused, and the pods of an application whose class is not, or no longer, in that list get the tenant's class. Empty means inherit from the tenant.
|
|
## @maxLength 63
|
|
schedulingClass: ""
|
|
|
|
##
|
|
## @enum {string} Version
|
|
## @value v18
|
|
## @value v17
|
|
## @value v16
|
|
## @value v15
|
|
## @value v14
|
|
## @value v13
|
|
|
|
## @param {Version} version - PostgreSQL major version to deploy
|
|
version: v18
|
|
|
|
##
|
|
## @enum {string} Flavor
|
|
## @value postgresql
|
|
## @value postgis
|
|
|
|
## @param {Flavor} flavor - PostgreSQL image flavor, fixed when the cluster is created. `postgresql` uses the CloudNativePG PostgreSQL image. `postgis` uses the CloudNativePG PostGIS image, which adds postgis, postgis_raster, postgis_topology, postgis_sfcgal, postgis_tiger_geocoder and address_standardizer; enable them per database in `databases.<name>.extensions`. Changing the flavor of an existing cluster is refused, and a backup restores only into a cluster of the flavor it was taken from: to change flavor, create a new cluster and move the data with a logical dump (pg_dump / pg_restore).
|
|
flavor: postgresql
|
|
|
|
## @param {bool} allowCollationChange - Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The collation repair Job, which a post-upgrade hook starts once the init Job is done, rebuilds the indexes on such text after the rollout, those on C.UTF-8 and other C.* locales included, and its log reports a rebuild that failed; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.
|
|
allowCollationChange: false
|
|
|
|
##
|
|
## @section TLS configuration
|
|
##
|
|
|
|
## @typedef {struct} TLS - TLS configuration for PostgreSQL server connections.
|
|
## @field {*bool} enabled - Tri-state switch controlling whether the chart injects the external hostnames into the operator-managed CNPG cert via spec.certificates.serverAltDNSNames. When omitted, the chart injects them if `external: true` and skips them otherwise. Set explicitly to `true` to inject regardless of `external` (no-op when `external: false` since there is no external hostname to add). Set to `false` to skip injection. Note that CNPG keeps its built-in TLS on the wire regardless of this flag — this toggle only controls the chart-side SAN injection; to disable PostgreSQL TLS entirely set `postgresql.parameters.ssl = "off"` at the CNPG layer.
|
|
## @field {*bool} required - Tri-state switch controlling whether the server refuses sessions that are not encrypted. When omitted, it is on if `external: true` and off otherwise. When on, the chart renders `spec.postgresql.pg_hba` with `hostssl all all all scram-sha-256` (`md5` on PostgreSQL 13, matching CloudNativePG's default rule) followed by `host all all all reject`, so a client that connects with `sslmode=disable` is refused instead of getting a plaintext session; in-cluster clients are held to the same rule, since the pod network cannot be told apart from an external client. Set to `false` to keep accepting plaintext sessions on an external instance, or to `true` to require TLS on an in-cluster one. Rendering fails if `postgresql.parameters.ssl` is off while this is in effect.
|
|
|
|
## @param {TLS} tls - TLS configuration for server connections.
|
|
tls: {}
|
|
|
|
## @section Application-specific parameters
|
|
##
|
|
|
|
##
|
|
## @enum {string} PreloadLibrary
|
|
## @value pg_stat_statements
|
|
## @value auto_explain
|
|
## @value pgaudit
|
|
## @value pg_prewarm
|
|
|
|
## @typedef {struct} PostgreSQL - PostgreSQL server configuration.
|
|
## @field {[]PreloadLibrary} [sharedPreloadLibraries] - Libraries loaded at server start, restricted to an allowlist of modules already shipped in the PostgreSQL image. CloudNativePG also preloads `pg_stat_statements`, `auto_explain` and `pgaudit` by itself whenever `parameters` sets a key under their prefix (e.g. `pg_stat_statements.track`), so removing one of them from this list does not unload it while such a key is set; `pg_prewarm` is preloaded only through this list. Changing the list restarts PostgreSQL on every instance, the primary included, so writes pause briefly.
|
|
## @field {map[string]intOrString} [parameters] - PostgreSQL server parameters. Values may be strings or integers; integers are coerced to strings by the template (e.g. both `max_connections: 100` and `max_connections: "100"` are accepted). BLOCKED (enable arbitrary code execution): archive_command, restore_command, ssl_passphrase_command, archive_cleanup_command, recovery_end_command, dynamic_library_path, local_preload_libraries, session_preload_libraries, shared_preload_libraries. Do NOT override CloudNativePG-managed parameters: archive_mode, primary_conninfo, wal_level, max_replication_slots.
|
|
|
|
## @param {PostgreSQL} postgresql - PostgreSQL server configuration.
|
|
postgresql:
|
|
parameters:
|
|
max_connections: "100"
|
|
## Additional parameters examples:
|
|
## shared_buffers: "1GB"
|
|
## effective_cache_size: "4GB"
|
|
## bgwriter_delay: "200ms"
|
|
## commit_delay: "100"
|
|
## commit_siblings: "5"
|
|
## work_mem: "256MB"
|
|
##
|
|
## SECURITY: The following parameters are BLOCKED (enable arbitrary code execution):
|
|
## archive_command, restore_command, ssl_passphrase_command, archive_cleanup_command, recovery_end_command (shell commands),
|
|
## dynamic_library_path, local_preload_libraries, session_preload_libraries,
|
|
## shared_preload_libraries (arbitrary .so loading)
|
|
##
|
|
## To preload a module, use the `sharedPreloadLibraries` allowlist instead of the
|
|
## blocked `shared_preload_libraries` parameter:
|
|
## sharedPreloadLibraries:
|
|
## - pg_stat_statements
|
|
## - auto_explain
|
|
##
|
|
## IMPORTANT: Do NOT override CloudNativePG-managed parameters:
|
|
## archive_mode, primary_conninfo, wal_level, max_replication_slots
|
|
##
|
|
## NOTE: Some parameters require pod restart (not just reload):
|
|
## shared_buffers, max_connections, max_prepared_transactions,
|
|
## wal_buffers, max_wal_senders
|
|
##
|
|
## When shared_buffers is not set and the memory limit is below 512Mi, the
|
|
## chart sets it to a quarter of the limit with a 16MB floor, capped at the
|
|
## memory request rounded down to whole MiB. Larger limits keep the
|
|
## PostgreSQL default of 128MB.
|
|
|
|
##
|
|
## @section Audit parameters
|
|
##
|
|
|
|
## @typedef {struct} Audit - PostgreSQL audit configuration.
|
|
## @field {bool} [enabled] - Enable PostgreSQL auditing. Loads the pgaudit extension through the `sharedPreloadLibraries` allowlist and turns on `log_connections`/`log_disconnections`, so who connected and the classes of statement they ran are written to the instance log and collected by the platform log stack. The audited statement classes are set by `log`. Off by default. Enabling or disabling it restarts PostgreSQL, since pgaudit is a preloaded library. Note that `write` and `all` record statement text with literal values, so anyone who can read the tenant's log stack can read audited data; keep that in mind on a shared Monitoring.
|
|
## @field {string} [log] - pgaudit session audit classes recorded when `enabled`, as the comma-separated value of `pgaudit.log`. Valid classes are `read`, `write`, `function`, `role`, `ddl`, `misc`, `misc_set`, `all` and `none`; a class may be prefixed with `-` to subtract it from `all` (for example `ddl, role`, `write, ddl, role`, or `all, -misc`). `all` logs every statement including reads and is heavy. Defaults to `write, ddl, role`. A `pgaudit.log` set in `postgresql.parameters` overrides this. The pattern rejects an unrecognised class at admission, which otherwise makes pgaudit fall back to `none` at the next start and silently disables auditing.
|
|
## @pattern ^(\s*-?(read|write|function|role|ddl|misc_set|misc|all|none)\s*(,\s*-?(read|write|function|role|ddl|misc_set|misc|all|none)\s*)*)?$
|
|
|
|
## @param {Audit} audit - PostgreSQL audit configuration.
|
|
audit:
|
|
enabled: false
|
|
log: "write, ddl, role"
|
|
|
|
##
|
|
## @section Quorum-based synchronous replication
|
|
##
|
|
|
|
## @typedef {struct} Quorum - Quorum configuration for synchronous replication.
|
|
## @field {int} minSyncReplicas - Minimum number of synchronous replicas required for commit.
|
|
## @field {int} maxSyncReplicas - Maximum number of synchronous replicas allowed (must be less than total replicas). Under autoscaling it also sets the scale-down floor (the effective minimum is `max(minReplicas, maxSyncReplicas+1, 2)`); the chart fails to render if that floor exceeds `autoscaling.maxReplicas`.
|
|
|
|
## @param {Quorum} quorum - Quorum configuration for synchronous replication.
|
|
quorum:
|
|
minSyncReplicas: 0
|
|
maxSyncReplicas: 0
|
|
|
|
##
|
|
## @section Autoscaling
|
|
##
|
|
|
|
## @typedef {struct} Autoscaling - Horizontal autoscaling of read replicas via KEDA. When active, the CNPG instance count is SEEDED from `max(replicas, floor)` and then driven by a KEDA ScaledObject from read load; `replicas` becomes the resting/seed count, not the live count, which KEDA owns via the `/scale` subresource. Disabling does not auto-restore the live count to `replicas` (the unchanged seed is a merge no-op); lower `replicas` to reclaim capacity KEDA grew.
|
|
## @field {bool} enabled - Enable horizontal autoscaling of read replicas. Requires the platform `keda` package to be enabled by an administrator first; the chart fails to render (rather than break the release) if KEDA is not installed. Prerequisite: the queried vmselect must hold BOTH the CNPG metrics (cnpg_backends_total / container CPU) AND kube_pod_labels (kube-state-metrics). This holds for a tenant on the shared root monitoring stack (`monitoring: false`, both land in tenant-root). A tenant running its OWN Monitoring app (`monitoring: true`) has the CNPG metrics but not kube_pod_labels (KSM is root-only), so it must set `serverAddress` to a vmselect carrying both series or autoscaling never actuates.
|
|
## @field {string} serverAddress - Override the Prometheus/vmselect URL the ScaledObject queries. Empty (default) derives `http://vmselect-shortterm.<monitoring-ns>.svc:8481/select/0/prometheus`. Set it when the derived vmselect does not hold both the CNPG metrics and kube_pod_labels (e.g. `monitoring: true` tenants, or a non-default `metricsStorages` name). SSRF constraint: the host must be an in-cluster Service DNS name (`<svc>.<ns>.svc[.<clusterDomain>]`) whose namespace is within the tenant's own subtree (its namespace, its parents, or `tenant-root`) — the cluster-privileged KEDA operator fetches this URL every poll, so it is refused a metadata endpoint, an external host, or a sibling/system namespace. Residual surface (accepted trade-off): `tenant-root` is always allowed because the derived default points there, so a tenant can still aim the operator at any Service in `tenant-root` on any port/path (a blind in-cluster reachability probe — the operator reads no response body back to the tenant); the egress NetworkPolicy does not narrow that.
|
|
## @field {int} minReplicas - Minimum total instances; raised to the synchronous-quorum floor (`maxSyncReplicas + 1`) and to 2 when either is higher.
|
|
## @field {int} maxReplicas - Maximum total instances. Must be >= minReplicas and >= the synchronous-quorum floor (maxSyncReplicas+1); the chart fails to render (rather than silently run an unbounded instance count) if the effective floor exceeds it - raise maxReplicas. HAZARD: lowering maxReplicas below the live count makes the HPA cut straight to the new maximum in one step (the current>max branch bypasses the scale-down pacing), shedding the surplus replicas + PVCs at once; to lower it deliberately, suspend the HelmRelease and pin the live count with `kubectl scale` first.
|
|
## @field {ReadMetric} metric - Read-load signal to scale on.
|
|
## @field {int} target - Target read load per read-serving replica (unit depends on `metric`: active connections, or CPU millicores). Dimensionless integer - a resource.Quantity here would accept `150m`, which PromQL reads as 150 minutes and KEDA cannot use as a threshold.
|
|
## @field {int} maxReplicationLagSeconds - Freeze scaling while replication lag exceeds this (seconds) and the primary is writing. 0 disables the brake. Default 0: the freeze branch has only been validated on a live cluster in its non-braking (pass-through) form, so the lag brake is opt-in until the braking path is exercised under load; set a positive value (e.g. 30) to enable it.
|
|
## @field {bool} dryRun - Recommendation mode: keep the static count and render the ScaledObject with both scaling directions paused, so KEDA keeps the HPA and keeps serving its trigger metric but actuates neither way. Note both scaling policies are disabled, so the HPA's desiredReplicas is frozen to the current count - read the recommendation from the matching read-load dashboard panel for your metric (connections or CPU): desired = 1 + ceil(read load / target), clamped to [effectiveMin..maxReplicas] where effectiveMin = max(minReplicas, maxSyncReplicas+1, 2), not from the desired-replicas line. Like disabling, flipping a LIVE autoscaled cluster into dryRun re-renders `instances: replicas` (the raw static value, which can be below the autoscaling floor); if `replicas` is below the live count, stage it to the live count first (see the enablement note) or the cluster sheds down to `replicas`. No shed occurs when the rendered value is unchanged (replicas already equals the active seed) — client-side merge is then a no-op and the live count is preserved. Permanent, unlike `transition`.
|
|
## @field {bool} transition - Migration phase 1: render `.spec.instances` from `replicas` (which the operator stages to the current live count) AND pause the ScaledObject in both directions, so KEDA stands up with its HPA present but not actuating. Flip to false (phase 2) to hand the runtime count to KEDA. Because the both-direction pause keeps the HPA (not the HPA-deleting full pause), KEDA is genuinely warm at phase 2 — no HPA recreate — and because the active seed is max(replicas, effectiveMin), phase 2 re-renders the same instance count phase 1 did (when `replicas` is staged at/above the floor), so the flip is a merge no-op with no dip. The HPA's scaleUp stabilization window still smooths the first actuation.
|
|
|
|
## @enum {string} ReadMetric - Read-load metric type.
|
|
## @value ReadConnections - Active read connections on the standby pods.
|
|
## @value ReadCPUUtilization - CPU (millicores) of the postgres container on the standby pods.
|
|
|
|
## Under active autoscaling the KEDA HPA owns the runtime count via the /scale
|
|
## subresource, and the chart SEEDS `.spec.instances` at a CONSTANT =
|
|
## max(.Values.replicas, effectiveMin), where effectiveMin = max(minReplicas,
|
|
## maxSyncReplicas+1, 2). It re-renders that same constant every reconcile, and the
|
|
## postgres HelmRelease applies CLIENT-SIDE, under which helm-controller patches this CRD
|
|
## from the previous-vs-new rendered manifest and does not consult live state, so the
|
|
## unchanged constant yields no patch and never reverts KEDA's higher live value written
|
|
## through /scale.
|
|
## Client-side apply is forced per-app: the platform's helm-controller (v1.5.0) defaults
|
|
## to server-side apply, which would force-own the rendered field and revert it, so the
|
|
## postgres ApplicationDefinition carries `release.cozystack.io/helm-server-side-apply:
|
|
## "false"` (threaded onto the HelmRelease in pkg/registry/apps/application/rest.go).
|
|
## Seeding (rather than omitting) is deliberate: an omitted field defaults to 1, which the
|
|
## CNPG webhook rejects under quorum, and — worse — under server-side apply the phase-2
|
|
## omit prunes the field whenever KEDA has not yet written /scale (e.g. a cluster idle at
|
|
## its floor), collapsing it to 1 and decommissioning every replica PVC (see community
|
|
## design proposal §Upgrade "Implementation update 2026-09-02"; validated live on a test cluster).
|
|
## Seeding max(replicas, effectiveMin) — rather than effectiveMin alone — keeps the active
|
|
## branch equal to the disabled/dryRun/transition branch (which renders `instances:
|
|
## replicas`) whenever `replicas` sits at or above the floor, so enabling, dry-running, or
|
|
## completing a transition is a merge no-op and the live count does NOT dip.
|
|
## The merge writes `instances` (rebasing the live count) only when the newly-rendered
|
|
## SEED differs from the previously-rendered one — KEDA's live count is never compared —
|
|
## so the residual drop cases are narrow:
|
|
## (1) LOWERING `.Values.replicas` below the live count (or enabling with `replicas`
|
|
## left at its default 2 while the live cluster is larger): the seed becomes
|
|
## max(replicas, floor) and the live count rebases down to it (never below the
|
|
## quorum floor, never a collapse to 1), decommissioning the surplus replicas+PVCs.
|
|
## Stage `replicas` to the live count first to avoid this.
|
|
## (2) RAISING `minReplicas`/`quorum.maxSyncReplicas` so the floor exceeds both the live
|
|
## count and `replicas`: the seed rises and the live count is raised to it. Lowering
|
|
## the floor is a no-op while `replicas` >= the new floor.
|
|
## HAZARD (either case, under load): the rebase compares the newly-rendered seed to the
|
|
## PREVIOUS rendered seed — never to KEDA's live count. So whenever load has scaled the live
|
|
## count ABOVE the seed and any chart change re-renders a seed still at/below that live count
|
|
## (lowering `replicas`, OR raising the floor to a value still below the live count), the
|
|
## re-apply cuts `.spec.instances` straight down to the seed in ONE step — shedding the
|
|
## surplus standbys and their PVCs past the scaleDown pacing — before the HPA re-clones them
|
|
## back up. This is the same one-step shed the lowering-`maxReplicas` HAZARD warns about, but
|
|
## triggered by a floor/replicas change rather than the ceiling. Stage the live count into
|
|
## `replicas` first (below) to avoid the transient.
|
|
## To rebase deliberately with no transient: suspend the HelmRelease, pin the live count
|
|
## with `kubectl scale cluster.postgresql.cnpg.io/<name> --replicas=<live count>` and set
|
|
## `.Values.replicas` to match (or use the two-phase `transition` flow), apply, then
|
|
## resume. The `transition` flag additionally lets KEDA come up warm so it actuates at
|
|
## phase 2 without recreating the HPA.
|
|
## Keep `.Values.replicas` greater than `quorum.maxSyncReplicas` even under autoscaling:
|
|
## the active path floors the seed up to effectiveMin so it admits a too-small `replicas`,
|
|
## but the static path (disable / dryRun / transition phase 1) renders `instances:
|
|
## replicas` and fails closed when `replicas <= maxSyncReplicas` — so a too-small
|
|
## `replicas` only surfaces when you later disable or dry-run, not at enable.
|
|
## Likewise `autoscaling.maxReplicas` must be >= effectiveMin = max(minReplicas,
|
|
## maxSyncReplicas+1, 2) or the chart fails to render (it will not silently run an
|
|
## unbounded instance count) — e.g. with the default read floor, maxReplicas must be >= 2.
|
|
## @param {Autoscaling} autoscaling - Read-replica autoscaling configuration.
|
|
autoscaling:
|
|
enabled: false
|
|
serverAddress: ""
|
|
minReplicas: 2
|
|
maxReplicas: 6
|
|
metric: ReadConnections
|
|
target: 150
|
|
maxReplicationLagSeconds: 0
|
|
dryRun: false
|
|
transition: false
|
|
|
|
##
|
|
## @section Users configuration
|
|
##
|
|
|
|
## @typedef {struct} User - User configuration.
|
|
## @field {bool} [replication] - Whether the user has replication privileges.
|
|
## @field {bool} [createRole] - Not supported while users are CloudNativePG managed roles: the chart refuses to render when it is true, and a release that sets it keeps its previous chart version until it is false. CloudNativePG revokes every membership a managed role is not declared to hold, including the one PostgreSQL gives a CREATEROLE user in each role it creates. Setting it to false withdraws CREATEROLE from a role that held it.
|
|
## @field {bool} [bypassRls] - Whether the user can bypass row-level security policies (BYPASSRLS). A role can only create other roles carrying BYPASSRLS if it holds the attribute itself.
|
|
|
|
## @param {map[string]User} users - Users configuration map. Each user is a PostgreSQL role the operator manages from an account Secret the platform keeps. Passwords are issued through the Cozystack credentials API: a mint on the account's `Credential` (`core.cozystack.io`) returns a new password once and stores only its SCRAM verifier, and a revoke retires the password without issuing one. A `password` key here is ignored and draws an admission warning. A password set inside PostgreSQL is reverted by the operator.
|
|
users: {}
|
|
## Example:
|
|
## users:
|
|
## user1: {}
|
|
## user2: {}
|
|
## airflow: {}
|
|
## debezium:
|
|
## replication: true
|
|
## migrator:
|
|
## bypassRls: true
|
|
|
|
##
|
|
## @section Databases configuration
|
|
##
|
|
|
|
## @typedef {struct} DatabaseRoles - Role assignments for a database.
|
|
## @field {[]string} [admin] - List of users with admin privileges.
|
|
## @field {[]string} [readonly] - List of users with read-only privileges.
|
|
|
|
## @typedef {struct} Database - Database configuration.
|
|
## @field {DatabaseRoles} [roles] - Roles assigned to users.
|
|
## @field {[]string} [extensions] - List of enabled PostgreSQL extensions.
|
|
|
|
## @param {map[string]Database} databases - Databases configuration map. The PostgreSQL system databases `postgres`, `template0` and `template1` are refused.
|
|
databases: {}
|
|
## Example:
|
|
## databases:
|
|
## myapp:
|
|
## roles:
|
|
## admin:
|
|
## - user1
|
|
## - debezium
|
|
## readonly:
|
|
## - user2
|
|
## airflow:
|
|
## roles:
|
|
## admin:
|
|
## - airflow
|
|
## extensions:
|
|
## - hstore
|
|
|
|
##
|
|
## @section Backup parameters
|
|
##
|
|
|
|
## @typedef {struct} S3CredentialsSecret - Reference to a pre-existing Secret with S3 credentials. Setting `name` makes the chart bind the barman-cloud ObjectStore's `spec.configuration.s3Credentials` directly to that Secret instead of materialising `<release>-s3-creds` from `s3AccessKey`/`s3SecretKey`. Use this to keep credentials out of the Postgres CR's `.spec`.
|
|
## @field {string} [name] - Name of the Secret in the application namespace. Empty means the chart materialises `<release>-s3-creds` from `s3AccessKey`/`s3SecretKey`.
|
|
## @field {string} [accessKeyIDKey] - Key in the Secret holding the access key ID. Defaults to `AWS_ACCESS_KEY_ID`.
|
|
## @field {string} [secretAccessKeyKey] - Key in the Secret holding the secret access key. Defaults to `AWS_SECRET_ACCESS_KEY`.
|
|
|
|
## @typedef {struct} EndpointCA - Reference to a Secret holding a PEM-encoded CA bundle the barman-cloud plugin should trust when reaching a self-signed S3 endpoint. Required when the cluster's S3 (e.g. cozystack's seaweedfs-s3) presents a certificate not signed by a publicly-trusted CA. Used by both the backup ObjectStore's spec.configuration.endpointCA and the recovery ObjectStore's spec.configuration.endpointCA (referenced from externalClusters[].plugin) so backup *and* recovery can verify TLS.
|
|
## @field {string} [name] - Name of the Secret in the application namespace. Empty means no endpointCA is emitted (the plugin uses the system trust store).
|
|
## @field {string} [key] - Key within the Secret containing the CA bundle. Defaults to `ca.crt`.
|
|
|
|
## @typedef {struct} Backup - Backup configuration.
|
|
## @field {bool} enabled - Enable regular backups.
|
|
## @field {bool} [useSystemBucket] - Opt-in: when true, the chart-emitted `<release>-s3-creds` Secret is skipped AND `spec.plugins` (plus the barman-cloud ObjectStore) is left UNSET in the chart-rendered Cluster — the cozy-default BackupClass driver SSA-applies an ObjectStore (carrying destinationPath/endpointURL/credentials) and patches `spec.plugins` on the live Cluster when the first BackupJob runs. Consequence: plugin WAL archiving is NOT active until that first BackupJob fires; WAL accumulates on the PVC in the meantime, so fire an ad-hoc BackupJob immediately after enabling the flag on existing releases. Use together with the platform `cozy-default` BackupClass — tenants do not need to fill `s3AccessKey`/`s3SecretKey` or `destinationPath`/`endpointURL`. The destination path automatically scopes to `s3://cozy-backups/<namespace>/<release>/`.
|
|
## @field {string} [schedule] - Legacy. Cron schedule for the chart-emitted ScheduledBackup, either a standard five-field cron such as `0 2 * * *` for every day at 02:00, or six fields with leading seconds such as `0 0 2 * * *` for the same time. Empty means no chart-managed schedule, which is the recommended setup when a `BackupClass` from `backups.cozystack.io` already drives backup orchestration. In the legacy chart-managed flow `spec.plugins` plus the barman-cloud ObjectStore is rendered when `backup.enabled=true` AND `useSystemBucket=false` AND `destinationPath` is non-empty AND inline-or-external creds are supplied; in the platform `useSystemBucket=true` flow the chart skips emitting `spec.plugins` and the CNPG driver SSA-applies the ObjectStore and patches `spec.plugins` onto the live Cluster at first BackupJob time.
|
|
## @field {string} [retentionPolicy] - Retention policy (e.g. "30d").
|
|
## @field {string} [destinationPath] - DEPRECATED. Per-tenant S3 configuration is superseded by the platform-managed `cozy-default` BackupClass and the `cozy-backups` system bucket. Leave empty for new installations; the BackupClass driver picks up the system-managed coordinates. Kept for in-place upgrade compatibility.
|
|
## @field {string} [endpointURL] - DEPRECATED. See `destinationPath`.
|
|
## @field {string} [s3AccessKey] - DEPRECATED. Tenants no longer supply S3 keys; the system Bucket Secret is projected into the tenant namespace by the backup controller. Ignored when `s3CredentialsSecret.name` is set or `useSystemBucket` is true. The chart skips materialising `<release>-s3-creds` whenever this field is empty so a default install does not leak placeholder credentials into the tenant namespace.
|
|
## @field {string} [s3SecretKey] - DEPRECATED. See `s3AccessKey`.
|
|
## @field {S3CredentialsSecret} [s3CredentialsSecret] - DEPRECATED. Pre-existing Secret with S3 credentials. Use the platform-managed `cozy-default` BackupClass instead. When set, the chart references this Secret directly (legacy chart-managed flow). The CNPG backup driver writes this field on restore so credentials never land in the CR `.spec`.
|
|
## @field {EndpointCA} [endpointCA] - DEPRECATED. Pre-existing Secret with the CA bundle the barman-cloud plugin should trust when reaching a self-signed S3 endpoint. Used for both backup and bootstrap recovery in the legacy chart-managed flow.
|
|
|
|
## @param {Backup} backup - Backup configuration.
|
|
##
|
|
## Note on defaults: destinationPath/endpointURL keep their pre-PR
|
|
## placeholder values so existing tenants on the legacy chart-managed
|
|
## flow continue to render spec.plugins + a barman-cloud ObjectStore on
|
|
## upgrade (the placeholder coordinates never produced working plugin
|
|
## WAL archiving, but the CR shape stays compatible with what Flux
|
|
## already applied).
|
|
##
|
|
## BEHAVIOUR CHANGE on upgrade for tenants with backup.enabled=true and
|
|
## empty s3AccessKey / s3SecretKey: the pre-PR defaults were the literal
|
|
## "<your-access-key>" / "<your-secret-key>" placeholders, so the chart
|
|
## still wired the plugin (with junk creds, plugin WAL archiving failing
|
|
## at runtime). After this PR the defaults are empty strings,
|
|
## $hasInlineCreds is false, and the chart NO LONGER renders the backup
|
|
## block at all. Such tenants stop seeing chart-emitted spec.plugins and
|
|
## the ObjectStore on the cnpg.io Cluster. Action: either set real
|
|
## s3AccessKey/s3SecretKey (legacy flow), set useSystemBucket=true
|
|
## (platform flow), or supply s3CredentialsSecret.name (external Secret).
|
|
##
|
|
## New tenants should set useSystemBucket=true and leave the placeholders
|
|
## alone — the chart skips rendering spec.plugins and the ObjectStore
|
|
## entirely in that mode and the CNPG driver SSA-applies the ObjectStore
|
|
## and patches spec.plugins onto the live Cluster at first BackupJob time.
|
|
backup:
|
|
enabled: false
|
|
useSystemBucket: false
|
|
retentionPolicy: 30d
|
|
destinationPath: "s3://bucket/path/to/folder/"
|
|
endpointURL: "http://minio-gateway-service:9000"
|
|
schedule: ""
|
|
s3AccessKey: ""
|
|
s3SecretKey: ""
|
|
s3CredentialsSecret:
|
|
name: ""
|
|
accessKeyIDKey: ""
|
|
secretAccessKeyKey: ""
|
|
endpointCA:
|
|
name: ""
|
|
key: ""
|
|
|
|
##
|
|
## @section Bootstrap (recovery) parameters
|
|
##
|
|
|
|
## @typedef {struct} Bootstrap - Bootstrap configuration for restoring a database cluster from a backup.
|
|
## @field {bool} enabled - Whether to restore from a backup.
|
|
## @field {string} [recoveryTime] - Timestamp (RFC3339) for point-in-time recovery; empty means latest.
|
|
## @field {string} [backupID] - Barman ID of the base backup to recover from, passed as `recoveryTarget.backupID`. Empty lets the barman-cloud plugin pick one: the newest backup when `recoveryTime` is empty, otherwise the newest one ending at or before it, on any timeline. The CNPG backup driver sets this on restore.
|
|
## @field {string} oldName - Previous cluster name before deletion.
|
|
## @field {string} [serverName] - Server name (S3 path prefix) used by the original cluster when writing backups; passed to the barman-cloud plugin via `externalClusters[].plugin.parameters.serverName`. Defaults to `bootstrap.oldName`. Set this only when the original cluster wrote backups under an explicit server name that differed from its Kubernetes resource name.
|
|
## @field {string} [newServerName] - WAL-archive server name (S3 path prefix) the RESTORED cluster writes to. Must differ from `serverName` (the recovery source) so a restored cluster archives to a fresh, empty prefix and barman-cloud-check-wal-archive passes while it recovers from the source's prefix. The CNPG backup driver sets this on restore; empty means the cluster archives under its own name.
|
|
## @field {string} [sourceImageName] - Image of the cluster the backup was taken from. A restore of a backup taken on one of the bare Debian bullseye tags the chart used before standard-trixie comes back on that image (see `allowCollationChange`); any other value is ignored. The CNPG backup driver sets this on restore and clears it with `enabled`.
|
|
|
|
## @param {Bootstrap} bootstrap - Bootstrap configuration.
|
|
bootstrap:
|
|
enabled: false
|
|
# example: 2020-11-26 15:22:00.00000+00
|
|
recoveryTime: ""
|
|
backupID: ""
|
|
oldName: ""
|
|
serverName: ""
|
|
newServerName: ""
|
|
sourceImageName: ""
|