Compare commits

...
4 Commits
Author SHA1 Message Date
volker.raschekandCopilot 6d68d44894 feat(cloudnativePG): support topologySpreadConstraints
Bash / shellcheck (push) Successful in 7s
Bash / bash-unittest (push) Successful in 25s
changelog / changelog (push) Successful in 15s
Helm / helm-lint (push) Successful in 13s
Helm / helm-unittest (push) Successful in 20s
Markdown linter / markdown-lint (push) Successful in 18s
Markdown linter / markdown-link-checker (push) Successful in 52s
A HA `Cluster` is only actually highly available if its instances end up in different failure domains. Pod
anti-affinity alone cannot express that: it only keeps the instances off the same node, not off the same zone,
and `cloudnativePG.affinity` has no way to encode a skew budget. Without `topologySpreadConstraints` a three
instance cluster can legitimately be scheduled into a single availability zone, where a zone outage takes down
the primary and both replicas at once.

Both `affinity` and `topologySpreadConstraints` are rendered only when they are set. The CloudNativePG API
declares them as `omitempty`, so an empty `{}` or `[]` in the manifest would show up as a permanent diff against
the state the operator writes back.

Tolerations deliberately do not get a dedicated value. CloudNativePG has no `spec.tolerations`, it nests them
below `spec.affinity.tolerations`, so they are configured through `cloudnativePG.affinity` like `nodeSelector`
and the anti-affinity settings. A separate top-level value would only have to be folded back into the same place
and would silently conflict with a tolerations list set via `cloudnativePG.affinity`.

Co-authored-by: Copilot <copilot@github.com>
2026-10-04 00:39:08 +02:00
volker.raschekandCopilot 27db0d26b0 feat!: remove the postgresql sub-chart
With `cloudnativePG` in place, the bundled Bitnami `postgresql` sub-chart is the second in-chart way to run a
database, and the worse one. It is a single, non-HA instance without failover, backup or managed major-version
upgrades, and it ships images that Bitnami no longer distributes freely. Keeping it around means maintaining two
code paths for the same job, including the mutual-exclusion assertion between both dependencies and a second set
of DNS, credential and image helpers.

Removing it leaves exactly two supported choices: a CloudNativePG `Cluster` rendered by this chart, or an
external database configured via `gitea.config.database`. Both scale from a single instance to a HA setup -
`cloudnativePG.instances=1` covers the use case the `postgresql` sub-chart served - so nothing is lost besides
the duplication.

BREAKING CHANGE: The `postgresql` sub-chart and all `postgresql.*` values have been removed. There is no
in-place migration path: dump the database of the old `postgresql` release with `pg_dump`, remove the
`postgresql` values, deploy the chart with `cloudnativePG.enabled=true` and restore the dump. Alternatively
point `gitea.config.database` at an externally managed database. Setting `postgresql` now fails the release with
a pointer to the changelog.

Co-authored-by: Copilot <copilot@github.com>
2026-10-04 00:39:05 +02:00
volker.raschekandCopilot 1b82a15b7f feat!: replace postgresql-ha with CloudNativePG
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>
2026-10-04 00:18:34 +02:00
volker.raschekandCopilot eeacda2a25 test: align the file names of the helm unit tests with the chart conventions
The chart conventions demand camelCase file names, forbid short names like `svc` and require the unit tests to
mirror the template structure. The unit tests followed none of that consistently. Four casings existed side by
side - camelCase (extraInitContainers.yaml), kebab-case (checksum-annotations.yaml), a snake and kebab mix
(init_directory_structure.sh-rootless.yaml) and all caps (HA.yaml) - so there was no pattern to copy when
adding a suite, which is how the inconsistency kept growing.

Three groups of problems are fixed:

- svc-configuration.yaml used exactly the short name the conventions forbid for files and keys.
- Several file names repeated their own directory, for example deployment/deployment-additional-config.yaml and
  metric-secret/metrics-secret-servicemonitor-disabled.yaml, which names the subject three times. The directory
  already carries that information, so the file name now only carries the scenario. The default scenario of a
  template is named basics.yaml.
- Four suites lived in a directory of a template they do not assert on. They were filed under deployment/
  because the deployment is rendered as a side effect, not because it is the subject:

      deployment/deprecations.yaml                -> deprecation/deployment.yaml
      deployment/inline-config.yaml               -> config/inlineConfig.yaml
      deployment/storage-class-configuration.yaml -> persistentVolumeClaim/storageClass.yaml
      deployment/svc-configuration.yaml           -> service/configuration.yaml

  storage-class-configuration.yaml is the clearest case: a persistentVolumeClaim directory already existed next
  to it. The suite titles of the two suites whose subject changed are adjusted accordingly.

The Makefile passed `--file unittests/helm/values-conflicting-checks.yaml`, but that file does not exist in the
tree. `helm unittest` ignores a missing path without a warning, so the flag has been dead for an unknown amount
of time while still suggesting the checks run. It is removed; the `unittests/helm/**/*.yaml` glob would pick
the file up anyway if it ever returns.

The naming rule is written down in the copilot instructions, together with the constraint that the glob matches
only a single directory level, so a suite can never be placed directly in unittests/helm/.

All 49 suites and 267 tests still pass.

Co-authored-by: Copilot <copilot@github.com>
2026-10-03 22:19:39 +02:00
60 changed files with 682 additions and 529 deletions

No files matched your search

+3 -2
View File
@@ -2,7 +2,7 @@
## Project Overview
Kubernetes Helm chart for deploying [Gitea](https://gitea.com). Uses Go/Helm templating (`templates/`), YAML values (`values.yaml`), and includes sub-charts for PostgreSQL, PostgreSQL-HA, Valkey, and Valkey-cluster.
Kubernetes Helm chart for deploying [Gitea](https://gitea.com). Uses Go/Helm templating (`templates/`), YAML values (`values.yaml`), and includes a sub-chart for Valkey. The database is provisioned as a CloudNativePG `Cluster` resource, the operator itself is not part of the chart.
## Build & Test
@@ -52,8 +52,9 @@ data:
### Unit Tests
- Helm unit tests live in `unittests/helm/` mirroring the template structure.
- Helm unit tests live in `unittests/helm/` mirroring the template structure. A suite belongs into the directory of the template it asserts on, never into the directory of a template it only renders as a side effect.
- Test files are YAML using the [helm-unittest](https://github.com/helm-unittest/helm-unittest) format.
- Name test files in camelCase after the scenario they cover (e.g. `signingEnabled.yaml`), use `basics.yaml` for the default scenario and do not repeat the directory name in the file name. The `make helm/unittest` glob only matches one directory level, so every suite must live in a subdirectory.
- Each test must set all required values explicitly — do not rely on cross-test state.
- The `values.yaml` file must pass `yamllint`. The configuration is in `.yamllint.yaml`. Use `make yamllint` to run the linter.
- The title of the unit test should clearly describe the scenario being tested. As title must be use a short sentence starting with a capital letter and ending without a period.
+2 -8
View File
@@ -1,12 +1,6 @@
dependencies:
- name: postgresql
repository: oci://registry-1.docker.io/bitnamicharts
version: 16.7.27
- name: postgresql-ha
repository: oci://registry-1.docker.io/bitnamicharts
version: 16.3.2
- name: valkey
repository: https://valkey.io/valkey-helm
version: 0.10.0
digest: sha256:1afecbf0d4fc9f48e31417573d4bed7e0ac7848040b9e0c5f3989ada9d1f944f
generated: "2026-07-20T19:52:11.548874634+02:00"
digest: sha256:c3deb43d02228f143e1c9525f5ce06dc6a78646e763c7a73c5ec8ea0101ed2f5
generated: "2026-10-04T00:24:11.331968211+02:00"
-10
View File
@@ -36,16 +36,6 @@ maintainers:
email: christopher.homberger@web.de
dependencies:
# https://github.com/bitnami/charts/blob/main/bitnami/postgresql
- name: postgresql
repository: oci://registry-1.docker.io/bitnamicharts
version: 16.7.27
condition: postgresql.enabled
# https://github.com/bitnami/charts/blob/main/bitnami/postgresql-ha/Chart.yaml
- name: postgresql-ha
repository: oci://registry-1.docker.io/bitnamicharts
version: 16.3.2
condition: postgresql-ha.enabled
# https://github.com/bitnami/charts/blob/main/bitnami/valkey/Chart.yaml
- name: valkey
repository: https://valkey.io/valkey-helm
+1 -1
View File
@@ -39,7 +39,7 @@ helm/dependency-update:
# ==============================================================================
PHONY+=helm/unittest
helm/unittest:
helm unittest --strict --file 'unittests/helm/**/*.yaml' --file 'unittests/helm/values-conflicting-checks.yaml' ./
helm unittest --strict --file 'unittests/helm/**/*.yaml' ./
# BASH PREPARE
# ==============================================================================
+73 -89
View File
@@ -4,7 +4,6 @@
- [Update and versioning policy](#update-and-versioning-policy)
- [Dependencies](#dependencies)
- [HA Dependencies](#ha-dependencies)
- [Non-HA Dependencies](#non-ha-dependencies)
- [Dependency Versioning](#dependency-versioning)
- [Installing](#installing)
- [High Availability](#high-availability)
@@ -58,8 +57,7 @@
- [ReadinessProbe](#readinessprobe)
- [StartupProbe](#startupprobe)
- [valkey](#valkey)
- [PostgreSQL HA](#postgresql-ha)
- [PostgreSQL](#postgresql)
- [CloudNativePG](#cloudnativepg)
- [Advanced](#advanced)
- [Contributing](#contributing)
- [Upgrading](#upgrading)
@@ -97,24 +95,21 @@ Users can also configure their own external providers via the configuration.
### HA Dependencies
These dependencies are enabled by default:
- PostgreSQL ([CloudNativePG](https://cloudnative-pg.io/)), disabled by default
- Valkey ([Official Valkey Helm Chart](https://github.com/valkey-io/valkey-helm)), enabled by default
- PostgreSQL HA ([Bitnami PostgreSQL-HA](https://github.com/bitnami/charts/blob/main/bitnami/postgresql-ha/Chart.yaml))
- Valkey ([Official Valkey Helm Chart](https://github.com/valkey-io/valkey-helm))
### Non-HA Dependencies
Alternatively, the following non-HA replacements are available:
- PostgreSQL ([Bitnami PostgreSQL](https://github.com/bitnami/charts/blob/main/bitnami/postgresql/Chart.yaml))
CloudNativePG is **not** bundled as a sub-chart.
Only the `Cluster` resource is rendered by this chart, the [CloudNativePG operator](https://cloudnative-pg.io/documentation/current/installation_upgrade/) must already be installed cluster-wide.
Because that operator cannot be assumed to be present, `cloudnativePG.enabled` defaults to `false`.
Set it to `true` once the operator is installed, or use an external database instead.
### Dependency Versioning
Updates of sub-charts will be incorporated into the Gitea chart as they are released.
The reasoning behind this is that new users of the chart will start with the most recent sub-chart dependency versions.
**Note** If you want to stay on an older appVersion of a sub-chart dependency (e.g. PostgreSQL), you need to override the image tag in your `values.yaml` file.
In fact, we recommend to do so right from the start to be independent of major sub-chart dependency changes as they are released.
**Note** If you want to stay on an older appVersion of a dependency (e.g. PostgreSQL), you need to override the image tag in your `values.yaml` file.
In fact, we recommend to do so right from the start to be independent of major dependency changes as they are released.
There is no need to update to every new PostgreSQL major version - you can happily skip some and do larger updates when you are ready for them.
We recommend to use a rolling tag like `:<majorVersion>-debian-<debian major version>` to incorporate minor and patch updates for the respective major version as they are released.
@@ -122,8 +117,7 @@ Alternatively you can also use a versioning helper tool like [renovate](https://
Please double-check the image repository and available tags in the sub-chart:
- [PostgreSQL-HA](https://hub.docker.com/r/bitnami/postgresql-repmgr/tags)
- [PostgreSQL](https://hub.docker.com/r/bitnami/postgresql/tags)
- [CloudNativePG](https://github.com/cloudnative-pg/postgres-containers/pkgs/container/postgresql)
- [Valkey](https://hub.docker.com/r/valkey/valkey/tags)
and look up the image tag which fits your needs on Dockerhub.
@@ -223,17 +217,20 @@ _All default settings are made directly in the generated `app.ini`, not in the V
#### Database defaults
If a builtIn database is enabled the database configuration is set automatically.
For example, PostgreSQL builtIn will appear in the `app.ini` as:
For example, the CloudNativePG `Cluster` will appear in the `app.ini` as:
```ini
[database]
DB_TYPE = postgres
HOST = RELEASE-NAME-postgresql.default.svc.cluster.local:5432
HOST = RELEASE-NAME-postgresql-rw.default.svc.cluster.local:5432
NAME = gitea
PASSWD = gitea
USER = gitea
```
`PASSWD` is not part of the generated `app.ini`.
It is injected into the `init-app-ini` init container as the `GITEA__database__PASSWD` environment variable, sourced
from the credentials Secret referenced by `cloudnativePG.credentials`, and merged into the `app.ini` at startup.
#### Server defaults
The server defaults are a bit more complex.
@@ -335,7 +332,7 @@ External tools such as `valkey` or `memcached` handle these workloads much bette
If HA is not needed/desired, the following configurations can be used to deploy a single-pod Gitea instance.
1. For a production-ready single-pod Gitea instance without external dependencies (using the chart dependency `postgresql` and `valkey`):
1. For a production-ready single-pod Gitea instance (using the chart dependency `valkey` and a single-instance CloudNativePG `Cluster`):
<details>
@@ -344,10 +341,9 @@ If HA is not needed/desired, the following configurations can be used to deploy
```yaml
valkey:
enabled: true
postgresql:
cloudnativePG:
enabled: true
postgresql-ha:
enabled: false
instances: 1
persistence:
enabled: true
@@ -375,9 +371,7 @@ If HA is not needed/desired, the following configurations can be used to deploy
```yaml
valkey:
enabled: false
postgresql:
enabled: false
postgresql-ha:
cloudnativePG:
enabled: false
persistence:
@@ -489,7 +483,7 @@ Priority (highest to lowest) for defining app.ini variables:
Any external database listed in [https://docs.gitea.com/installation/database-prep/](https://docs.gitea.com/installation/database-prep/) can be used instead of the built-in PostgreSQL.
In fact, it is **highly recommended** to use an external database to ensure a stable Gitea installation longterm.
If an external database is used, no matter which type, make sure to set `postgresql.enabled` to `false` to disable the use of the built-in PostgreSQL.
If an external database is used, no matter which type, make sure to set `cloudnativePG.enabled` to `false` to disable the use of the built-in PostgreSQL.
```yaml
gitea:
@@ -502,10 +496,7 @@ gitea:
PASSWD: gitea
SCHEMA: gitea
postgresql:
enabled: false
postgresql-ha:
cloudnativePG:
enabled: false
```
@@ -608,14 +599,14 @@ persistence:
In case that persistence has been disabled it will simply use an empty dir volume.
PostgreSQL handles the persistence in the exact same way.
You can interact with the postgres settings as displayed in the following example:
The CloudNativePG `Cluster` handles the persistence on its own.
You can interact with its storage settings as displayed in the following example:
```yaml
postgresql:
persistence:
enabled: true
existingClaim: MyAwesomeGiteaPostgresClaim
cloudnativePG:
storage:
size: 20Gi
storageClass: myOwnStorageClass
```
### Admin User
@@ -1035,8 +1026,8 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
| `deployment.labels` | Labels for the deployment. | `{}` |
| `deployment.affinity` | Affinity for the deployment. | `{}` |
| `deployment.dnsConfig` | dnsConfig of the Gitea deployment. | `{}` |
| `deployment.gitea.env` | Additional environment variables to pass to the gitea container. | `[]` |
| `deployment.gitea.envFrom` | List of environment variables mounted from configMaps or secrets for the gitea container. | `[]` |
| `deployment.gitea.env` | Additional environment variables to pass to the Gitea container. | `[]` |
| `deployment.gitea.envFrom` | List of environment variables mounted from configMaps or secrets for the Gitea container. | `[]` |
| `deployment.gitea.image.registry` | image registry, e.g. gcr.io,docker.io. | `docker.gitea.com` |
| `deployment.gitea.image.repository` | Image to start for this pod. | `gitea` |
| `deployment.gitea.image.tag` | Visit: [Image tag](https://hub.docker.com/r/gitea/gitea/tags?page=1&ordering=last_updated). Defaults to `appVersion` within Chart.yaml. | `""` |
@@ -1122,7 +1113,7 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
| `gatewayAPI.core.backendTLSPolicy.targetRefs` | Target references for the BackendTLSPolicy. Defaults to the HTTP service. | `[]` |
| `gatewayAPI.core.backendTLSPolicy.validation` | Validation configuration (required when enabled). See `docs/gateway-api.md`. | `{}` |
| `gatewayAPI.core.backendTLSPolicy.validation.caCertificateRefs` | CA certificate references for the BackendTLSPolicy validation. See `docs/gateway-api.md`. | |
| `gatewayAPI.core.backendTLSPolicy.validation.hostname` | Hostname for the BackendTLSPolicy validation. Must be the Common Name (CN) or a Subject Alternative Name (SAN) of the gitea server certificate. See `docs/gateway-api.md`. | |
| `gatewayAPI.core.backendTLSPolicy.validation.hostname` | Hostname for the BackendTLSPolicy validation. Must be the Common Name (CN) or a Subject Alternative Name (SAN) of the Gitea server certificate. See `docs/gateway-api.md`. | |
| `gatewayAPI.core.httpRoute.enabled` | Render an HTTPRoute resource. | `false` |
| `gatewayAPI.core.httpRoute.annotations` | Annotations applied to the HTTPRoute. | `{}` |
| `gatewayAPI.core.httpRoute.labels` | Additional labels applied to the HTTPRoute. | `{}` |
@@ -1153,7 +1144,7 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
| `ingress.hosts[0].host` | Default Ingress host. | `git.example.com` |
| `ingress.hosts[0].paths[0].path` | Default Ingress path. | `/` |
| `ingress.tls` | Ingress tls settings. | `[]` |
| `namespace` | An explicit namespace to deploy gitea into. Defaults to the release namespace if not specified. | `""` |
| `namespace` | An explicit namespace to deploy Gitea into. Defaults to the release namespace if not specified. | `""` |
### Network
@@ -1213,7 +1204,7 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
| `secrets.config.existingSecret.secretName` | Name of the already existing config Secret. | `""` |
| `secrets.config.new.annotations` | Annotations for the config Secret. | `{}` |
| `secrets.config.new.labels` | Labels for the config Secret. | `{}` |
| `secrets.gpg.enabled` | Enable mounting of a GPG key to sign git commits. | `false` |
| `secrets.gpg.enabled` | Enable mounting of a GPG key to sign Git commits. | `false` |
| `secrets.gpg.addSHASumAnnotation` | Add a pod annotation with the SHA sum of the GPG key Secret to trigger a rollout on change. Further information can be found in the [documentation](./README.md#secret-checksum-annotation). | `false` |
| `secrets.gpg.existingSecret.enabled` | Use an already existing Secret instead of creating the GPG key Secret. | `false` |
| `secrets.gpg.existingSecret.secretName` | Name of the already existing GPG key Secret. | `""` |
@@ -1370,6 +1361,38 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
| `gitea.startupProbe.successThreshold` | Success threshold for startup probe. | `1` |
| `gitea.startupProbe.failureThreshold` | Failure threshold for startup probe. | `10` |
### CloudNativePG
| Name | Description | Value |
| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------- |
| `cloudnativePG.enabled` | Provision a CloudNativePG `Cluster` for Gitea. Requires the CloudNativePG operator to be installed in the cluster. | `false` |
| `cloudnativePG.annotations` | Annotations for the CloudNativePG `Cluster`. | `{}` |
| `cloudnativePG.labels` | Additional labels for the CloudNativePG `Cluster`. | `{}` |
| `cloudnativePG.image.registry` | Image registry. | `ghcr.io` |
| `cloudnativePG.image.repository` | Image repository. | `cloudnative-pg/postgresql` |
| `cloudnativePG.image.tag` | Image tag. | `18.0` |
| `cloudnativePG.instances` | Number of PostgreSQL instances. Values greater than `1` provision a HA-ready cluster with streaming replication. | `3` |
| `cloudnativePG.credentials.addSHASumAnnotation` | Add a pod annotation with the SHA sum of the credentials Secret to trigger a rollout on change. Further information can be found in the [documentation](./README.md#secret-checksum-annotation). | `false` |
| `cloudnativePG.credentials.database` | Name of the database to create. CloudNativePG requires it as a literal in the `Cluster`, hence it cannot be sourced from a Secret. | `gitea` |
| `cloudnativePG.credentials.username` | Name of the database owner to create. CloudNativePG requires it as a literal in the `Cluster`, hence it cannot be sourced from a Secret. | `gitea` |
| `cloudnativePG.credentials.existingSecret.enabled` | Use an already existing Secret instead of creating the credentials Secret. | `false` |
| `cloudnativePG.credentials.existingSecret.secretName` | Name of the already existing credentials Secret. Must be of type `kubernetes.io/basic-auth` and its `username` must match `cloudnativePG.credentials.username`. | `""` |
| `cloudnativePG.credentials.existingSecret.passwordKey` | Key of the password in the existing credentials Secret. | `password` |
| `cloudnativePG.credentials.new.annotations` | Annotations for the credentials Secret. | `{}` |
| `cloudnativePG.credentials.new.labels` | Labels for the credentials Secret. | `{}` |
| `cloudnativePG.credentials.new.password` | Password of the database owner. | `gitea` |
| `cloudnativePG.postgresql.parameters` | Custom PostgreSQL configuration parameters. | `{}` |
| `cloudnativePG.storage.size` | Size of the data volume. | `10Gi` |
| `cloudnativePG.storage.storageClass` | Storage class of the data volume. Defaults to the cluster's default storage class. | `""` |
| `cloudnativePG.walStorage.enabled` | Store the write-ahead log on a dedicated volume. | `false` |
| `cloudnativePG.walStorage.size` | Size of the write-ahead log volume. | `2Gi` |
| `cloudnativePG.walStorage.storageClass` | Storage class of the write-ahead log volume. Defaults to the cluster's default storage class. | `""` |
| `cloudnativePG.affinity` | Affinity for the PostgreSQL pods. CloudNativePG nests `nodeSelector` and `tolerations` below this key as well. | `{}` |
| `cloudnativePG.priorityClassName` | Priority class name for the PostgreSQL pods. | `""` |
| `cloudnativePG.monitoring.enablePodMonitor` | Create a `PodMonitor` for the CloudNativePG `Cluster`. | `false` |
| `cloudnativePG.resources` | Kubernetes resources for the PostgreSQL containers. | `{}` |
| `cloudnativePG.topologySpreadConstraints` | Topology spread constraints for the PostgreSQL pods. | `[]` |
### valkey
| Name | Description | Value |
@@ -1394,47 +1417,6 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
| `valkey.metrics.exporter.image.repository` | Image repository. | `oliver006/redis_exporter` |
| `valkey.metrics.exporter.image.tag` | Image tag. | `""` |
### PostgreSQL HA
| Name | Description | Value |
| -------------------------------------------------- | ----------------------------------------------------------------- | --------------------------------- |
| `postgresql-ha.enabled` | Enable PostgreSQL HA. | `true` |
| `postgresql-ha.global.postgresql.database` | Name for a custom database to create (overrides `auth.database`). | `gitea` |
| `postgresql-ha.global.postgresql.username` | Name for a custom user to create (overrides `auth.username`). | `gitea` |
| `postgresql-ha.global.postgresql.password` | Name for a custom password to create (overrides `auth.password`). | `gitea` |
| `postgresql-ha.metrics.image.repository` | Image repository, eg. `bitnamilegacy/postgres-exporter`. | `bitnamilegacy/postgres-exporter` |
| `postgresql-ha.postgresql.image.repository` | Image repository, eg. `bitnamilegacy/postgresql-repmgr`. | `bitnamilegacy/postgresql-repmgr` |
| `postgresql-ha.postgresql.repmgrPassword` | Repmgr Password. | `changeme2` |
| `postgresql-ha.postgresql.postgresPassword` | postgres Password. | `changeme1` |
| `postgresql-ha.postgresql.password` | Password for the `gitea` user (overrides `auth.password`). | `changeme4` |
| `postgresql-ha.pgpool.adminPassword` | pgpool adminPassword. | `changeme3` |
| `postgresql-ha.pgpool.image.repository` | Image repository, eg. `bitnamilegacy/pgpool`. | `bitnamilegacy/pgpool` |
| `postgresql-ha.pgpool.srCheckPassword` | pgpool srCheckPassword. | `changeme4` |
| `postgresql-ha.service.ports.postgresql` | PostgreSQL service port (overrides `service.ports.postgresql`). | `5432` |
| `postgresql-ha.persistence.enabled` | Enable persistence. | `true` |
| `postgresql-ha.persistence.storageClass` | Persistent Volume Storage Class. | `""` |
| `postgresql-ha.persistence.size` | PVC Storage Request for PostgreSQL HA volume. | `10Gi` |
| `postgresql-ha.volumePermissions.image.repository` | Image repository, eg. `bitnamilegacy/os-shell`. | `bitnamilegacy/os-shell` |
### PostgreSQL
| Name | Description | Value |
| ------------------------------------------------------- | ----------------------------------------------------------------- | --------------------------------- |
| `postgresql.enabled` | Enable PostgreSQL. | `false` |
| `postgresql.global.postgresql.auth.password` | Password for the `gitea` user (overrides `auth.password`). | `gitea` |
| `postgresql.global.postgresql.auth.database` | Name for a custom database to create (overrides `auth.database`). | `gitea` |
| `postgresql.global.postgresql.auth.username` | Name for a custom user to create (overrides `auth.username`). | `gitea` |
| `postgresql.global.postgresql.service.ports.postgresql` | PostgreSQL service port (overrides `service.ports.postgresql`). | `5432` |
| `postgresql.image.repository` | Image repository, eg. `bitnamilegacy/postgresql`. | `bitnamilegacy/postgresql` |
| `postgresql.primary.persistence.enabled` | Enable persistence. | `true` |
| `postgresql.primary.persistence.storageClass` | Persistent Volume storage class. | `""` |
| `postgresql.primary.persistence.size` | PVC Storage Request for PostgreSQL volume. | `10Gi` |
| `postgresql.readReplicas.persistence.enabled` | Enable PostgreSQL read only data persistence using PVC. | `true` |
| `postgresql.readReplicas.persistence.storageClass` | Persistent Volume storage class. | `""` |
| `postgresql.readReplicas.persistence.size` | PVC Storage Request for PostgreSQL volume. | `""` |
| `postgresql.metrics.image.repository` | Image repository, eg. `bitnamilegacy/postgres-exporter`. | `bitnamilegacy/postgres-exporter` |
| `postgresql.volumePermissions.image.repository` | Image repository, eg. `bitnamilegacy/os-shell`. | `bitnamilegacy/os-shell` |
### Advanced
| Name | Description | Value |
@@ -1466,7 +1448,7 @@ If you miss this, blindly upgrading may delete your Postgres instance and you ma
- All Secrets created by this chart are now configured through the new `secrets` section.
It exposes `annotations`, `labels`, a checksum-annotation toggle and an `existingSecret` reference for each of the
`admin`, `config`, `gpg`, `init`, `inlineConfig` and `metrics` Secrets.
- The `gitea.admin` object has been replaced by `secrets.admin`.
The chart fails to render if `gitea.admin` is still set.
Migrate as follows:
@@ -1682,15 +1664,17 @@ If you want to switch to a RWX volume and go for HA, you need to
<!-- prettier-ignore-start -->
<!-- markdownlint-disable-next-line -->
**Transitioning from Postgres to Postgres HA**
**Transitioning from Postgres or Postgres HA to CloudNativePG**
<!-- prettier-ignore-end -->
If you are running with a non-HA PG DB from a previous chart release, you need to set
The `postgresql` and `postgresql-ha` sub-charts have been replaced by a [CloudNativePG](https://cloudnative-pg.io/) `Cluster` resource, configured via `cloudnativePG`.
The CloudNativePG operator is not bundled with this chart and has to be installed cluster-wide beforehand.
- `postgresql-ha.enabled=false`
- `postgresql.enabled=true`
There is no in-place migration path: dump the database of the old deployment with `pg_dump`, remove the `postgresql` or `postgresql-ha` values and deploy the chart with `cloudnativePG.enabled=true`.
Afterwards restore the dump into the new cluster.
Alternatively, point the new `Cluster` at the existing data via one of the [CloudNativePG bootstrap methods](https://cloudnative-pg.io/documentation/current/bootstrap/).
This is needed to stay with your existing single-instance DB (as the HA-variant is the new default).
For a single-instance database, set `cloudnativePG.instances=1`.
<!-- prettier-ignore-start -->
<!-- markdownlint-disable-next-line -->
+24 -8
View File
@@ -28,8 +28,8 @@ In addition, the following components are required for full HA-readiness:
- A HA-ready cache (`valkey-cluster`)
- A HA-ready DB
`postgres.enabled`, which default to `true`, must be set to `false` for a HA setup.
The default `postgres` chart dependency is not HA-ready (there's a dedicated `postgres-ha` chart).
`cloudnativePG.enabled`, which defaults to `false`, must be enabled for a HA setup.
It requires the CloudNativePG operator to be installed cluster-wide beforehand.
The following sections discuss each of the components in more detail.
Note that for each component discussed, the shown configurations only provides a (working) starting point, not necessarily the most optimal setup.
@@ -153,15 +153,31 @@ persistence:
## Database
If you do not have an HA-ready DB, using a managed database service in the cloud might be the easiest and most robust solution.
Remember: disable the built-in `postgres` dependency and configure the database connection manually via `gitea.config.database`:
By enabling `cloudnativePG`, the chart renders a [CloudNativePG](https://cloudnative-pg.io/) `Cluster`, which provides a HA-ready PostgreSQL via streaming replication.
The CloudNativePG operator itself is not part of this chart and has to be [installed cluster-wide](https://cloudnative-pg.io/documentation/current/installation_upgrade/) beforehand.
For that reason the option is disabled by default.
```yml
cloudnativePG:
enabled: true
instances: 3
storage:
size: 10Gi
storageClass: <storage class>
walStorage:
enabled: true
size: 2Gi
storageClass: <storage class>
```
If you do not want to run the operator, using a managed database service in the cloud might be the easiest and most robust solution.
Remember: keep `cloudnativePG` disabled and configure the database connection manually via `gitea.config.database`:
```yml
cloudnativePG:
enabled: false
gitea:
database:
builtIn:
postgresql:
enabled: false
config:
database:
DB_TYPE: postgres
+24
View File
@@ -0,0 +1,24 @@
{{/* vim: set filetype=mustache: */}}
{{/* annotations */}}
{{- define "gitea.cluster.cloudnativePG.annotations" -}}
{{- with .Values.cloudnativePG.annotations }}
{{- toYaml . -}}
{{- end }}
{{- end }}
{{/* labels */}}
{{- define "gitea.cluster.cloudnativePG.labels" -}}
{{ include "gitea.labels" . }}
{{- with .Values.cloudnativePG.labels }}
{{ toYaml . }}
{{- end }}
{{- end }}
{{/* names */}}
{{- define "gitea.cluster.cloudnativePG.name" -}}
{{ include "gitea.fullname" . }}-postgresql
{{- end }}
+8 -23
View File
@@ -174,15 +174,9 @@ app.kubernetes.io/name: {{ include "gitea.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- define "postgresql-ha.dns" -}}
{{- if (index .Values "postgresql-ha").enabled -}}
{{- printf "%s-postgresql-ha-pgpool.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain (index .Values "postgresql-ha" "service" "ports" "postgresql") -}}
{{- end -}}
{{- end -}}
{{- define "postgresql.dns" -}}
{{- if (index .Values "postgresql").enabled -}}
{{- printf "%s-postgresql.%s.svc.%s:%g" .Release.Name .Release.Namespace .Values.clusterDomain .Values.postgresql.global.postgresql.service.ports.postgresql -}}
{{- define "cloudnativePG.dns" -}}
{{- if .Values.cloudnativePG.enabled -}}
{{- printf "%s-rw.%s.svc.%s:5432" (include "gitea.cluster.cloudnativePG.name" .) (.Values.namespace | default .Release.Namespace) .Values.clusterDomain -}}
{{- end -}}
{{- end -}}
@@ -441,23 +435,14 @@ https
{{- end -}}
{{- define "gitea.inline_configuration.defaults.database" -}}
{{- if (index .Values "postgresql-ha" "enabled") -}}
{{- if .Values.cloudnativePG.enabled -}}
{{/* PASSWD is injected as an env-to-ini variable from the credentials Secret. */}}
{{- $_ := set .Values.gitea.config.database "DB_TYPE" "postgres" -}}
{{- if not (.Values.gitea.config.database.HOST) -}}
{{- $_ := set .Values.gitea.config.database "HOST" (include "postgresql-ha.dns" .) -}}
{{- $_ := set .Values.gitea.config.database "HOST" (include "cloudnativePG.dns" .) -}}
{{- end -}}
{{- $_ := set .Values.gitea.config.database "NAME" (index .Values "postgresql-ha" "global" "postgresql" "database") -}}
{{- $_ := set .Values.gitea.config.database "USER" (index .Values "postgresql-ha" "global" "postgresql" "username") -}}
{{- $_ := set .Values.gitea.config.database "PASSWD" (index .Values "postgresql-ha" "global" "postgresql" "password") -}}
{{- end -}}
{{- if (index .Values "postgresql" "enabled") -}}
{{- $_ := set .Values.gitea.config.database "DB_TYPE" "postgres" -}}
{{- if not (.Values.gitea.config.database.HOST) -}}
{{- $_ := set .Values.gitea.config.database "HOST" (include "postgresql.dns" .) -}}
{{- end -}}
{{- $_ := set .Values.gitea.config.database "NAME" .Values.postgresql.global.postgresql.auth.database -}}
{{- $_ := set .Values.gitea.config.database "USER" .Values.postgresql.global.postgresql.auth.username -}}
{{- $_ := set .Values.gitea.config.database "PASSWD" .Values.postgresql.global.postgresql.auth.password -}}
{{- $_ := set .Values.gitea.config.database "NAME" .Values.cloudnativePG.credentials.database -}}
{{- $_ := set .Values.gitea.config.database "USER" .Values.cloudnativePG.credentials.username -}}
{{- end -}}
{{- end -}}
+7
View File
@@ -84,6 +84,13 @@
value: /tmp/existing-envs
- name: ENV_TO_INI_MOUNT_POINT
value: /env-to-ini-mounts
{{- if .Values.cloudnativePG.enabled }}
- name: GITEA__database__PASSWD
valueFrom:
secretKeyRef:
key: {{ include "gitea.secret.cloudnativePG.passwordKey" . }}
name: {{ include "gitea.secret.cloudnativePG.name" . }}
{{- end }}
{{- if .Values.deployment.gitea.env }}
{{- toYaml .Values.deployment.gitea.env | nindent 4 }}
{{- end }}
+5
View File
@@ -9,6 +9,11 @@
checksum/admin: {{ include "gitea.secret.checksum" (list . "admin") }}
{{- end }}
{{/* secret - cloudnativePG */}}
{{- if and .Values.cloudnativePG.enabled .Values.cloudnativePG.credentials.addSHASumAnnotation }}
checksum/cloudnativePG: {{ include "gitea.secret.checksum" (list . "cloudnativePG") }}
{{- end }}
{{/* secret - config */}}
{{- if and .Values.secrets.config.enabled .Values.secrets.config.addSHASumAnnotation }}
checksum/config: {{ include "gitea.secret.checksum" (list . "config") }}
+34 -1
View File
@@ -8,6 +8,12 @@
{{- end }}
{{- end }}
{{- define "gitea.secret.cloudnativePG.annotations" -}}
{{- with .Values.cloudnativePG.credentials.new.annotations }}
{{- toYaml . -}}
{{- end }}
{{- end }}
{{- define "gitea.secret.config.annotations" -}}
{{- with .Values.secrets.config.new.annotations }}
{{- toYaml . -}}
@@ -49,7 +55,11 @@ Arguments: (list $root $key)
{{- define "gitea.secret.checksum" -}}
{{- $root := index . 0 -}}
{{- $key := index . 1 -}}
{{- if (index $root.Values.secrets $key).existingSecret.enabled -}}
{{- $config := index $root.Values.secrets $key -}}
{{- if eq $key "cloudnativePG" -}}
{{- $config = $root.Values.cloudnativePG.credentials -}}
{{- end -}}
{{- if $config.existingSecret.enabled -}}
{{- $namespace := $root.Values.namespace | default $root.Release.Namespace -}}
{{- $name := include (printf "gitea.secret.%s.name" $key) $root -}}
{{- lookup "v1" "Secret" $namespace $name | toYaml | sha256sum -}}
@@ -68,6 +78,13 @@ Arguments: (list $root $key)
{{- end }}
{{- end }}
{{- define "gitea.secret.cloudnativePG.labels" -}}
{{ include "gitea.labels" . }}
{{- with .Values.cloudnativePG.credentials.new.labels }}
{{ toYaml . }}
{{- end }}
{{- end }}
{{- define "gitea.secret.config.labels" -}}
{{ include "gitea.labels" . }}
{{- with .Values.secrets.config.new.labels }}
@@ -113,6 +130,14 @@ Arguments: (list $root $key)
{{- end -}}
{{- end }}
{{- define "gitea.secret.cloudnativePG.name" -}}
{{- if .Values.cloudnativePG.credentials.existingSecret.enabled -}}
{{ required "`cloudnativePG.credentials.existingSecret.secretName` must be set when `cloudnativePG.credentials.existingSecret.enabled` is enabled" .Values.cloudnativePG.credentials.existingSecret.secretName }}
{{- else -}}
{{ include "gitea.cluster.cloudnativePG.name" . }}-app
{{- end -}}
{{- end }}
{{- define "gitea.secret.config.name" -}}
{{- if .Values.secrets.config.existingSecret.enabled -}}
{{ required "`secrets.config.existingSecret.secretName` must be set when `secrets.config.existingSecret.enabled` is enabled" .Values.secrets.config.existingSecret.secretName }}
@@ -179,6 +204,14 @@ username
{{- end -}}
{{- end }}
{{- define "gitea.secret.cloudnativePG.passwordKey" -}}
{{- if .Values.cloudnativePG.credentials.existingSecret.enabled -}}
{{ .Values.cloudnativePG.credentials.existingSecret.passwordKey }}
{{- else -}}
password
{{- end -}}
{{- end }}
{{- define "gitea.secret.gpg.gpgHomeKey" -}}
{{- if .Values.secrets.gpg.existingSecret.enabled -}}
{{ .Values.secrets.gpg.existingSecret.gpgHomeKey }}
+51
View File
@@ -0,0 +1,51 @@
{{- if .Values.cloudnativePG.enabled -}}
{{- $registry := .Values.global.imageRegistry | default .Values.cloudnativePG.image.registry -}}
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
{{- with (include "gitea.cluster.cloudnativePG.annotations" .) }}
annotations:
{{- . | nindent 4 }}
{{- end }}
labels:
{{- include "gitea.cluster.cloudnativePG.labels" . | nindent 4 }}
name: {{ include "gitea.cluster.cloudnativePG.name" . }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
spec:
{{- with .Values.cloudnativePG.affinity }}
affinity:
{{- toYaml . | nindent 4 }}
{{- end }}
bootstrap:
initdb:
database: {{ .Values.cloudnativePG.credentials.database | quote }}
owner: {{ .Values.cloudnativePG.credentials.username | quote }}
secret:
name: {{ include "gitea.secret.cloudnativePG.name" . }}
imageName: {{ printf "%s/%s:%s" $registry .Values.cloudnativePG.image.repository (.Values.cloudnativePG.image.tag | toString) | quote }}
instances: {{ .Values.cloudnativePG.instances }}
monitoring:
enablePodMonitor: {{ .Values.cloudnativePG.monitoring.enablePodMonitor }}
postgresql:
parameters:
{{- toYaml .Values.cloudnativePG.postgresql.parameters | nindent 6 }}
priorityClassName: {{ .Values.cloudnativePG.priorityClassName | quote }}
resources:
{{- toYaml .Values.cloudnativePG.resources | nindent 4 }}
storage:
size: {{ .Values.cloudnativePG.storage.size | quote }}
{{- with .Values.cloudnativePG.storage.storageClass }}
storageClass: {{ . | quote }}
{{- end }}
{{- with .Values.cloudnativePG.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.cloudnativePG.walStorage.enabled }}
walStorage:
size: {{ .Values.cloudnativePG.walStorage.size | quote }}
{{- with .Values.cloudnativePG.walStorage.storageClass }}
storageClass: {{ . | quote }}
{{- end }}
{{- end }}
{{- end -}}
+10
View File
@@ -95,6 +95,16 @@
{{- fail "`openshift.hostUsers` does no longer exist. Please refer to the changelog and configure `deployment.hostUsers` instead." -}}
{{- end -}}
{{/* POSTGRESQL */}}
{{- if index .Values "postgresql" -}}
{{- fail "`postgresql` does no longer exist. Please refer to the changelog and configure `cloudnativePG` instead, which requires the CloudNativePG operator to be installed in the cluster." -}}
{{- end -}}
{{/* POSTGRESQL HA */}}
{{- if index .Values "postgresql-ha" -}}
{{- fail "`postgresql-ha` does no longer exist. Please refer to the changelog and configure `cloudnativePG` instead, which requires the CloudNativePG operator to be installed in the cluster." -}}
{{- end -}}
{{/* PRIORITY CLASS NAME */}}
{{- if .Values.priorityClassName -}}
{{- fail "`priorityClassName` does no longer exist. Please refer to the changelog and configure `deployment.priorityClassName` instead." -}}
+18
View File
@@ -0,0 +1,18 @@
{{- if and .Values.cloudnativePG.enabled (not .Values.cloudnativePG.credentials.existingSecret.enabled) -}}
apiVersion: v1
kind: Secret
metadata:
{{- with (include "gitea.secret.cloudnativePG.annotations" .) }}
annotations:
{{- . | nindent 4 }}
{{- end }}
labels:
{{- include "gitea.secret.cloudnativePG.labels" . | nindent 4 }}
name: {{ include "gitea.secret.cloudnativePG.name" . }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
type: kubernetes.io/basic-auth
data:
password: {{ required "`cloudnativePG.credentials.new.password` must be set when `cloudnativePG.enabled` is enabled" .Values.cloudnativePG.credentials.new.password | b64enc | quote }}
{{- /* CloudNativePG requires the username of a basic-auth bootstrap Secret to match the owner of the Cluster. */}}
username: {{ required "`cloudnativePG.credentials.username` must be set when `cloudnativePG.enabled` is enabled" .Values.cloudnativePG.credentials.username | b64enc | quote }}
{{- end -}}
-5
View File
@@ -21,11 +21,6 @@ data:
{{- define "gitea.config.assertions" -}}
{{- /*assert that only one PG dep is enabled */ -}}
{{- if and (.Values.postgresql.enabled) (index .Values "postgresql-ha" "enabled") -}}
{{- fail "Only one of postgresql or postgresql-ha can be enabled at the same time." -}}
{{- end }}
{{- /* multiple replicas assertions */ -}}
{{- if gt (.Values.deployment.replicas | int) 1 -}}
{{- if .Values.gitea.config.cron -}}
+182
View File
@@ -0,0 +1,182 @@
suite: Test cluster basics
release:
name: gitea-unittests
namespace: testing
tests:
- it: "Render nothing when cloudnativePG is disabled"
templates:
- templates/cluster.yaml
- templates/secret_cloudnativePG.yaml
set:
cloudnativePG:
enabled: false
asserts:
- hasDocuments:
count: 0
- it: "Render the Cluster with the default values"
template: templates/cluster.yaml
set:
cloudnativePG:
enabled: true
asserts:
- containsDocument:
kind: Cluster
apiVersion: postgresql.cnpg.io/v1
name: gitea-unittests-postgresql
namespace: testing
- equal:
path: spec.instances
value: 3
- equal:
path: spec.imageName
value: "ghcr.io/cloudnative-pg/postgresql:18.0"
- equal:
path: spec.bootstrap.initdb
value:
database: "gitea"
owner: "gitea"
secret:
name: gitea-unittests-postgresql-app
- equal:
path: spec.storage.size
value: "10Gi"
- notExists:
path: spec.storage.storageClass
- notExists:
path: spec.walStorage
- notExists:
path: spec.affinity
- notExists:
path: spec.topologySpreadConstraints
- it: "Render the credential Secret with the default values"
template: templates/secret_cloudnativePG.yaml
set:
cloudnativePG:
enabled: true
asserts:
- containsDocument:
kind: Secret
apiVersion: v1
name: gitea-unittests-postgresql-app
namespace: testing
- equal:
path: type
value: kubernetes.io/basic-auth
- equal:
path: data.password
decodeBase64: true
value: "gitea"
- equal:
path: data.username
decodeBase64: true
value: "gitea"
- notExists:
path: data.database
- notExists:
path: stringData
- it: "Render no credential Secret when an existing Secret is used"
template: templates/secret_cloudnativePG.yaml
set:
cloudnativePG:
enabled: true
credentials:
existingSecret:
enabled: true
secretName: my-credentials
asserts:
- hasDocuments:
count: 0
- it: "Reference the existing Secret in the Cluster"
template: templates/cluster.yaml
set:
cloudnativePG:
enabled: true
credentials:
existingSecret:
enabled: true
secretName: my-credentials
database: my-database
username: my-username
asserts:
- equal:
path: spec.bootstrap.initdb
value:
database: "my-database"
owner: "my-username"
secret:
name: my-credentials
- it: "Apply the storage and walStorage customizations"
template: templates/cluster.yaml
set:
cloudnativePG:
enabled: true
storage:
size: 1337Mi
storageClass: my-storage-class
walStorage:
enabled: true
size: 42Mi
storageClass: my-wal-storage-class
asserts:
- equal:
path: spec.storage
value:
size: "1337Mi"
storageClass: "my-storage-class"
- equal:
path: spec.walStorage
value:
size: "42Mi"
storageClass: "my-wal-storage-class"
- it: "Apply the scheduling customizations"
template: templates/cluster.yaml
set:
cloudnativePG:
enabled: true
affinity:
nodeSelector:
disktype: ssd
podAntiAffinityType: required
tolerations:
- key: my-key
operator: Equal
value: my-value
effect: NoSchedule
priorityClassName: my-priority-class
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: gitea
asserts:
- equal:
path: spec.affinity
value:
nodeSelector:
disktype: ssd
podAntiAffinityType: required
tolerations:
- key: my-key
operator: Equal
value: my-value
effect: NoSchedule
- equal:
path: spec.priorityClassName
value: my-priority-class
- equal:
path: spec.topologySpreadConstraints
value:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: gitea
+48
View File
@@ -0,0 +1,48 @@
suite: Test config database
release:
name: gitea-unittests
namespace: testing
tests:
- it: "Connect to the read-write Service of the CloudNativePG Cluster"
template: templates/secret_inlineConfig.yaml
set:
cloudnativePG:
enabled: true
asserts:
- documentIndex: 0
matchRegex:
path: data.database
decodeBase64: true
pattern: HOST=gitea-unittests-postgresql-rw.testing.svc.cluster.local:5432
- it: "Connect to the read-write Service of the CloudNativePG Cluster with a custom cluster domain"
template: templates/secret_inlineConfig.yaml
set:
clusterDomain: my-special-cluster.local
cloudnativePG:
enabled: true
asserts:
- documentIndex: 0
matchRegex:
path: data.database
decodeBase64: true
pattern: HOST=gitea-unittests-postgresql-rw.testing.svc.my-special-cluster.local:5432
- it: "Connect to the configured CloudNativePG database"
template: templates/secret_inlineConfig.yaml
set:
cloudnativePG:
enabled: true
credentials:
database: gitea-database
username: gitea-username
asserts:
- documentIndex: 0
equal:
path: data.database
decodeBase64: true
value: |-
DB_TYPE=postgres
HOST=gitea-unittests-postgresql-rw.testing.svc.cluster.local:5432
NAME=gitea-database
USER=gitea-username
@@ -1,4 +1,4 @@
suite: Test deployment inline config
suite: Test config inlineConfig
release:
name: gitea-unittests
namespace: testing
@@ -1,129 +0,0 @@
suite: Test dependency customization integrity of postgresql-ha
release:
name: gitea-unittests
namespace: testing
set:
postgresql:
enabled: false
postgresql-ha:
enabled: true
global:
postgresql:
database: gitea-database
password: gitea-password
username: gitea-username
postgresql:
repmgrPassword: custom-password-repmgr
postgresPassword: custom-password-postgres
password: custom-password-overwritten-by-global-postgresql-password
pgpool:
adminPassword: custom-password-pgpool
srCheckPassword: custom-password-sr-check
service:
ports:
postgresql: 1234
persistence:
size: 1337Mi
tests:
- it: "[postgresql-ha] Apply the database settings"
template: charts/postgresql-ha/templates/postgresql/statefulset.yaml
asserts:
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_DB
value: "gitea-database"
- documentIndex: 0
contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_USER
value: "gitea-username"
- it: "[postgresql-ha] Apply the database passwords"
template: charts/postgresql-ha/templates/postgresql/secrets.yaml
asserts:
- documentIndex: 0
equal:
path: data["repmgr-password"]
value: "Y3VzdG9tLXBhc3N3b3JkLXJlcG1ncg=="
- documentIndex: 0
equal:
path: data["postgres-password"]
value: "Y3VzdG9tLXBhc3N3b3JkLXBvc3RncmVz"
- documentIndex: 0
equal:
path: data["password"]
value: "Z2l0ZWEtcGFzc3dvcmQ=" # postgresql-ha.postgresql.password is overwritten by postgresql-ha.global.postgresql.password and should not be referenced here
- it: "[postgresql-ha] Apply pgpool.adminPassword"
template: charts/postgresql-ha/templates/pgpool/secrets.yaml
asserts:
- documentIndex: 0
equal:
path: data["admin-password"]
value: "Y3VzdG9tLXBhc3N3b3JkLXBncG9vbA=="
- it: "[postgresql-ha] Apply pgpool.srCheckPassword"
template: charts/postgresql-ha/templates/pgpool/secrets.yaml
asserts:
- documentIndex: 0
equal:
path: data["sr-check-password"]
value: "Y3VzdG9tLXBhc3N3b3JkLXNyLWNoZWNr"
- it: "[postgresql-ha] Apply persistence.size"
template: charts/postgresql-ha/templates/postgresql/statefulset.yaml
asserts:
- documentIndex: 0
equal:
path: spec.volumeClaimTemplates[0].spec.resources.requests.storage
value: "1337Mi"
- it: "[postgresql-ha] Apply service.ports.postgresql"
template: charts/postgresql-ha/templates/pgpool/service.yaml
asserts:
- documentIndex: 0
equal:
path: spec.ports[0].port
value: 1234
- it: "[postgresql-ha] Render the referenced Service"
template: charts/postgresql-ha/templates/pgpool/service.yaml
asserts:
- containsDocument:
kind: Service
apiVersion: v1
name: gitea-unittests-postgresql-ha-pgpool
namespace: testing
- it: "[gitea] Connect to the pgpool Service"
template: templates/secret_inlineConfig.yaml
asserts:
- documentIndex: 0
matchRegex:
path: data.database
decodeBase64: true
pattern: HOST=gitea-unittests-postgresql-ha-pgpool.testing.svc.cluster.local:1234
- it: "[gitea] Connect to the pgpool 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-ha-pgpool.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
@@ -1,102 +0,0 @@
suite: Test dependency customization integrity of postgresql
release:
name: gitea-unittests
namespace: testing
set:
postgresql-ha:
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
@@ -1,42 +0,0 @@
suite: Test dependency major image bumps
release:
name: gitea-unittests
namespace: testing
tests:
- it: "[postgresql-ha] Detect major image version upgrades"
template: charts/postgresql-ha/templates/postgresql/statefulset.yaml
set:
postgresql:
enabled: false
postgresql-ha:
enabled: true
asserts:
- documentIndex: 0
matchRegex:
path: spec.template.spec.containers[0].image
# IN CASE OF AN INTENTIONAL MAJOR BUMP, ADJUST THIS TEST
pattern: bitnamilegacy/postgresql-repmgr:17.+$
- it: "[postgresql] Detect major image version upgrades"
template: charts/postgresql/templates/primary/statefulset.yaml
set:
postgresql:
enabled: true
postgresql-ha:
enabled: false
asserts:
- documentIndex: 0
matchRegex:
path: spec.template.spec.containers[0].image
# IN CASE OF AN INTENTIONAL MAJOR BUMP, ADJUST THIS TEST
pattern: bitnamilegacy/postgresql:17.+$
- it: "[valkey] Detect major image version upgrades"
template: charts/valkey/templates/deploy_valkey.yaml
set:
valkey:
enabled: true
asserts:
- documentIndex: 0
matchRegex:
path: spec.template.spec.containers[0].image
# IN CASE OF AN INTENTIONAL MAJOR BUMP, ADJUST THIS TEST
pattern: valkey/valkey:9.+$
@@ -0,0 +1,16 @@
suite: Test dependency major image bumps
release:
name: gitea-unittests
namespace: testing
tests:
- it: "[valkey] Detect major image version upgrades"
template: charts/valkey/templates/deploy_valkey.yaml
set:
valkey:
enabled: true
asserts:
- documentIndex: 0
matchRegex:
path: spec.template.spec.containers[0].image
# IN CASE OF AN INTENTIONAL MAJOR BUMP, ADJUST THIS TEST
pattern: valkey/valkey:9.+$
@@ -5,6 +5,7 @@ release:
templates:
- templates/deployment.yaml
- templates/secret_admin.yaml
- templates/secret_cloudnativePG.yaml
- templates/secret_config.yaml
- templates/secret_gpg.yaml
- templates/secret_init.yaml
@@ -14,6 +15,8 @@ tests:
- it: "Omit the checksum annotations by default"
template: templates/deployment.yaml
set:
cloudnativePG.enabled: true
secrets.admin.enabled: true
secrets.config.enabled: true
secrets.gpg.enabled: true
@@ -26,6 +29,8 @@ tests:
asserts:
- notExists:
path: spec.template.metadata.annotations["checksum/admin"]
- notExists:
path: spec.template.metadata.annotations["checksum/cloudnativePG"]
- notExists:
path: spec.template.metadata.annotations["checksum/config"]
- notExists:
@@ -40,6 +45,9 @@ tests:
- it: "Add a checksum annotation for every Secret when addSHASumAnnotation is enabled"
template: templates/deployment.yaml
set:
cloudnativePG.credentials.addSHASumAnnotation: true
cloudnativePG.enabled: true
secrets.admin.addSHASumAnnotation: true
secrets.admin.enabled: true
@@ -63,6 +71,8 @@ tests:
asserts:
- exists:
path: spec.template.metadata.annotations["checksum/admin"]
- exists:
path: spec.template.metadata.annotations["checksum/cloudnativePG"]
- exists:
path: spec.template.metadata.annotations["checksum/config"]
- exists:
@@ -0,0 +1,67 @@
suite: Test deployment cloudnativePG credentials
release:
name: gitea-unittests
namespace: testing
templates:
- templates/deployment.yaml
- templates/secret_cloudnativePG.yaml
tests:
- it: "Inject no database password when cloudnativePG is disabled"
template: templates/deployment.yaml
set:
cloudnativePG:
enabled: false
asserts:
- notContains:
path: spec.template.spec.initContainers[1].env
content:
name: GITEA__database__PASSWD
any: true
- it: "Inject the database password from the rendered Secret"
template: templates/deployment.yaml
set:
cloudnativePG:
enabled: true
asserts:
- contains:
path: spec.template.spec.initContainers[1].env
content:
name: GITEA__database__PASSWD
valueFrom:
secretKeyRef:
key: password
name: gitea-unittests-postgresql-app
- it: "Inject the database password from an existing Secret"
template: templates/deployment.yaml
set:
cloudnativePG:
enabled: true
credentials:
existingSecret:
enabled: true
secretName: my-credentials
passwordKey: my-password-key
asserts:
- contains:
path: spec.template.spec.initContainers[1].env
content:
name: GITEA__database__PASSWD
valueFrom:
secretKeyRef:
key: my-password-key
name: my-credentials
- it: "Fail when an existing Secret is used without a name"
template: templates/deployment.yaml
set:
cloudnativePG:
enabled: true
credentials:
existingSecret:
enabled: true
secretName: ""
asserts:
- failedTemplate:
errorMessage: "`cloudnativePG.credentials.existingSecret.secretName` must be set when `cloudnativePG.credentials.existingSecret.enabled` is enabled"
@@ -98,6 +98,20 @@ tests:
asserts:
- failedTemplate:
errorMessage: "`openshift.hostUsers` does no longer exist. Please refer to the changelog and configure `deployment.hostUsers` instead."
- it: "Fail when the removed `postgresql` value is set"
set:
postgresql:
enabled: true
asserts:
- failedTemplate:
errorMessage: "`postgresql` does no longer exist. Please refer to the changelog and configure `cloudnativePG` instead, which requires the CloudNativePG operator to be installed in the cluster."
- it: "Fail when the removed `postgresql-ha` value is set"
set:
postgresql-ha:
enabled: true
asserts:
- failedTemplate:
errorMessage: "`postgresql-ha` does no longer exist. Please refer to the changelog and configure `cloudnativePG` instead, which requires the CloudNativePG operator to be installed in the cluster."
- it: "Fail when the removed `priorityClassName` value is set"
set:
priorityClassName: high-priority
File renamed without changes.
File renamed without changes.
@@ -3,7 +3,7 @@ chart:
release:
name: gitea-unittests
namespace: testing
suite: Test deployment storage class configuration
suite: Test persistentVolumeClaim storage class
templates:
- templates/persistentVolumeClaim.yaml
tests:
File renamed without changes.
+83 -107
View File
@@ -1112,6 +1112,89 @@ gitea:
successThreshold: 1
failureThreshold: 10
## @section CloudNativePG
# The CloudNativePG operator itself is not part of this chart. It must be installed cluster-wide beforehand:
# https://cloudnative-pg.io/documentation/current/installation_upgrade/
cloudnativePG:
## @param cloudnativePG.enabled Provision a CloudNativePG `Cluster` for Gitea. Requires the CloudNativePG operator to be installed in the cluster.
enabled: false
## @param cloudnativePG.annotations Annotations for the CloudNativePG `Cluster`.
## @param cloudnativePG.labels Additional labels for the CloudNativePG `Cluster`.
annotations: {}
labels: {}
## @param cloudnativePG.image.registry Image registry.
## @param cloudnativePG.image.repository Image repository.
## @param cloudnativePG.image.tag Image tag.
image:
registry: ghcr.io
repository: cloudnative-pg/postgresql
tag: "18.0"
## @param cloudnativePG.instances Number of PostgreSQL instances. Values greater than `1` provision a HA-ready cluster with streaming replication.
instances: 3
credentials:
## @param cloudnativePG.credentials.addSHASumAnnotation Add a pod annotation with the SHA sum of the credentials Secret to trigger a rollout on change. Further information can be found in the [documentation](./README.md#secret-checksum-annotation).
addSHASumAnnotation: false
## @param cloudnativePG.credentials.database Name of the database to create. CloudNativePG requires it as a literal in the `Cluster`, hence it cannot be sourced from a Secret.
## @param cloudnativePG.credentials.username Name of the database owner to create. CloudNativePG requires it as a literal in the `Cluster`, hence it cannot be sourced from a Secret.
database: gitea
username: gitea
## @param cloudnativePG.credentials.existingSecret.enabled Use an already existing Secret instead of creating the credentials Secret.
## @param cloudnativePG.credentials.existingSecret.secretName Name of the already existing credentials Secret. Must be of type `kubernetes.io/basic-auth` and its `username` must match `cloudnativePG.credentials.username`.
## @param cloudnativePG.credentials.existingSecret.passwordKey Key of the password in the existing credentials Secret.
existingSecret:
enabled: false
secretName: ""
passwordKey: password
## @param cloudnativePG.credentials.new.annotations Annotations for the credentials Secret.
## @param cloudnativePG.credentials.new.labels Labels for the credentials Secret.
## @param cloudnativePG.credentials.new.password Password of the database owner.
new:
annotations: {}
labels: {}
password: gitea
## @param cloudnativePG.postgresql.parameters Custom PostgreSQL configuration parameters.
postgresql:
parameters: {}
## @param cloudnativePG.storage.size Size of the data volume.
## @param cloudnativePG.storage.storageClass Storage class of the data volume. Defaults to the cluster's default storage class.
storage:
size: 10Gi
storageClass: ""
## @param cloudnativePG.walStorage.enabled Store the write-ahead log on a dedicated volume.
## @param cloudnativePG.walStorage.size Size of the write-ahead log volume.
## @param cloudnativePG.walStorage.storageClass Storage class of the write-ahead log volume. Defaults to the cluster's default storage class.
walStorage:
enabled: false
size: 2Gi
storageClass: ""
## @param cloudnativePG.affinity Affinity for the PostgreSQL pods. CloudNativePG nests `nodeSelector` and `tolerations` below this key as well.
affinity: {}
## @param cloudnativePG.priorityClassName Priority class name for the PostgreSQL pods.
priorityClassName: ""
## @param cloudnativePG.monitoring.enablePodMonitor Create a `PodMonitor` for the CloudNativePG `Cluster`.
monitoring:
enablePodMonitor: false
## @param cloudnativePG.resources Kubernetes resources for the PostgreSQL containers.
resources: {}
## @param cloudnativePG.topologySpreadConstraints Topology spread constraints for the PostgreSQL pods.
topologySpreadConstraints: []
## @section valkey
valkey:
## @param valkey.enabled Enable valkey standalone or replicated.
@@ -1170,113 +1253,6 @@ valkey:
repository: oliver006/redis_exporter
tag: ""
## @section PostgreSQL HA
postgresql-ha:
## @param postgresql-ha.enabled Enable PostgreSQL HA.
enabled: true
## @param postgresql-ha.global.postgresql.database Name for a custom database to create (overrides `auth.database`).
## @param postgresql-ha.global.postgresql.username Name for a custom user to create (overrides `auth.username`).
## @param postgresql-ha.global.postgresql.password Name for a custom password to create (overrides `auth.password`).
global:
postgresql:
database: gitea
password: gitea
username: gitea
## @param postgresql-ha.metrics.image.repository Image repository, eg. `bitnamilegacy/postgres-exporter`.
metrics:
image:
repository: bitnamilegacy/postgres-exporter
## @param postgresql-ha.postgresql.image.repository Image repository, eg. `bitnamilegacy/postgresql-repmgr`.
## @param postgresql-ha.postgresql.repmgrPassword Repmgr Password.
## @param postgresql-ha.postgresql.postgresPassword postgres Password.
## @param postgresql-ha.postgresql.password Password for the `gitea` user (overrides `auth.password`).
postgresql:
image:
repository: bitnamilegacy/postgresql-repmgr
repmgrPassword: changeme2
postgresPassword: changeme1
password: changeme4
## @param postgresql-ha.pgpool.adminPassword pgpool adminPassword.
## @param postgresql-ha.pgpool.image.repository Image repository, eg. `bitnamilegacy/pgpool`.
## @param postgresql-ha.pgpool.srCheckPassword pgpool srCheckPassword.
pgpool:
adminPassword: changeme3
image:
repository: bitnamilegacy/pgpool
srCheckPassword: changeme4
## @param postgresql-ha.service.ports.postgresql PostgreSQL service port (overrides `service.ports.postgresql`).
service:
ports:
postgresql: 5432
## @param postgresql-ha.persistence.enabled Enable persistence.
## @param postgresql-ha.persistence.storageClass Persistent Volume Storage Class.
## @param postgresql-ha.persistence.size PVC Storage Request for PostgreSQL HA volume.
persistence:
enabled: true
storageClass: ""
size: 10Gi
## @param postgresql-ha.volumePermissions.image.repository Image repository, eg. `bitnamilegacy/os-shell`.
volumePermissions:
image:
repository: bitnamilegacy/os-shell
## @section PostgreSQL
postgresql:
## @param postgresql.enabled Enable PostgreSQL.
enabled: false
## @param postgresql.global.postgresql.auth.password Password for the `gitea` user (overrides `auth.password`).
## @param postgresql.global.postgresql.auth.database Name for a custom database to create (overrides `auth.database`).
## @param postgresql.global.postgresql.auth.username Name for a custom user to create (overrides `auth.username`).
## @param postgresql.global.postgresql.service.ports.postgresql PostgreSQL service port (overrides `service.ports.postgresql`).
global:
postgresql:
auth:
password: gitea
database: gitea
username: gitea
service:
ports:
postgresql: 5432
## @param postgresql.image.repository Image repository, eg. `bitnamilegacy/postgresql`.
image:
repository: bitnamilegacy/postgresql
primary:
## @param postgresql.primary.persistence.enabled Enable persistence.
## @param postgresql.primary.persistence.storageClass Persistent Volume storage class.
## @param postgresql.primary.persistence.size PVC Storage Request for PostgreSQL volume.
persistence:
enabled: true
storageClass: ""
size: 10Gi
readReplicas:
## @param postgresql.readReplicas.persistence.enabled Enable PostgreSQL read only data persistence using PVC.
## @param postgresql.readReplicas.persistence.storageClass Persistent Volume storage class.
## @param postgresql.readReplicas.persistence.size PVC Storage Request for PostgreSQL volume.
persistence:
enabled: true
storageClass: ""
size: ""
## @param postgresql.metrics.image.repository Image repository, eg. `bitnamilegacy/postgres-exporter`.
metrics:
image:
repository: bitnamilegacy/postgres-exporter
## @param postgresql.volumePermissions.image.repository Image repository, eg. `bitnamilegacy/os-shell`.
volumePermissions:
image:
repository: bitnamilegacy/os-shell
# By default, removed or moved settings that still remain in a user defined values.yaml will cause Helm to fail running the install/update.
# Set it to false to skip this basic validation check.