Skip to content

Commit

Permalink
feature: allow dnsConfig parameter overriding in deployment thanks to…
Browse files Browse the repository at this point in the history
… pod template spec
  • Loading branch information
RouxAntoine authored and traefiker committed Apr 13, 2023
1 parent c4c4987 commit 0365a17
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
15 changes: 15 additions & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@
{{- with .Values.deployment.dnsPolicy }}
dnsPolicy: {{ . }}
{{- end }}
{{- with .Values.deployment.dnsConfig }}
dnsConfig:
{{- if .searches }}
searches:
{{- toYaml .searches | nindent 10 }}
{{- end }}
{{- if .nameservers }}
nameservers:
{{- toYaml .nameservers | nindent 10 }}
{{- end }}
{{- if .options }}
options:
{{- toYaml .options | nindent 10 }}
{{- end }}
{{- end }}
{{- with .Values.deployment.initContainers }}
initContainers:
{{- toYaml . | nindent 6 }}
Expand Down
46 changes: 46 additions & 0 deletions traefik/tests/pod-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -523,3 +523,49 @@ tests:
hostPort: 1234
name: websecure-http3
protocol: UDP
- it: should have a custom list of dns nameservers
set:
deployment:
dnsConfig:
nameservers:
- 1.1.1.1
- 2001:db8:30::a
asserts:
- equal:
path: spec.template.spec.dnsConfig.nameservers[0]
value: "1.1.1.1"
- equal:
path: spec.template.spec.dnsConfig.nameservers[1]
value: "2001:db8:30::a"
- it: should have a list of dns search domain
set:
deployment:
dnsConfig:
searches:
- ns1.svc.cluster-domain.example
- my.dns.search.suffix
asserts:
- equal:
path: spec.template.spec.dnsConfig.searches[0]
value: "ns1.svc.cluster-domain.example"
- equal:
path: spec.template.spec.dnsConfig.searches[1]
value: "my.dns.search.suffix"
- it: should have a custom dns options
set:
deployment:
dnsConfig:
options:
- name: ndots
value: 2
- name: edns0
asserts:
- equal:
path: spec.template.spec.dnsConfig.options[0].name
value: "ndots"
- equal:
path: spec.template.spec.dnsConfig.options[0].value
value: 2
- equal:
path: spec.template.spec.dnsConfig.options[1].name
value: "edns0"
10 changes: 10 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ deployment:
shareProcessNamespace: false
# Custom pod DNS policy. Apply if `hostNetwork: true`
# dnsPolicy: ClusterFirstWithHostNet
dnsConfig: {}
# nameservers:
# - 192.0.2.1 # this is an example
# searches:
# - ns1.svc.cluster-domain.example
# - my.dns.search.suffix
# options:
# - name: ndots
# value: "2"
# - name: edns0
# Additional imagePullSecrets
imagePullSecrets: []
# - name: myRegistryKeySecretName
Expand Down

0 comments on commit 0365a17

Please sign in to comment.