Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(argo-cd): Add ability to use an external redis instance #1150

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ jobs:
## Metrics API not available in kind cluster
rm charts/argo-cd/ci/ha-autoscaling-values.yaml

- name: Create an external redis for ArgoCD externalRedis feature
if: contains(steps.list-changed.outputs.changed_charts, 'argo-cd')
run: |
kubectl create namespace redis
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install redis bitnami/redis --wait --namespace redis --set auth.password=argocd --set architecture=standalone

- name: Run chart-testing (install)
run: ct install --config ./.github/configs/ct-install.yaml
if: steps.list-changed.outputs.changed == 'true'
4 changes: 2 additions & 2 deletions charts/argo-cd/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: v2.3.3
description: A Helm chart for Argo CD, a declarative, GitOps continuous delivery tool for Kubernetes.
name: argo-cd
version: 4.3.2
version: 4.4.0
home: https://github.com/argoproj/argo-helm
icon: https://argo-cd.readthedocs.io/en/stable/assets/logo.png
keywords:
Expand All @@ -21,4 +21,4 @@ dependencies:
condition: redis-ha.enabled
annotations:
artifacthub.io/changes: |
- "[Fixed]: Upgrade dex to v2.30.2"
- "[Added]: Ability to use external/existing Redis (eg. a managed cloud service)"
4 changes: 4 additions & 0 deletions charts/argo-cd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ NAME: my-release
| redis-ha.redis.config | object | See [values.yaml] | Any valid redis config options in this section will be applied to each server (see `redis-ha` chart) |
| redis-ha.redis.config.save | string | `"\"\""` | Will save the DB if both the given number of seconds and the given number of write operations against the DB occurred. `""` is disabled |
| redis-ha.redis.masterGroupName | string | `"argocd"` | Redis convention for naming the cluster group: must match `^[\\w-\\.]+$` and can be templated |
| externalRedis.existingSecret | string | `""` | The name of an existing secret with Redis credentials (must contain key `redis-password`). When it's set, the `externalRedis.password` parameter is ignored |
| externalRedis.host | string | `""` | External Redis server host |
| externalRedis.password | string | `""` | External Redis password |
| externalRedis.port | int | `6379` | External Redis server port |

## ApplicationSet

Expand Down
7 changes: 6 additions & 1 deletion charts/argo-cd/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ NAME: my-release
| Key | Type | Default | Description |
|-----|------|---------|-------------|
{{- range .Values }}
{{- if not (or (hasPrefix "controller" .Key) (hasPrefix "repoServer" .Key) (hasPrefix "server" .Key) (hasPrefix "dex" .Key) (hasPrefix "redis" .Key) (hasPrefix "applicationSet" .Key) (hasPrefix "notifications" .Key) ) }}
{{- if not (or (hasPrefix "controller" .Key) (hasPrefix "repoServer" .Key) (hasPrefix "server" .Key) (hasPrefix "dex" .Key) (hasPrefix "redis" .Key) (hasPrefix "externalRedis" .Key) (hasPrefix "applicationSet" .Key) (hasPrefix "notifications" .Key) ) }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- if hasPrefix "server.additional" .Key }}
Expand Down Expand Up @@ -260,6 +260,11 @@ NAME: my-release
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}
{{- range .Values }}
{{- if hasPrefix "externalRedis" .Key }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

## ApplicationSet

Expand Down
9 changes: 9 additions & 0 deletions charts/argo-cd/ci/external-redis-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
redis:
enabled: false

redis-ha:
enabled: false

externalRedis:
host: "redis-master.redis.svc.cluster.local"
password: "argocd"
14 changes: 14 additions & 0 deletions charts/argo-cd/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,17 @@ Create the name of the configmap to use
{{ default "argocd-notifications-cm" .Values.notifications.cm.name }}
{{- end -}}
{{- end -}}

{{- define "argo-cd.redisPasswordEnv" -}}
{{- if or .Values.externalRedis.password .Values.externalRedis.existingSecret }}
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.externalRedis.existingSecret }}
name: {{ .Values.externalRedis.existingSecret }}
{{- else }}
name: {{ template "argo-cd.redis.fullname" . }}
{{- end }}
key: redis-password
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ spec:
{{- if or (and .Values.redis.enabled (not $redisHa.enabled)) (and $redisHa.enabled $redisHa.haproxy.enabled) }}
- --redis
- {{ template "argo-cd.redis.fullname" . }}:{{ .Values.redis.servicePort }}
{{- else if and .Values.externalRedis.host .Values.externalRedis.port }}
- --redis
- {{ .Values.externalRedis.host }}:{{ .Values.externalRedis.port }}
{{- end }}
{{- with .Values.controller.extraArgs }}
{{- . | toYaml | nindent 8 }}
Expand All @@ -75,9 +78,12 @@ spec:
{{- if .Values.controller.containerSecurityContext }}
securityContext: {{- toYaml .Values.controller.containerSecurityContext | nindent 10 }}
{{- end }}
{{- if .Values.controller.env }}
{{- if or .Values.controller.env .Values.externalRedis.password .Values.externalRedis.existingSecret }}
env:
{{- toYaml .Values.controller.env | nindent 8 }}
{{- include "argo-cd.redisPasswordEnv" . | nindent 8 }}
{{- with .Values.controller.env }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.controller.envFrom }}
envFrom: {{- toYaml . | nindent 8 }}
Expand Down
11 changes: 11 additions & 0 deletions charts/argo-cd/templates/argocd-configs/externalredis-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if and .Values.externalRedis.password (not .Values.externalRedis.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "argo-cd.redis.fullname" . }}
labels:
{{- include "argo-cd.labels" (dict "context" $) | nindent 4 }}
type: Opaque
data:
redis-password: {{ .Values.externalRedis.password | b64enc }}
{{- end }}
10 changes: 7 additions & 3 deletions charts/argo-cd/templates/argocd-repo-server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ spec:
{{- if or (and .Values.redis.enabled (not $redisHa.enabled)) (and $redisHa.enabled $redisHa.haproxy.enabled) }}
- --redis
- {{ template "argo-cd.redis.fullname" . }}:{{ .Values.redis.servicePort }}
{{- else if and .Values.externalRedis.host .Values.externalRedis.port }}
- --redis
- {{ .Values.externalRedis.host }}:{{ .Values.externalRedis.port }}
{{- end }}
- --logformat
- {{ .Values.repoServer.logFormat }}
Expand All @@ -65,9 +68,10 @@ spec:
value: /helm-working-dir
- name: HELM_DATA_HOME
value: /helm-working-dir
{{- if .Values.repoServer.env }}
{{- toYaml .Values.repoServer.env | nindent 8 }}
{{- end }}
{{- include "argo-cd.redisPasswordEnv" . | nindent 8 }}
{{- with .Values.repoServer.env }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.openshift.enabled }}
- name: USER_NAME
value: argocd
Expand Down
10 changes: 8 additions & 2 deletions charts/argo-cd/templates/argocd-server/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,22 @@ spec:
{{- if or (and .Values.redis.enabled (not $redisHa.enabled)) (and $redisHa.enabled $redisHa.haproxy.enabled) }}
- --redis
- {{ template "argo-cd.redis.fullname" . }}:{{ .Values.redis.servicePort }}
{{- else if and .Values.externalRedis.host .Values.externalRedis.port }}
- --redis
- {{ .Values.externalRedis.host }}:{{ .Values.externalRedis.port }}
{{- end }}
{{- with .Values.server.extraArgs }}
{{- . | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.server.containerSecurityContext }}
securityContext: {{- toYaml .Values.server.containerSecurityContext | nindent 10 }}
{{- end }}
{{- if .Values.server.env }}
{{- if or .Values.server.env .Values.externalRedis.password .Values.externalRedis.existingSecret }}
env:
{{- toYaml .Values.server.env | nindent 8 }}
{{- include "argo-cd.redisPasswordEnv" . | nindent 8 }}
{{- with .Values.server.env }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.server.envFrom }}
envFrom: {{- toYaml . | nindent 8 }}
Expand Down
12 changes: 12 additions & 0 deletions charts/argo-cd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,18 @@ redis-ha:
# -- Redis tag
tag: 6.2.6-alpine

# External Redis parameters
externalRedis:
# -- External Redis server host
host: ""
# -- External Redis password
password: ""
# -- External Redis server port
port: 6379
# -- The name of an existing secret with Redis credentials (must contain key `redis-password`).
# When it's set, the `externalRedis.password` parameter is ignored
existingSecret: ""

## Server
server:
# -- Argo CD server name
Expand Down