-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 authentication for builtin Redis #2616
Open
afrimberger
wants to merge
3
commits into
argoproj:main
Choose a base branch
from
afrimberger:feature/redis-auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+157
−2
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{{- $redisHa := index .Values "redis-ha" -}} | ||
{{- if and .Values.redis.enabled (or .Values.redis.auth.enabled .Values.redis.extraConfig) (not $redisHa.enabled) -}} | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: "{{ include "argo-cd.redis.fullname" . }}-config" | ||
namespace: {{ .Release.Namespace | quote }} | ||
labels: | ||
{{- include "argo-cd.labels" (dict "context" . "component" .Values.redis.name "name" .Values.redis.name) | nindent 4 }} | ||
{{- with .Values.redis.auth.secretAnnotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
data: | ||
{{- if or .Values.redis.auth.enabled .Values.redis.extraConfig }} | ||
redis.conf: | | ||
{{- if .Values.redis.auth.enabled }} | ||
aclfile /etc/redis/users.acl | ||
{{- end }} | ||
{{- .Values.redis.extraConfig | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# lookup existing secret | ||
{{- $secretName := include "argo-cd.redis.fullname" . -}} | ||
{{- $secretObj := (lookup "v1" "Secret" .Release.Namespace $secretName) | default dict }} | ||
{{- $secretData := (get $secretObj "data") | default dict }} | ||
# generate random password if secret doesn't exist | ||
{{- $defaultUserPassword := (get $secretData "redis-password-default") | default (randAlphaNum 48 | b64enc) }} | ||
{{- $adminUserPassword := (get $secretData "redis-password-admin") | default (randAlphaNum 48 | b64enc) }} | ||
{{- $argoUserPassword := (get $secretData "redis-password") | default (randAlphaNum 48 | b64enc) }} | ||
{{- if .Values.redis.auth.enabled }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ $secretName }} | ||
namespace: {{ .Release.Namespace | quote }} | ||
labels: | ||
{{- include "argo-cd.labels" (dict "context" . "component" .Values.redis.name "name" .Values.redis.name) | nindent 4 }} | ||
{{- with .Values.redis.auth.secretAnnotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
type: Opaque | ||
immutable: true | ||
data: | ||
redis-username-default: {{ "default" | b64enc }} | ||
redis-password-default: {{ $defaultUserPassword | quote }} | ||
|
||
redis-username-admin: {{ "admin" | b64enc }} | ||
redis-password-admin: {{ $adminUserPassword | quote }} | ||
|
||
{{- with .Values.redis.auth.username }} | ||
redis-username: {{ . | b64enc }} | ||
{{- end }} | ||
redis-password: {{ $argoUserPassword | quote }} | ||
{{- end }} | ||
|
||
{{- $redisHa := index .Values "redis-ha" -}} | ||
{{- if and .Values.redis.enabled .Values.redis.auth.enabled (not $redisHa.enabled) }} | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: "{{ include "argo-cd.redis.fullname" . }}-users" | ||
namespace: {{ .Release.Namespace | quote }} | ||
labels: | ||
{{- include "argo-cd.labels" (dict "context" . "component" .Values.redis.name "name" .Values.redis.name) | nindent 4 }} | ||
{{- with .Values.redis.auth.secretAnnotations }} | ||
annotations: | ||
{{- range $key, $value := . }} | ||
{{ $key }}: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
stringData: | ||
users.acl: | | ||
user default on +@all -@admin -@dangerous ~* &* >{{ $defaultUserPassword | b64dec }} | ||
user admin on +@all -@admin -@dangerous ~* &* >{{ $adminUserPassword | b64dec }} | ||
user {{ .Values.redis.auth.username }} on +@all ~* &* >{{ $argoUserPassword | b64dec }} | ||
|
||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using lookup inside the Argo ecosystem is IMHO a bad idea. Argo CD uses helm only as a template engine (argocd only executes
helm template ...
).And
helm template
does not support looking up values for security reasons.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mkilchhofer, Thanks for bringing up this topic! If we're talking about ArgoCD in general, I fully agree. However, in this particular case the Helm Chart is meant for bootstrapping ArgoCD. Basically, this can be achieved in two ways:
ignoreDifferences
for the password fields needs to be specifiedI would really love to see a more secure default installation of ArgoCD. Especially, because not all clusters support
NetworkPolicies
out of the box (e.g. Flannel doesn't).I suggest to add an example for
ignoreDifferences
and some explanation to the README to address the questions arising by using lookup. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean changing the default installation without being in-line with with upstrean kustomize manifests is not what we want.
Upstream is our reference for the default installation as mentioned in the charts README.
I appreciate a more secure default installation but it has to be promoted first as a PR in the upstream repo (https://github.com/argoproj/argo-cd).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Chart's README:
According to this, the default should be
redis.auth.enabled=false
(as it is in the current implementation). Additionally, a user can easily enable a more secure installation by settingredis.auth.enabled
totrue
.Sounds reasonable to me.