add redis-cluster support

This commit is contained in:
Lucas Hahn 2021-07-09 16:39:56 +02:00
parent b456d07c45
commit 346a1d316b
4 changed files with 65 additions and 3 deletions

View File

@ -38,6 +38,10 @@ dependencies:
repository: https://charts.bitnami.com/bitnami
version: 6.2.3
condition: redis-cluster.enabled
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 14.6.6
condition: redis.enabled
- name: mysql
repository: https://charts.bitnami.com/bitnami
version: 6.14.10

View File

@ -112,7 +112,27 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- define "redis.dns" -}}
{{- printf "redis://%s-redis-cluster.%s.svc.%s:%g/0?pool_size=100&idle_timeout=180s" .Release.Name .Release.Namespace .Values.clusterDomain (index .Values "redis-cluster").service.port -}}
{{- if (index .Values "redis-cluster").enabled -}}
{{- printf "redis://:%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.port -}}
{{- else if .Values.redis.enabled -}}
{{- printf "redis://:%s@%s-redis-master.%s.svc.%s:%g/0?pool_size=100&idle_timeout=180s" .Values.redis.global.redis.password .Release.Name .Release.Namespace .Values.clusterDomain .Values.redis.master.service.port -}}
{{- end -}}
{{- end -}}
{{- define "redis.port" -}}
{{- if (index .Values "redis-cluster").enabled -}}
{{ (index .Values "redis-cluster").service.port }}
{{- else if .Values.redis.enabled -}}
{{ .Values.redis.master.service.port }}
{{- end -}}
{{- end -}}
{{- define "redis.servicename" -}}
{{- if (index .Values "redis-cluster").enabled -}}
{{- printf "%s-redis-cluster-headless.%s.svc.%s" .Release.Name .Release.Namespace .Values.clusterDomain -}}
{{- else if .Values.redis.enabled -}}
{{- printf "%s-redis-master.%s.svc.%s" .Release.Name .Release.Namespace .Values.clusterDomain -}}
{{- end -}}
{{- end -}}
{{- define "gitea.default_domain" -}}

View File

@ -60,6 +60,27 @@ stringData:
test_db_connection
{{- end }}
{{- if include "redis.servicename" . }}
function test_redis_connection() {
local RETRY=0
local MAX=30
echo 'Wait for redis to become avialable...'
until [ "${RETRY}" -ge "${MAX}" ]; do
nc -vz -w2 {{ include "redis.servicename" . }} {{ include "redis.port" . }} && break
RETRY=$[${RETRY}+1]
echo "...not ready yet (${RETRY}/${MAX})"
done
if [ "${RETRY}" -ge "${MAX}" ]; then
echo "Redis not reachable after '${MAX}' attempts!"
exit 1
fi
}
test_redis_connection
{{- end }}
echo '==== BEGIN GITEA CONFIGURATION ===='
gitea migrate

View File

@ -2,7 +2,7 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 2
replicaCount: 1
clusterDomain: cluster.local
@ -114,10 +114,16 @@ statefulset:
persistence:
enabled: true
existingClaim: gitea-data-test
# existingClaim:
size: 10Gi
accessModes:
- ReadWriteOnce
labels: {}
annotations: {}
# storageClass:
# subPath:
# additional volumes to add to the Gitea statefulset.
extraVolumes:
# - name: postgres-ssl-vol
@ -245,6 +251,17 @@ memcached:
service:
port: 11211
redis:
enabled: false
global:
redis:
password: gitea
master:
service:
port: 6379
replica:
replicaCount: 2
redis-cluster:
enabled: false
global: