Add non-clustered redis as sub-chart (#672)

Co-authored-by: Julien <julienym@gmail.com>
Co-authored-by: justusbunsi <sk.bunsenbrenner@gmail.com>
Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/672
Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.com>
Co-authored-by: pat-s <patrick.schratz@gmail.com>
Co-committed-by: pat-s <patrick.schratz@gmail.com>
This commit is contained in:
pat-s 2024-07-07 09:57:16 +00:00 committed by justusbunsi
parent 6ffc0a3790
commit 6226e4eaea
11 changed files with 163 additions and 21 deletions

View File

@ -8,5 +8,8 @@ dependencies:
- name: redis-cluster - name: redis-cluster
repository: oci://registry-1.docker.io/bitnamicharts repository: oci://registry-1.docker.io/bitnamicharts
version: 10.2.6 version: 10.2.6
digest: sha256:9bca43256b80ebb6c265a91f81b33ca30536a993d3089413c12fd4ac4d91d0d0 - name: redis
generated: "2024-07-06T00:19:14.943493055Z" repository: oci://registry-1.docker.io/bitnamicharts
version: 19.6.1
digest: sha256:b67d5866d0e5c17ae77d617f11d0c598c93b90dd4703684799f6a77282d8d96d
generated: "2024-07-07T11:54:30.9528697+02:00"

View File

@ -47,3 +47,8 @@ dependencies:
repository: oci://registry-1.docker.io/bitnamicharts repository: oci://registry-1.docker.io/bitnamicharts
version: 10.2.6 version: 10.2.6
condition: redis-cluster.enabled condition: redis-cluster.enabled
# https://github.com/bitnami/charts/blob/main/bitnami/redis/Chart.yaml
- name: redis
repository: oci://registry-1.docker.io/bitnamicharts
version: 19.6.1
condition: redis.enabled

View File

@ -9,7 +9,7 @@ readme: prepare-environment
.PHONY: unittests .PHONY: unittests
unittests: unittests:
helm unittest --strict -f 'unittests/**/*.yaml' -f 'unittests/dependency-major-image-check.yaml' ./ helm unittest --strict -f 'unittests/**/*.yaml' -f 'unittests/dependency-major-image-check.yaml' -f 'unittests/values-conflicting-checks.yaml' ./
.PHONY: helm .PHONY: helm
update-helm-dependencies: update-helm-dependencies:

View File

@ -50,6 +50,7 @@
- [ReadinessProbe](#readinessprobe) - [ReadinessProbe](#readinessprobe)
- [StartupProbe](#startupprobe) - [StartupProbe](#startupprobe)
- [redis-cluster](#redis-cluster) - [redis-cluster](#redis-cluster)
- [redis](#redis)
- [PostgreSQL HA](#postgresql-ha) - [PostgreSQL HA](#postgresql-ha)
- [PostgreSQL](#postgresql) - [PostgreSQL](#postgresql)
- [Advanced](#advanced) - [Advanced](#advanced)
@ -98,7 +99,8 @@ These dependencies are enabled by default:
Alternatively, the following non-HA replacements are available: Alternatively, the following non-HA replacements are available:
- PostgreSQL ([Bitnami PostgreSQL](postgresql](https://github.com/bitnami/charts/blob/main/bitnami/postgresql/Chart.yaml))) - PostgreSQL ([Bitnami PostgreSQL](<Postgresql](https://github.com/bitnami/charts/blob/main/bitnami/postgresql/Chart.yaml)>))
- Redis ([Bitnami Redis](<Redis](https://github.com/bitnami/charts/blob/main/bitnami/redis/Chart.yaml)>))
### Dependency Versioning ### Dependency Versioning
@ -117,6 +119,7 @@ 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-HA](https://hub.docker.com/r/bitnami/postgresql-repmgr/tags)
- [PostgreSQL](https://hub.docker.com/r/bitnami/postgresql/tags) - [PostgreSQL](https://hub.docker.com/r/bitnami/postgresql/tags)
- [Redis Cluster](https://hub.docker.com/r/bitnami/redis-cluster/tags) - [Redis Cluster](https://hub.docker.com/r/bitnami/redis-cluster/tags)
- [Redis](https://hub.docker.com/r/bitnami/redis/tags)
and look up the image tag which fits your needs on Dockerhub. and look up the image tag which fits your needs on Dockerhub.
@ -244,7 +247,7 @@ External tools such as `redis-cluster` or `memcached` handle these workloads muc
If HA is not needed/desired, the following configurations can be used to deploy a single-pod Gitea instance. 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`): 1. For a production-ready single-pod Gitea instance without external dependencies (using the chart dependency `postgresql` and `redis`):
<details> <details>
@ -253,6 +256,8 @@ If HA is not needed/desired, the following configurations can be used to deploy
```yaml ```yaml
redis-cluster: redis-cluster:
enabled: false enabled: false
redis:
enabled: true
postgresql: postgresql:
enabled: true enabled: true
postgresql-ha: postgresql-ha:
@ -265,12 +270,6 @@ If HA is not needed/desired, the following configurations can be used to deploy
config: config:
database: database:
DB_TYPE: postgres DB_TYPE: postgres
session:
PROVIDER: db
cache:
ADAPTER: memory
queue:
TYPE: level
indexer: indexer:
ISSUE_INDEXER_TYPE: bleve ISSUE_INDEXER_TYPE: bleve
REPO_INDEXER_ENABLED: true REPO_INDEXER_ENABLED: true
@ -290,6 +289,8 @@ If HA is not needed/desired, the following configurations can be used to deploy
```yaml ```yaml
redis-cluster: redis-cluster:
enabled: false enabled: false
redis:
enabled: false
postgresql: postgresql:
enabled: false enabled: false
postgresql-ha: postgresql-ha:
@ -1039,13 +1040,26 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
### redis-cluster ### redis-cluster
Redis cluster and [Redis](#redis) cannot be enabled at the same time.
| Name | Description | Value | | Name | Description | Value |
| -------------------------------- | -------------------------------------------- | ------- | | -------------------------------- | -------------------------------------------- | ------- |
| `redis-cluster.enabled` | Enable redis | `true` | | `redis-cluster.enabled` | Enable redis cluster | `true` |
| `redis-cluster.usePassword` | Whether to use password authentication | `false` | | `redis-cluster.usePassword` | Whether to use password authentication | `false` |
| `redis-cluster.cluster.nodes` | Number of redis cluster master nodes | `3` | | `redis-cluster.cluster.nodes` | Number of redis cluster master nodes | `3` |
| `redis-cluster.cluster.replicas` | Number of redis cluster master node replicas | `0` | | `redis-cluster.cluster.replicas` | Number of redis cluster master node replicas | `0` |
### redis
Redis and [Redis cluster](#redis-cluster) cannot be enabled at the same time.
| Name | Description | Value |
| ----------------------------- | ------------------------------------------ | ------------ |
| `redis.enabled` | Enable redis standalone or replicated | `false` |
| `redis.architecture` | Whether to use standalone or replication | `standalone` |
| `redis.global.redis.password` | Required password | `changeme` |
| `redis.master.count` | Number of Redis master instances to deploy | `1` |
### PostgreSQL HA ### PostgreSQL HA
| Name | Description | Value | | Name | Description | Value |

View File

@ -113,20 +113,28 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}} {{- end -}}
{{- define "redis.dns" -}} {{- define "redis.dns" -}}
{{- if (index .Values "redis-cluster").enabled -}} {{- if and ((index .Values "redis-cluster").enabled) ((index .Values "redis").enabled) -}}
{{- fail "redis and redis-cluster cannot be enabled at the same time. Please only choose one." -}}
{{- else if (index .Values "redis-cluster").enabled -}}
{{- printf "redis+cluster://:%s@%s-redis-cluster-headless.%s.svc.%s:%g/0?pool_size=100&idle_timeout=180s&" (index .Values "redis-cluster").global.redis.password .Release.Name .Release.Namespace .Values.clusterDomain (index .Values "redis-cluster").service.ports.redis -}} {{- printf "redis+cluster://:%s@%s-redis-cluster-headless.%s.svc.%s:%g/0?pool_size=100&idle_timeout=180s&" (index .Values "redis-cluster").global.redis.password .Release.Name .Release.Namespace .Values.clusterDomain (index .Values "redis-cluster").service.ports.redis -}}
{{- else if (index .Values "redis").enabled -}}
{{- printf "redis://:%s@%s-redis-headless.%s.svc.%s:%g/0?pool_size=100&idle_timeout=180s&" (index .Values "redis").global.redis.password .Release.Name .Release.Namespace .Values.clusterDomain (index .Values "redis").master.service.ports.redis -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- define "redis.port" -}} {{- define "redis.port" -}}
{{- if (index .Values "redis-cluster").enabled -}} {{- if (index .Values "redis-cluster").enabled -}}
{{ (index .Values "redis-cluster").service.ports.redis }} {{ (index .Values "redis-cluster").service.ports.redis }}
{{- else if (index .Values "redis").enabled -}}
{{ (index .Values "redis").master.service.ports.redis }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- define "redis.servicename" -}} {{- define "redis.servicename" -}}
{{- if (index .Values "redis-cluster").enabled -}} {{- if (index .Values "redis-cluster").enabled -}}
{{- printf "%s-redis-cluster-headless.%s.svc.%s" .Release.Name .Release.Namespace .Values.clusterDomain -}} {{- printf "%s-redis-cluster-headless.%s.svc.%s" .Release.Name .Release.Namespace .Values.clusterDomain -}}
{{- else if (index .Values "redis").enabled -}}
{{- printf "%s-redis-headless.%s.svc.%s" .Release.Name .Release.Namespace .Values.clusterDomain -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
@ -271,7 +279,7 @@ https
{{- $_ := set .Values.gitea.config.metrics "ENABLED" .Values.gitea.metrics.enabled -}} {{- $_ := set .Values.gitea.config.metrics "ENABLED" .Values.gitea.metrics.enabled -}}
{{- end -}} {{- end -}}
{{- /* redis queue */ -}} {{- /* redis queue */ -}}
{{- if (index .Values "redis-cluster").enabled -}} {{- if or ((index .Values "redis-cluster").enabled) ((index .Values "redis").enabled) -}}
{{- $_ := set .Values.gitea.config.queue "TYPE" "redis" -}} {{- $_ := set .Values.gitea.config.queue "TYPE" "redis" -}}
{{- $_ := set .Values.gitea.config.queue "CONN_STR" (include "redis.dns" .) -}} {{- $_ := set .Values.gitea.config.queue "CONN_STR" (include "redis.dns" .) -}}
{{- $_ := set .Values.gitea.config.session "PROVIDER" "redis" -}} {{- $_ := set .Values.gitea.config.session "PROVIDER" "redis" -}}

View File

@ -8,6 +8,8 @@ tests:
set: set:
redis-cluster: redis-cluster:
enabled: true enabled: true
redis:
enabled: false
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
equal: equal:
@ -16,11 +18,28 @@ tests:
ADAPTER=redis ADAPTER=redis
HOST=redis+cluster://:@gitea-unittests-redis-cluster-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s& HOST=redis+cluster://:@gitea-unittests-redis-cluster-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s&
- it: "cache is configured correctly for 'memory' when redis-cluster is disabled" - it: "cache is configured correctly for redis"
template: templates/gitea/config.yaml template: templates/gitea/config.yaml
set: set:
redis-cluster: redis-cluster:
enabled: false enabled: false
redis:
enabled: true
asserts:
- documentIndex: 0
equal:
path: stringData.cache
value: |-
ADAPTER=redis
HOST=redis://:changeme@gitea-unittests-redis-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s&
- it: "cache is configured correctly for 'memory' when redis (or redis-cluster) is disabled"
template: templates/gitea/config.yaml
set:
redis-cluster:
enabled: false
redis:
enabled: false
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
equal: equal:
@ -29,11 +48,13 @@ tests:
ADAPTER=memory ADAPTER=memory
HOST= HOST=
- it: "cache can be customized when redis-cluster is disabled" - it: "cache can be customized when redis (or redis-cluster) is disabled"
template: templates/gitea/config.yaml template: templates/gitea/config.yaml
set: set:
redis-cluster: redis-cluster:
enabled: false enabled: false
redis:
enabled: false
gitea.config.cache.ADAPTER: custom-adapter gitea.config.cache.ADAPTER: custom-adapter
gitea.config.cache.HOST: custom-host gitea.config.cache.HOST: custom-host
asserts: asserts:

View File

@ -8,6 +8,8 @@ tests:
set: set:
redis-cluster: redis-cluster:
enabled: true enabled: true
redis:
enabled: false
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
equal: equal:
@ -16,11 +18,28 @@ tests:
CONN_STR=redis+cluster://:@gitea-unittests-redis-cluster-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s& CONN_STR=redis+cluster://:@gitea-unittests-redis-cluster-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s&
TYPE=redis TYPE=redis
- it: "queue is configured correctly for 'levelDB' when redis-cluster is disabled" - it: "queue is configured correctly for redis"
template: templates/gitea/config.yaml template: templates/gitea/config.yaml
set: set:
redis-cluster: redis-cluster:
enabled: false enabled: false
redis:
enabled: true
asserts:
- documentIndex: 0
equal:
path: stringData.queue
value: |-
CONN_STR=redis://:changeme@gitea-unittests-redis-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s&
TYPE=redis
- it: "queue is configured correctly for 'levelDB' when redis (and redis-cluster) is disabled"
template: templates/gitea/config.yaml
set:
redis-cluster:
enabled: false
redis:
enabled: false
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
equal: equal:
@ -29,11 +48,13 @@ tests:
CONN_STR= CONN_STR=
TYPE=level TYPE=level
- it: "queue can be customized when redis-cluster is disabled" - it: "queue can be customized when redis (and redis-cluster) are disabled"
template: templates/gitea/config.yaml template: templates/gitea/config.yaml
set: set:
redis-cluster: redis-cluster:
enabled: false enabled: false
redis:
enabled: false
gitea.config.queue.TYPE: custom-type gitea.config.queue.TYPE: custom-type
gitea.config.queue.CONN_STR: custom-connection-string gitea.config.queue.CONN_STR: custom-connection-string
asserts: asserts:

View File

@ -8,6 +8,8 @@ tests:
set: set:
redis-cluster: redis-cluster:
enabled: true enabled: true
redis:
enabled: false
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
equal: equal:
@ -16,11 +18,28 @@ tests:
PROVIDER=redis PROVIDER=redis
PROVIDER_CONFIG=redis+cluster://:@gitea-unittests-redis-cluster-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s& PROVIDER_CONFIG=redis+cluster://:@gitea-unittests-redis-cluster-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s&
- it: "session is configured correctly for 'memory' when redis-cluster is disabled" - it: "session is configured correctly for redis"
template: templates/gitea/config.yaml template: templates/gitea/config.yaml
set: set:
redis-cluster: redis-cluster:
enabled: false enabled: false
redis:
enabled: true
asserts:
- documentIndex: 0
equal:
path: stringData.session
value: |-
PROVIDER=redis
PROVIDER_CONFIG=redis://:changeme@gitea-unittests-redis-headless.testing.svc.cluster.local:6379/0?pool_size=100&idle_timeout=180s&
- it: "session is configured correctly for 'memory' when redis (and redis-cluster) is disabled"
template: templates/gitea/config.yaml
set:
redis-cluster:
enabled: false
redis:
enabled: false
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
equal: equal:
@ -29,11 +48,13 @@ tests:
PROVIDER=memory PROVIDER=memory
PROVIDER_CONFIG= PROVIDER_CONFIG=
- it: "session can be customized when redis-cluster is disabled" - it: "session can be customized when redis (and redis-cluster) is disabled"
template: templates/gitea/config.yaml template: templates/gitea/config.yaml
set: set:
redis-cluster: redis-cluster:
enabled: false enabled: false
redis:
enabled: false
gitea.config.session.PROVIDER: custom-provider gitea.config.session.PROVIDER: custom-provider
gitea.config.session.PROVIDER_CONFIG: custom-provider-config gitea.config.session.PROVIDER_CONFIG: custom-provider-config
asserts: asserts:

View File

@ -34,9 +34,24 @@ tests:
set: set:
redis-cluster: redis-cluster:
enabled: true enabled: true
redis:
enabled: false
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
matchRegex: matchRegex:
path: spec.template.spec.containers[0].image path: spec.template.spec.containers[0].image
# IN CASE OF AN INTENTIONAL MAJOR BUMP, ADJUST THIS TEST # IN CASE OF AN INTENTIONAL MAJOR BUMP, ADJUST THIS TEST
pattern: bitnami/redis-cluster:7.+$ pattern: bitnami/redis-cluster:7.+$
- it: "[redis] ensures we detect major image version upgrades"
template: charts/redis/templates/master/application.yaml
set:
redis-cluster:
enabled: false
redis:
enabled: true
asserts:
- documentIndex: 0
matchRegex:
path: spec.template.spec.containers[0].image
# IN CASE OF AN INTENTIONAL MAJOR BUMP, ADJUST THIS TEST
pattern: bitnami/redis:7.+$

View File

@ -0,0 +1,14 @@
suite: Values conflicting checks
release:
name: gitea-unittests
namespace: testing
tests:
- it: fails when trying to configure redis and redis-cluster the same time
set:
redis-cluster:
enabled: true
redis:
enabled: true
asserts:
- failedTemplate:
errorMessage: redis and redis-cluster cannot be enabled at the same time. Please only choose one.

View File

@ -481,10 +481,13 @@ gitea:
failureThreshold: 10 failureThreshold: 10
## @section redis-cluster ## @section redis-cluster
## @param redis-cluster.enabled Enable redis ## @param redis-cluster.enabled Enable redis cluster
## @param redis-cluster.usePassword Whether to use password authentication ## @param redis-cluster.usePassword Whether to use password authentication
## @param redis-cluster.cluster.nodes Number of redis cluster master nodes ## @param redis-cluster.cluster.nodes Number of redis cluster master nodes
## @param redis-cluster.cluster.replicas Number of redis cluster master node replicas ## @param redis-cluster.cluster.replicas Number of redis cluster master node replicas
## @descriptionStart
## Redis cluster and [Redis](#redis) cannot be enabled at the same time.
## @descriptionEnd
redis-cluster: redis-cluster:
enabled: true enabled: true
usePassword: false usePassword: false
@ -492,6 +495,23 @@ redis-cluster:
nodes: 3 # default: 6 nodes: 3 # default: 6
replicas: 0 # default: 1 replicas: 0 # default: 1
## @section redis
## @param redis.enabled Enable redis standalone or replicated
## @param redis.architecture Whether to use standalone or replication
## @param redis.global.redis.password Required password
## @param redis.master.count Number of Redis master instances to deploy
## @descriptionStart
## Redis and [Redis cluster](#redis-cluster) cannot be enabled at the same time.
## @descriptionEnd
redis:
enabled: false
architecture: standalone
global:
redis:
password: changeme
master:
count: 1
## @section PostgreSQL HA ## @section PostgreSQL HA
# #
## @param postgresql-ha.enabled Enable PostgreSQL HA ## @param postgresql-ha.enabled Enable PostgreSQL HA