The bundled `postgresql-ha` sub-chart was the only HA-ready database option, but it pinned us to a Bitnami chart whose images are no longer freely distributed, and it bundled repmgr and pgpool into the release. Operating a Postgres cluster through a Helm release also means the chart has to reimplement failover, backup and upgrade orchestration that a dedicated operator already solves. CloudNativePG is the de-facto standard operator for Postgres on Kubernetes and handles instance management, streaming replication, switchover and rolling upgrades itself. The operator is deliberately *not* part of this chart: cluster-scoped CRDs and controllers do not belong into an application release and would conflict with an operator that is already installed. The chart only renders the namespaced `Cluster` resource, so the operator can be managed independently. Because the operator cannot be assumed to be present, `cloudnativePG.enabled` defaults to `false`. Existing users of `postgresql` or an external database are therefore unaffected. Credentials follow the chart-wide `secrets.*` convention. Only the password is read from a Secret, because CloudNativePG requires `bootstrap.initdb.database` and `bootstrap.initdb.owner` as literals in the `Cluster` spec and cannot resolve them from a Secret. The password is injected into the `init-app-ini` container as `GITEA__database__PASSWD` instead of being written into the generated `app.ini`. BREAKING CHANGE: The `postgresql-ha` sub-chart and all `postgresql-ha.*` values have been removed. There is no in-place migration path between the two deployments: dump the database of the old `postgresql-ha` release with `pg_dump`, remove the `postgresql-ha` values, deploy the chart with `cloudnativePG.enabled=true` and restore the dump. Setting `postgresql-ha` now fails the release with a pointer to the changelog. Co-authored-by: Copilot <copilot@github.com>
103 lines
3.1 KiB
YAML
103 lines
3.1 KiB
YAML
suite: Test dependency customization integrity of postgresql
|
|
release:
|
|
name: gitea-unittests
|
|
namespace: testing
|
|
set:
|
|
cloudnativePG:
|
|
enabled: false
|
|
postgresql:
|
|
enabled: true
|
|
global:
|
|
postgresql:
|
|
auth:
|
|
password: gitea-password
|
|
database: gitea-database
|
|
username: gitea-username
|
|
service:
|
|
ports:
|
|
postgresql: 1234
|
|
primary:
|
|
persistence:
|
|
size: 1337Mi
|
|
tests:
|
|
- it: "[postgresql] Apply the database settings"
|
|
template: charts/postgresql/templates/primary/statefulset.yaml
|
|
asserts:
|
|
- documentIndex: 0
|
|
contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: POSTGRES_DATABASE
|
|
value: "gitea-database"
|
|
- documentIndex: 0
|
|
contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: POSTGRES_USER
|
|
value: "gitea-username"
|
|
- it: "[postgresql] Apply the database password"
|
|
template: charts/postgresql/templates/secrets.yaml
|
|
asserts:
|
|
- documentIndex: 0
|
|
equal:
|
|
path: data["password"]
|
|
value: "Z2l0ZWEtcGFzc3dvcmQ="
|
|
- it: "[postgresql] Apply primary.persistence.size"
|
|
template: charts/postgresql/templates/primary/statefulset.yaml
|
|
asserts:
|
|
- documentIndex: 0
|
|
equal:
|
|
path: spec.volumeClaimTemplates[0].spec.resources.requests.storage
|
|
value: "1337Mi"
|
|
- it: "[postgresql] Apply global.postgresql.service.ports.postgresql"
|
|
template: charts/postgresql/templates/primary/svc.yaml
|
|
asserts:
|
|
- documentIndex: 0
|
|
equal:
|
|
path: spec.ports[0].port
|
|
value: 1234
|
|
- it: "[postgresql] Render the referenced Service"
|
|
template: charts/postgresql/templates/primary/svc.yaml
|
|
asserts:
|
|
- containsDocument:
|
|
kind: Service
|
|
apiVersion: v1
|
|
name: gitea-unittests-postgresql
|
|
namespace: testing
|
|
- it: "[gitea] Connect to the postgresql Service"
|
|
template: templates/secret_inlineConfig.yaml
|
|
asserts:
|
|
- documentIndex: 0
|
|
matchRegex:
|
|
path: data.database
|
|
decodeBase64: true
|
|
pattern: HOST=gitea-unittests-postgresql.testing.svc.cluster.local:1234
|
|
- it: "[gitea] Connect to the postgresql Service with a custom cluster domain"
|
|
set:
|
|
clusterDomain: my-special-cluster.local
|
|
template: templates/secret_inlineConfig.yaml
|
|
asserts:
|
|
- documentIndex: 0
|
|
matchRegex:
|
|
path: data.database
|
|
decodeBase64: true
|
|
pattern: HOST=gitea-unittests-postgresql.testing.svc.my-special-cluster.local:1234
|
|
- it: "[gitea] Connect to the configured database"
|
|
template: templates/secret_inlineConfig.yaml
|
|
asserts:
|
|
- documentIndex: 0
|
|
matchRegex:
|
|
path: data.database
|
|
decodeBase64: true
|
|
pattern: NAME=gitea-database
|
|
- documentIndex: 0
|
|
matchRegex:
|
|
path: data.database
|
|
decodeBase64: true
|
|
pattern: USER=gitea-username
|
|
- documentIndex: 0
|
|
matchRegex:
|
|
path: data.database
|
|
decodeBase64: true
|
|
pattern: PASSWD=gitea-password
|