Skip to content

feat(helm): allow extraArgs to also be a map enabling overrides of individual values #5293

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

Merged
merged 1 commit into from
Apr 23, 2025
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
4 changes: 4 additions & 0 deletions charts/external-dns/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED]

### Changed

- Allow extraArgs to also be a map enabling overrides of individual values ([#5293](https://github.com/kubernetes-sigs/external-dns/pull/5293)) _@frittentheke

### Fixed

- Fixed wrong type definitions for webhook probes. ([#5297](https://github.com/kubernetes-sigs/external-dns/pull/5297)) _@semnell_
Expand Down
2 changes: 1 addition & 1 deletion charts/external-dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ If `namespaced` is set to `true`, please ensure that `sources` my only contains
| enabled | bool | `nil` | No effect - reserved for use in sub-charting. |
| env | list | `[]` | [Environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/) for the `external-dns` container. |
| excludeDomains | list | `[]` | Intentionally exclude domains from being managed. |
| extraArgs | list | `[]` | Extra arguments to provide to _ExternalDNS_. |
| extraArgs | object | `{}` | Extra arguments to provide to _ExternalDNS_. 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. |
| extraContainers | object | `{}` | Extra containers to add to the `Deployment`. |
| extraVolumeMounts | list | `[]` | Extra [volume mounts](https://kubernetes.io/docs/concepts/storage/volumes/) for the `external-dns` container. |
| extraVolumes | list | `[]` | Extra [volumes](https://kubernetes.io/docs/concepts/storage/volumes/) for the `Pod`. |
Expand Down
21 changes: 19 additions & 2 deletions charts/external-dns/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,26 @@ spec:
- --managed-record-types={{ . }}
{{- end }}
- --provider={{ $providerName }}
{{- range .Values.extraArgs }}
{{- if kindIs "map" .Values.extraArgs }}
{{- range $key, $value := .Values.extraArgs }}
{{- if not (kindIs "invalid" $value) }}
{{- if kindIs "slice" $value }}
{{- range $value }}
- --{{ $key }}={{ tpl (. | toString) $ }}
{{- end }}
{{- else }}
- --{{ $key }}={{ tpl ($value | toString) $ }}
{{- end }}
{{- else }}
- --{{ $key }}
{{- end }}
{{- end }}
{{- end }}
{{- if kindIs "slice" .Values.extraArgs }}
{{- range .Values.extraArgs }}
- {{ tpl . $ }}
{{- end }}
{{- end }}
{{- end }}
ports:
- name: http
protocol: TCP
Expand Down
55 changes: 55 additions & 0 deletions charts/external-dns/tests/deployment-flags_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,65 @@ tests:
- --zone-id-filter=/hostedzone/Z00004
- --zone-id-filter=/hostedzone/Z00005


- it: should allow 'extraArgs' to be a slice
set:
extraArgs:
- --extraArgA=valueA
- --extraArgB=valueB
- --extraArgC=valueC-1
- --extraArgC=valueC-2

asserts:
- equal:
path: spec.template.spec.containers[?(@.name == "external-dns")].args
value:
- --log-level=info
- --log-format=text
- --interval=1m
- --source=service
- --source=ingress
- --policy=upsert-only
- --registry=txt
- --provider=aws
- --extraArgA=valueA
- --extraArgB=valueB
- --extraArgC=valueC-1
- --extraArgC=valueC-2


- it: should allow 'extraArgs' to be a map with its entries potentially being slices (lists) themselves
set:
extraArgs:
extraArgA: valueA
extraArgB: valueB
extraArgC:
- valueC-1
- valueC-2

asserts:
- equal:
path: spec.template.spec.containers[?(@.name == "external-dns")].args
value:
- --log-level=info
- --log-format=text
- --interval=1m
- --source=service
- --source=ingress
- --policy=upsert-only
- --registry=txt
- --provider=aws
- --extraArgA=valueA
- --extraArgB=valueB
- --extraArgC=valueC-1
- --extraArgC=valueC-2


- it: should throw error when txtPrefix and txtSuffix are set
set:
txtPrefix: "test-prefix"
txtSuffix: "test-suffix"
asserts:
- failedTemplate:
errorMessage: "'txtPrefix' and 'txtSuffix' are mutually exclusive"

4 changes: 3 additions & 1 deletion charts/external-dns/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@
"items": {
"type": "string"
},
"properties": {},
"type": [
"array",
"null"
"null",
"object"
],
"uniqueItems": true
},
Expand Down
3 changes: 2 additions & 1 deletion charts/external-dns/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ provider: # @schema type: [object, string];
relabelings: []

# -- Extra arguments to provide to _ExternalDNS_.
extraArgs: [] # @schema type: [array, null]; item: string; uniqueItems: true;
# 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.
extraArgs: {} # @schema type: [array, null, object]; item: string; uniqueItems: true;

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