fix(argo-cd): Make code clearer when Redis Secret is optional (#3228)
This commit is contained in:
parent
eb0f0af836
commit
9365ba1dd2
6 changed files with 48 additions and 42 deletions
|
|
@ -275,3 +275,41 @@ ipFamilyPolicy: {{ . }}
|
|||
ipFamilies: {{ toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
secretKeyRef of env variable REDIS_USERNAME
|
||||
*/}}
|
||||
{{- define "argo-cd.redisUsernameSecretRef" -}}
|
||||
{{- if and .Values.externalRedis.host -}}
|
||||
name: {{ default (include "argo-cd.redis.fullname" .) .Values.externalRedis.existingSecret }}
|
||||
key: redis-username
|
||||
optional: true
|
||||
{{- else -}}
|
||||
name: {{ include "argo-cd.redis.fullname" . }}
|
||||
key: redis-username
|
||||
optional: true
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
secretKeyRef of env variable REDIS_PASSWORD
|
||||
*/}}
|
||||
{{- define "argo-cd.redisPasswordSecretRef" -}}
|
||||
{{- if and .Values.redisSecretInit.enabled (not .Values.externalRedis.host) -}}
|
||||
{{- /* Default case where Secret is generated by the Job with Helm pre-install hooks */ -}}
|
||||
name: "argocd-redis" # hard-coded in Job command "argocd admin redis-initial-password"
|
||||
key: auth
|
||||
optional: false # Secret is not optional in this case !
|
||||
{{- else if .Values.externalRedis.host -}}
|
||||
{{- /* External Redis use case */ -}}
|
||||
{{- /* Secret is required when specifying existingSecret, otherwise it is optional */ -}}
|
||||
name: {{ default (include "argo-cd.redis.fullname" .) .Values.externalRedis.existingSecret }}
|
||||
key: redis-password
|
||||
optional: {{ if .Values.externalRedis.existingSecret }}false{{ else }}true{{ end }}
|
||||
{{- else -}}
|
||||
{{- /* All other use cases (e.g. disabled pre-install Job) */ -}}
|
||||
name: {{ include "argo-cd.redis.fullname" . }}
|
||||
key: redis-password
|
||||
optional: true
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
|||
|
|
@ -226,19 +226,11 @@ spec:
|
|||
- name: REDIS_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ default "argocd-redis" .Values.externalRedis.existingSecret }}
|
||||
key: redis-username
|
||||
optional: true
|
||||
{{- include "argo-cd.redisUsernameSecretRef" . | nindent 16 }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ default "argocd-redis" .Values.externalRedis.existingSecret }}
|
||||
{{- if .Values.externalRedis.host }}
|
||||
key: redis-password
|
||||
{{- else }}
|
||||
key: auth
|
||||
{{- end }}
|
||||
optional: true
|
||||
{{- include "argo-cd.redisPasswordSecretRef" . | nindent 16 }}
|
||||
- name: REDIS_SENTINEL_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
|
|
|||
|
|
@ -225,19 +225,11 @@ spec:
|
|||
- name: REDIS_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ default "argocd-redis" .Values.externalRedis.existingSecret }}
|
||||
key: redis-username
|
||||
optional: true
|
||||
{{- include "argo-cd.redisUsernameSecretRef" . | nindent 16 }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ default "argocd-redis" .Values.externalRedis.existingSecret }}
|
||||
{{- if .Values.externalRedis.host }}
|
||||
key: redis-password
|
||||
{{- else }}
|
||||
key: auth
|
||||
{{- end }}
|
||||
optional: true
|
||||
{{- include "argo-cd.redisPasswordSecretRef" . | nindent 16 }}
|
||||
- name: REDIS_SENTINEL_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
|
|
|||
|
|
@ -178,19 +178,11 @@ spec:
|
|||
- name: REDIS_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ default "argocd-redis" .Values.externalRedis.existingSecret }}
|
||||
key: redis-username
|
||||
optional: true
|
||||
{{- include "argo-cd.redisUsernameSecretRef" . | nindent 16 }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ default "argocd-redis" .Values.externalRedis.existingSecret }}
|
||||
{{- if .Values.externalRedis.host }}
|
||||
key: redis-password
|
||||
{{- else }}
|
||||
key: auth
|
||||
{{- end }}
|
||||
optional: true
|
||||
{{- include "argo-cd.redisPasswordSecretRef" . | nindent 16 }}
|
||||
- name: REDIS_SENTINEL_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
|
|
|||
|
|
@ -246,19 +246,11 @@ spec:
|
|||
- name: REDIS_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ default "argocd-redis" .Values.externalRedis.existingSecret }}
|
||||
key: redis-username
|
||||
optional: true
|
||||
{{- include "argo-cd.redisUsernameSecretRef" . | nindent 16 }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ default "argocd-redis" .Values.externalRedis.existingSecret }}
|
||||
{{- if .Values.externalRedis.host }}
|
||||
key: redis-password
|
||||
{{- else }}
|
||||
key: auth
|
||||
{{- end }}
|
||||
optional: true
|
||||
{{- include "argo-cd.redisPasswordSecretRef" . | nindent 16 }}
|
||||
- name: REDIS_SENTINEL_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue