Browse Source

Fix the pretty-printing of (core|nodelocal)dns (#11721)

When using
dns_upstream_forward_extra_opts:
  prefer_udp: "" # the option as no value so use empty string to just
                 # put the key

This is rendered in the dns configmap as ($ for end-of-line)

...
  prefer_udp $
...

Note the trailing space.
This triggers https://github.com/kubernetes/kubernetes/issues/36222,
which makes the configmap hardly readable when editing them manually or
simply putting them in a yaml file for inspection.

Trim the concatenation of option + value to get rid of any trailing
space.

Co-authored-by: Max Gautier <mg@max.gautier.name>
release-2.25
k8s-infra-cherrypick-robot 6 days ago
committed by GitHub
parent
commit
586ba66b7a
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions
  1. 4
      roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2
  2. 8
      roles/kubernetes-apps/ansible/templates/nodelocaldns-config.yml.j2

4
roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2

@ -73,7 +73,9 @@ data:
max_concurrent 1000 max_concurrent 1000
{% if dns_upstream_forward_extra_opts is defined %} {% if dns_upstream_forward_extra_opts is defined %}
{% for optname, optvalue in dns_upstream_forward_extra_opts.items() %} {% for optname, optvalue in dns_upstream_forward_extra_opts.items() %}
{{ optname }} {{ optvalue }}
{{ (optname ~ ' ' ~ optvalue) | trim }}
{# do not add a trailing space when optvalue == ''
workaround for: https://github.com/kubernetes/kubernetes/issues/36222 #}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
} }

8
roles/kubernetes-apps/ansible/templates/nodelocaldns-config.yml.j2

@ -82,7 +82,9 @@ data:
bind {{ nodelocaldns_ip }} bind {{ nodelocaldns_ip }}
forward . {{ upstreamForwardTarget }}{% if dns_upstream_forward_extra_opts is defined %} { forward . {{ upstreamForwardTarget }}{% if dns_upstream_forward_extra_opts is defined %} {
{% for optname, optvalue in dns_upstream_forward_extra_opts.items() %} {% for optname, optvalue in dns_upstream_forward_extra_opts.items() %}
{{ optname }} {{ optvalue }}
{{ (optname ~ ' ' ~ optvalue) | trim }}
{# do not add a trailing space when optvalue == ''
workaround for: https://github.com/kubernetes/kubernetes/issues/36222 #}
{% endfor %} {% endfor %}
}{% endif %} }{% endif %}
@ -164,7 +166,9 @@ data:
bind {{ nodelocaldns_ip }} bind {{ nodelocaldns_ip }}
forward . {{ upstreamForwardTarget }}{% if dns_upstream_forward_extra_opts is defined %} { forward . {{ upstreamForwardTarget }}{% if dns_upstream_forward_extra_opts is defined %} {
{% for optname, optvalue in dns_upstream_forward_extra_opts.items() %} {% for optname, optvalue in dns_upstream_forward_extra_opts.items() %}
{{ optname }} {{ optvalue }}
{{ (optname ~ ' ' ~ optvalue) | trim }}
{# do not add a trailing space when optvalue == ''
workaround for: https://github.com/kubernetes/kubernetes/issues/36222 #}
{% endfor %} {% endfor %}
}{% endif %} }{% endif %}

Loading…
Cancel
Save