From 68960be0b319c841965426520a69e46de47cab8c Mon Sep 17 00:00:00 2001 From: Philipp Born Date: Sat, 9 Dec 2023 13:08:49 +0100 Subject: [PATCH] include redis-ha --- charts/traccar/Chart.lock | 7 +++++-- charts/traccar/Chart.yaml | 4 ++++ charts/traccar/ci/ha-with-redis-values.yaml | 16 ++++++++++++++++ charts/traccar/templates/configmap.yaml | 4 ++++ charts/traccar/templates/deployment.yaml | 17 +++++++++++++++-- charts/traccar/values.yaml | 15 ++++++++++++++- ct.yaml | 1 + 7 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 charts/traccar/ci/ha-with-redis-values.yaml diff --git a/charts/traccar/Chart.lock b/charts/traccar/Chart.lock index a0425c1..252512f 100644 --- a/charts/traccar/Chart.lock +++ b/charts/traccar/Chart.lock @@ -2,5 +2,8 @@ dependencies: - name: mysql repository: https://charts.bitnami.com/bitnami version: 9.4.8 -digest: sha256:c54ca45ec9055b33d96c582be62d5c4afd9501f2edfee0afaa73876b7ae13cfa -generated: "2023-01-28T11:57:35.495179799+01:00" +- name: redis-ha + repository: https://dandydeveloper.github.io/charts + version: 4.23.0 +digest: sha256:91b7dd321c826a5721204763f11ac8a641c60cc23690250ca2eecd8c368cdac8 +generated: "2023-12-09T13:20:23.900368+01:00" diff --git a/charts/traccar/Chart.yaml b/charts/traccar/Chart.yaml index a319688..4788553 100644 --- a/charts/traccar/Chart.yaml +++ b/charts/traccar/Chart.yaml @@ -9,6 +9,10 @@ dependencies: version: 9.4.8 repository: https://charts.bitnami.com/bitnami condition: mysql.enabled + - name: redis-ha + version: 4.23.0 + repository: https://dandydeveloper.github.io/charts + condition: redis-ha.enabled maintainers: - email: laszlo.kondas@gmail.com name: kondas diff --git a/charts/traccar/ci/ha-with-redis-values.yaml b/charts/traccar/ci/ha-with-redis-values.yaml new file mode 100644 index 0000000..e8d7bf6 --- /dev/null +++ b/charts/traccar/ci/ha-with-redis-values.yaml @@ -0,0 +1,16 @@ +replicaCount: 2 + +deploymentStrategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + +redis-ha: + enabled: true + # defaults to 3. but we wan't CI to run through in a reasonable time. + replicas: 1 + haproxy: + replicas: 1 + hardAntiAffinity: false + hardAntiAffinity: false diff --git a/charts/traccar/templates/configmap.yaml b/charts/traccar/templates/configmap.yaml index e625dd9..021584a 100644 --- a/charts/traccar/templates/configmap.yaml +++ b/charts/traccar/templates/configmap.yaml @@ -401,6 +401,10 @@ data: {{ .Values.traccar.notificator.telegram.sendLocation }} {{- end }} {{- end }} +{{- end }} +{{- if (index .Values "redis-ha").enabled }} + redis + redis://{{ include "traccar.fullname" . }}-redis-ha-haproxy:6379 {{- end }} {{- end }} diff --git a/charts/traccar/templates/deployment.yaml b/charts/traccar/templates/deployment.yaml index c8e903e..ad32c3b 100644 --- a/charts/traccar/templates/deployment.yaml +++ b/charts/traccar/templates/deployment.yaml @@ -36,13 +36,13 @@ spec: - name: config configMap: name: {{ include "traccar.fullname" . }} -{{- if or .Values.mysql.enabled .Values.initContainers }} +{{- if or .Values.mysql.enabled (index .Values "redis-ha").enabled .Values.initContainers }} initContainers: {{- if .Values.mysql.enabled }} - name: wait-for-db securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "alpine:3.6" + image: "alpine:3.19" command: - 'sh' - '-c' @@ -51,6 +51,19 @@ spec: do sleep 2; done {{- end }} +{{- if (index .Values "redis-ha").enabled }} + - name: wait-for-redis + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "alpine:3.19" + command: + - 'sh' + - '-c' + - > + until nc -z -w 2 {{ include "traccar.fullname" . }}-redis-master 6379 && echo redis ok; + do sleep 2; + done +{{- end }} {{- with .Values.initContainers }} {{- if eq (typeOf .) "string" }} {{- tpl . $ | nindent 8 }} diff --git a/charts/traccar/values.yaml b/charts/traccar/values.yaml index 9b5c5fe..788aa87 100644 --- a/charts/traccar/values.yaml +++ b/charts/traccar/values.yaml @@ -116,7 +116,8 @@ mysql: enabled: false # NOTE: When using multiple replicas, you must configure broadcast.type and broadcast.address -# This must be done via configOverride. See https://www.traccar.org/configuration-file/#:~:text=attributes%20to%20log.-,broadcast.type,-config +# This can be done via configOverride. See https://www.traccar.org/configuration-file/#:~:text=attributes%20to%20log.-,broadcast.type,-config +# Or by setting redis.enabled=true replicaCount: 1 deploymentStrategy: @@ -907,3 +908,15 @@ nodeSelector: tolerations: [] affinity: {} + +redis-ha: + # enables the redis subchart + enabled: false + persistentVolume: + enabled: false + redis: + masterGroupName: traccar + config: + save: '""' + haproxy: + enabled: true diff --git a/ct.yaml b/ct.yaml index 1ae8f4e..3e486cf 100644 --- a/ct.yaml +++ b/ct.yaml @@ -5,4 +5,5 @@ chart-dirs: - charts chart-repos: - bitnami=https://charts.bitnami.com/bitnami + - dandydeveloper=https://dandydeveloper.github.io/charts helm-extra-args: --timeout 600s