Skip to content

Commit ba83309

Browse files
More options for elasticsearch secret creation
Sometimes you don't want to include secret data in Git manifest for security reasons, e.g. when storing manifests in Git and deploying with ArgoCD. However, you may still want to generate a secret itself and then edit it's data section later, e.g. manually with kubectl. Provide more options of generating the secret while keeping backwards compatibility. Helps with: apache#45140 Signed-off-by: Andrii Korotkov <[email protected]>
1 parent 279f1fa commit ba83309

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

chart/templates/secrets/elasticsearch-secret.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
################################
2121
## Elasticsearch Secret
2222
#################################
23-
{{- if (and .Values.elasticsearch.enabled (not .Values.elasticsearch.secretName)) }}
23+
{{- if (and .Values.elasticsearch.enabled (or (not .Values.elasticsearch.secretName) .Values.elasticsearch.alwaysGenerateSecret)) }}
2424
apiVersion: v1
2525
kind: Secret
2626
metadata:
27-
name: {{ include "airflow.fullname" . }}-elasticsearch
27+
name: {{ template "elasticsearch_secret" . }}
2828
labels:
2929
release: {{ .Release.Name }}
3030
chart: {{ .Chart.Name }}
@@ -33,12 +33,14 @@ metadata:
3333
{{- toYaml . | nindent 4 }}
3434
{{- end }}
3535
type: Opaque
36+
{{- with .Values.elasticsearch.connection }}
37+
{{- if . }}
3638
data:
37-
{{- with .Values.elasticsearch.connection }}
38-
{{- if and .user .pass }}
39-
connection: {{ urlJoin (dict "scheme" (default "http" .scheme) "userinfo" (printf "%s:%s" (.user | urlquery) (.pass | urlquery)) "host" (printf "%s:%s" .host ((default 9200 .port) | toString) ) ) | b64enc | quote }}
40-
{{- else }}
41-
connection: {{ urlJoin (dict "scheme" (default "http" .scheme) "host" (printf "%s:%s" .host ((default 9200 .port) | toString))) | b64enc | quote }}
42-
{{- end }}
39+
{{- if and .user .pass }}
40+
connection: {{ urlJoin (dict "scheme" (default "http" .scheme) "userinfo" (printf "%s:%s" (.user | urlquery) (.pass | urlquery)) "host" (printf "%s:%s" .host ((default 9200 .port) | toString) ) ) | b64enc | quote }}
41+
{{- else }}
42+
connection: {{ urlJoin (dict "scheme" (default "http" .scheme) "host" (printf "%s:%s" .host ((default 9200 .port) | toString))) | b64enc | quote }}
4343
{{- end }}
4444
{{- end }}
45+
{{- end }}
46+
{{- end }}

chart/values.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8000,6 +8000,11 @@
80008000
],
80018001
"default": null
80028002
},
8003+
"alwaysGenerateSecret": {
8004+
"description": "Whether to generate a secret even if secretName is specified.",
8005+
"type": "boolean",
8006+
"default": false
8007+
},
80038008
"connection": {
80048009
"description": "Elasticsearch connection configuration.",
80058010
"type": "object",

chart/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,6 +2463,8 @@ elasticsearch:
24632463
enabled: false
24642464
# A secret containing the connection
24652465
secretName: ~
2466+
# Whether to generate a secret even if secretName is specified
2467+
alwaysGenerateSecret: false
24662468
# Or an object representing the connection
24672469
# Example:
24682470
# connection:

0 commit comments

Comments
 (0)