Repository navigation
Description
Problem or Motivation
The CloudNativePG clusters k8s/llm/gateway-db.yaml (LiteLLM) and k8s/mattermost/database.yaml (Mattermost) set imageName PostgreSQL 17 (17.2 live; the baseline #5065 takes 17.11). PostgreSQL 18 exists. Renovate (#4893) will offer it.
- A PostgreSQL major needs
pg_upgradeor a logical import into a new cluster (dump and restore). The image field alone is not safe. - Owner rule: a database major is never a pin-only update here. Renovate must hold PostgreSQL at 17 until this item plans the move.
Research of 2026-11-12 (research-k8s, record image-field:CloudNativePG imageName (PostgreSQL 18)).
Proposed Solution & Architectural Design
- Write the upgrade plan: the CloudNativePG method (offline in-place major upgrade of the operator, or a new cluster with
bootstrap.initdb.import), the backup before it (#4765 for Mattermost), the downtime, the check and the rollback. - Add a Renovate rule that holds the PostgreSQL major for a Dependency Dashboard approval, if feat(deps): track regular version updates with Renovate #4893 does not hold it already.
Done when the plan is in this issue and Renovate holds the major.
Target Subsystem
Kubernetes & Minikube Automation
Existing Tool Considered
CloudNativePG major upgrade support and pg_upgrade. No new code.
Source: #4893
Alternatives check of 2026-11-22: in-use.
The repository already uses this tool.
Tool: cloudnative-pg/cloudnative-pg (https://github.com/cloudnative-pg/cloudnative-pg), Apache-2.0, last activity 2026-11-21, maintained.
Reason: Searches found CloudNativePG, already the operator of both clusters, covering offline in-place pg_upgrade and logical import; it does not supply the written runbook or the Renovate major hold, so the item keeps real work.
Covers:
- Offline in-place major upgrade through pg_upgrade --link on imageName change
- Logical dump and restore path for a new cluster as fallback
- Automatic cleanup of a failed upgrade job when the image is reverted
- Operator-managed backup and restore through Barman Cloud
Lacks:
- No written runbook with downtime, checks and rollback per cluster
- No Renovate rule holding the PostgreSQL major by itself
- Pre-upgrade backup is only recommended, not enforced
- No rollback guarantee once data is upgraded and backups cannot serve PITR
Proposed design
Problem statement
Write the PostgreSQL 18 upgrade plan for the two CloudNativePG clusters and hold Renovate at PostgreSQL 17 until a person approves the major. The clusters llm-gateway-db and mattermost-db run PostgreSQL 17.11. A major version needs a planned upgrade with a backup, downtime, checks and rollback.
Acceptance criteria
Requirement: Upgrade plan records the CloudNativePG method
The change SHALL add a plan that names the CloudNativePG pg_upgrade method for both clusters and bootstrap.initdb.import as the fallback.
Scenario: Plan names the chosen method
- WHEN
uv run pytest tests/k8s/test_postgresql_upgrade_plan.pyruns - THEN the test passes and asserts that the plan names
pg_upgradefor both clusters andbootstrap.initdb.importas the fallback.
Requirement: Plan records backup, downtime, checks and rollback
The plan SHALL state the pre-upgrade backup, the downtime, the post-upgrade checks and the rollback for each cluster.
Scenario: Each cluster has the four runbook parts
- WHEN
uv run pytest tests/k8s/test_postgresql_upgrade_plan.pyruns - THEN the test passes and finds a backup, downtime, check and rollback part for
llm-gateway-dbandmattermost-db.
Requirement: Plan names the Mattermost backup prerequisite
The plan SHALL name dan-petty/homelab#342 as the backup prerequisite for mattermost-db.
Scenario: Mattermost backup part names dan-petty/homelab#342
- WHEN
uv run pytest tests/k8s/test_postgresql_upgrade_plan.pyruns - THEN the test passes and finds
#4765in themattermost-dbbackup part.
Requirement: Renovate holds the PostgreSQL major
The final Renovate configuration MUST hold a major update of ghcr.io/cloudnative-pg/postgresql for a Dependency Dashboard approval.
Scenario: Renovate holds the PostgreSQL major
- WHEN
uv run devops ci --check --only renovateruns, andgh api repos/dan-petty/devops-cli/contents/.github/renovate.json --jq .content | base64 -d | jqruns - THEN the validator exits 0 and the JSON shows
dependencyDashboardApproval: truewithmatchUpdateTypes: ["major"]forghcr.io/cloudnative-pg/postgresql.
Existing Tool Considered
cloudnative-pg/cloudnative-pg (Apache-2.0, maintained) is already in use. It covers the operator lifecycle and both major-upgrade paths: offline in-place pg_upgrade and a new cluster with bootstrap.initdb.import. It lacks a runbook for downtime, checks and rollback, and it does not hold the Renovate major by itself. The remaining work is the plan and one Renovate rule.
Key questions
- Which CloudNativePG major-upgrade method should the plan use for the two clusters?: Use the CloudNativePG offline in-place
pg_upgrademethod for both clusters. Each cluster has one instance and small storage. The operator stops the instance, runspg_upgradeand starts the new major. Usebootstrap.initdb.importonly as the fallback whenpg_upgradefails before cutover. (best practice) [sources: k8s/llm/gateway-db.yaml, k8s/mattermost/database.yaml]- Chosen: Offline in-place
pg_upgrade. Both clusters are single-instance and small, and the existing PVC and Service stay in place. - Rejected: New cluster with
bootstrap.initdb.import. It needs a second cluster, a second PVC and an application cutover for a 5Gi and 10Gi database. - Rejected: Hand-run logical dump and restore. The operator already provides the import path, so a hand-run path adds work.
- Chosen: Offline in-place
- What backup must precede the upgrade?: Take a CloudNativePG Barman Cloud backup of each cluster and verify a restore before the maintenance window. For
mattermost-db, use the backup from dan-petty/homelab#342. (best practice) [sources: k8s/mattermost/database.yaml]- Chosen: CloudNativePG Barman Cloud backup. The operator and its Barman Cloud plugin cover the backup and restore path.
- Rejected:
pg_dumpfrom the application pod. It adds a hand-run path and does not prove the operator can restore the cluster. - Rejected: No backup; rely on
pg_upgrade --link. A failed major upgrade has no rollback without a backup.
- What downtime does each cluster need?: Plan one maintenance window for each cluster. The operator stops the single instance for the whole
pg_upgrade. The gateway or Mattermost is unavailable from the stop until the new instance is Ready. Run the two clusters in separate windows. (best practice) [sources: k8s/llm/gateway-db.yaml, k8s/mattermost/database.yaml]- Chosen: One window for each cluster. Each cluster has one instance, so the upgrade is offline and the applications must not share the window.
- Rejected: Both clusters in one window. A failure in one cluster would hold both applications down.
- Rejected: No downtime with logical replication. It adds a second cluster and a cutover that this plan does not need.
- What checks prove the upgrade succeeded?: Check that the Cluster is Ready and the
pg_upgradejob completed. Check thatSELECT version()reports 18 and the application health endpoint passes. Check that the CloudNativePG metrics and alerts are green. Run the checks after each cluster and before the next window. (best practice) [sources: k8s/llm/gateway-db.yaml, k8s/mattermost/database.yaml]- Chosen: Operator status, SQL version and application health. The operator status shows the cluster, SQL shows the major, and the application health shows the data path.
- Rejected: Only the Pod is Running. A running pod does not prove that the new major serves the application.
- Rejected: Only the application health. The application can pass while the operator upgrade job has failed.
- What rollback does the plan use?: Restore the pre-upgrade Barman Cloud backup into a new cluster and point the application at it. Do not downgrade the upgraded cluster in place. PostgreSQL does not support a major downgrade in place. (best practice) [sources: k8s/llm/gateway-db.yaml]
- Chosen: Restore the backup into a new cluster. It gives a tested path back to PostgreSQL 17 without an unsupported downgrade.
- Rejected: Downgrade the existing cluster. PostgreSQL does not support an in-place major downgrade.
- Rejected: Re-run
pg_upgrade. It does not recover data after a failed upgrade.
- Does
.github/renovate.jsonalready hold the PostgreSQL major?: The file has a custom manager for the CloudNativePGimageNamefield at line 97. The visible lines do not show a major-hold package rule. The final file must hold major updates ofghcr.io/cloudnative-pg/postgresqlfor Dependency Dashboard approval. Add the rule only when it is absent. (best practice) [sources: .github/renovate.json:97]- Chosen: Add a major-hold package rule when absent. The issue asks for the hold, and the visible config does not show it.
- Rejected: Rely on feat(deps): track regular version updates with Renovate #4893. The issue makes the hold conditional, so the final config must prove it.
- Should the item change the PostgreSQL image in the Cluster manifests?: No. The item writes the plan and holds Renovate at 17. The image change runs in a later item after a person approves the plan. (best practice) [sources: k8s/llm/gateway-db.yaml, k8s/mattermost/database.yaml]
- Chosen: Keep
imageNameat 17.11. The issue is a plan, and a major move needs the planned backup and window. - Rejected: Bump
imageNameto 18 now. A pin-only major bump is not safe and the owner rule forbids it.
- Chosen: Keep
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Both concern the Mattermost CloudNativePG database; dan-petty/homelab#342 adds a backup while this item plans the version upgrade that depends on that backup.build(deps): take every safe version update before Renovate (#5102)
devops-cli-service commentedon Nov 15, 2026
Alternatives check: in-use
Reason: The searches point to CloudNativePG as the operator the two cluster manifests already run, and the operator itself provides the two major-version paths the issue weighs (offline in-place pg_upgrade, or a new cluster that imports through bootstrap.initdb.import), with operand images published for each supported PostgreSQL version. So the tool the issue needs already exists and is in use; only the plan text and the Renovate hold rule are the project's own work.
The repository already uses this tool.
Tool: cloudnative-pg/cloudnative-pg (https://github.com/cloudnative-pg/cloudnative-pg)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Status set to Ready at b8c7632 (see proposed design in issue body).
dan-petty commentedon Nov 26, 2026
Closed: the PostgreSQL 18 move already happened, and the next major is held.
dan-petty/homelab set both CloudNativePG clusters to
18.6on 2026-11-23 (dan-petty/homelab#158), and both were healthy on 18.6 on 2026-11-26. The presetrenovate/base.jsonof dan-petty/infra holds a PostgreSQL major for Dashboard approval. No database backup is in git: dan-petty/homelab#332 and dan-petty/homelab#342 (moved to dan-petty/homelab) hold that work.