Skip to content

Commit da0d77d

Browse files
committed
feat(helm): allow extraArgs to also be a map enabling overrides of individual values
With external-dns relying a lot on `extraArgs` for its configuration using a map (key: value) data structure for extraArgs enables a lot more versatility. Multiple values files can be used to e.g. configure common values in one and then only specific values in another. Also setting certain values via `--set` is then possible.
1 parent ad7dbb4 commit da0d77d

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed

charts/external-dns/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ If `namespaced` is set to `true`, please ensure that `sources` my only contains
104104
| enabled | bool | `nil` | No effect - reserved for use in sub-charting. |
105105
| env | list | `[]` | [Environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/) for the `external-dns` container. |
106106
| excludeDomains | list | `[]` | Intentionally exclude domains from being managed. |
107-
| extraArgs | list | `[]` | Extra arguments to provide to _ExternalDNS_. |
107+
| extraArgs | object | `{}` | Extra arguments to provide to _ExternalDNS_. An array or map can be used with maps allowing for value overrides and merging via multiple value files or --set |
108108
| extraContainers | object | `{}` | Extra containers to add to the `Deployment`. |
109109
| extraVolumeMounts | list | `[]` | Extra [volume mounts](https://kubernetes.io/docs/concepts/storage/volumes/) for the `external-dns` container. |
110110
| extraVolumes | list | `[]` | Extra [volumes](https://kubernetes.io/docs/concepts/storage/volumes/) for the `Pod`. |

charts/external-dns/templates/deployment.yaml

+19-2
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,26 @@ spec:
124124
- --managed-record-types={{ . }}
125125
{{- end }}
126126
- --provider={{ $providerName }}
127-
{{- range .Values.extraArgs }}
127+
{{- if kindIs "map" .Values.extraArgs }}
128+
{{- range $key, $value := .Values.extraArgs }}
129+
{{- if not (kindIs "invalid" $value) }}
130+
{{- if kindIs "slice" $value }}
131+
{{- range $value }}
132+
- --{{ $key }}={{ tpl (. | toString) $ }}
133+
{{- end }}
134+
{{- else }}
135+
- --{{ $key }}={{ tpl ($value | toString) $ }}
136+
{{- end }}
137+
{{- else }}
138+
- --{{ $key }}
139+
{{- end }}
140+
{{- end }}
141+
{{- end }}
142+
{{- if kindIs "slice" .Values.extraArgs }}
143+
{{- range .Values.extraArgs }}
128144
- {{ tpl . $ }}
129-
{{- end }}
145+
{{- end }}
146+
{{- end }}
130147
ports:
131148
- name: http
132149
protocol: TCP

charts/external-dns/tests/deployment-flags_test.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,65 @@ tests:
103103
- --zone-id-filter=/hostedzone/Z00004
104104
- --zone-id-filter=/hostedzone/Z00005
105105

106+
107+
- it: should allow 'extraArgs' to be a slice
108+
set:
109+
extraArgs:
110+
- --extraArgA=valueA
111+
- --extraArgB=valueB
112+
- --extraArgC=valueC-1
113+
- --extraArgC=valueC-2
114+
115+
asserts:
116+
- equal:
117+
path: spec.template.spec.containers[?(@.name == "external-dns")].args
118+
value:
119+
- --log-level=info
120+
- --log-format=text
121+
- --interval=1m
122+
- --source=service
123+
- --source=ingress
124+
- --policy=upsert-only
125+
- --registry=txt
126+
- --provider=aws
127+
- --extraArgA=valueA
128+
- --extraArgB=valueB
129+
- --extraArgC=valueC-1
130+
- --extraArgC=valueC-2
131+
132+
133+
- it: should allow 'extraArgs' to be a map with its entries potentially being slices (lists) themselves
134+
set:
135+
extraArgs:
136+
extraArgA: valueA
137+
extraArgB: valueB
138+
extraArgC:
139+
- valueC-1
140+
- valueC-2
141+
142+
asserts:
143+
- equal:
144+
path: spec.template.spec.containers[?(@.name == "external-dns")].args
145+
value:
146+
- --log-level=info
147+
- --log-format=text
148+
- --interval=1m
149+
- --source=service
150+
- --source=ingress
151+
- --policy=upsert-only
152+
- --registry=txt
153+
- --provider=aws
154+
- --extraArgA=valueA
155+
- --extraArgB=valueB
156+
- --extraArgC=valueC-1
157+
- --extraArgC=valueC-2
158+
159+
106160
- it: should throw error when txtPrefix and txtSuffix are set
107161
set:
108162
txtPrefix: "test-prefix"
109163
txtSuffix: "test-suffix"
110164
asserts:
111165
- failedTemplate:
112166
errorMessage: "'txtPrefix' and 'txtSuffix' are mutually exclusive"
167+

charts/external-dns/values.schema.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@
6464
"items": {
6565
"type": "string"
6666
},
67+
"properties": {},
6768
"type": [
6869
"array",
69-
"null"
70+
"null",
71+
"object"
7072
],
7173
"uniqueItems": true
7274
},

charts/external-dns/values.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ provider: # @schema type: [object, string];
296296
relabelings: []
297297

298298
# -- Extra arguments to provide to _ExternalDNS_.
299-
extraArgs: [] # @schema type: [array, null]; item: string; uniqueItems: true;
299+
# An array or map can be used, with maps allowing for value overrides; maps also support slice values to use the same arg multiple times.
300+
extraArgs: {} # @schema type: [array, null, object]; item: string; uniqueItems: true;
300301

301302
secretConfiguration:
302303
# -- If `true`, create a `Secret` to store sensitive provider configuration (**DEPRECATED**).

0 commit comments

Comments
 (0)