mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-13 21:34:40 +03:00
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.
187 lines
5.6 KiB
Django/Jinja
187 lines
5.6 KiB
Django/Jinja
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: nodelocaldns
|
|
namespace: kube-system
|
|
labels:
|
|
addonmanager.kubernetes.io/mode: EnsureExists
|
|
|
|
data:
|
|
Corefile: |
|
|
{% if nodelocaldns_external_zones is defined and nodelocaldns_external_zones | length > 0 %}
|
|
{% for block in nodelocaldns_external_zones %}
|
|
{{ block['zones'] | join(' ') }} {
|
|
errors
|
|
cache {{ block['cache'] | default(30) }}
|
|
reload
|
|
{% if block['rewrite'] is defined and block['rewrite'] | length > 0 %}
|
|
{% for rewrite_match in block['rewrite'] %}
|
|
rewrite {{ rewrite_match }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ block['nameservers'] | join(' ') }}
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_prometheus_port }}
|
|
log
|
|
{% if dns_etchosts | default(None) %}
|
|
hosts /etc/coredns/hosts {
|
|
fallthrough
|
|
}
|
|
{% endif %}
|
|
}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{{ dns_domain }}:53 {
|
|
errors
|
|
cache {
|
|
success 9984 30
|
|
denial 9984 5
|
|
}
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ forwardTarget }} {
|
|
force_tcp
|
|
}
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_prometheus_port }}
|
|
health {{ nodelocaldns_ip }}:{{ nodelocaldns_health_port }}
|
|
{% if dns_etchosts | default(None) %}
|
|
hosts /etc/coredns/hosts {
|
|
fallthrough
|
|
}
|
|
{% endif %}
|
|
}
|
|
in-addr.arpa:53 {
|
|
errors
|
|
cache 30
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ forwardTarget }} {
|
|
force_tcp
|
|
}
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_prometheus_port }}
|
|
}
|
|
ip6.arpa:53 {
|
|
errors
|
|
cache 30
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ forwardTarget }} {
|
|
force_tcp
|
|
}
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_prometheus_port }}
|
|
}
|
|
.:53 {
|
|
errors
|
|
cache 30
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ upstreamForwardTarget }}{% if dns_upstream_forward_extra_opts is defined %} {
|
|
{% for optname, optvalue in dns_upstream_forward_extra_opts.items() %}
|
|
{{ (optname ~ ' ' ~ optvalue) | trim }}
|
|
{# do not add a trailing space when optvalue == ''
|
|
workaround for: https://github.com/kubernetes/kubernetes/issues/36222 #}
|
|
{% endfor %}
|
|
}{% endif %}
|
|
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_prometheus_port }}
|
|
{% if dns_etchosts | default(None) %}
|
|
hosts /etc/coredns/hosts {
|
|
fallthrough
|
|
}
|
|
{% endif %}
|
|
}
|
|
{% if enable_nodelocaldns_secondary %}
|
|
Corefile-second: |
|
|
{% if nodelocaldns_external_zones is defined and nodelocaldns_external_zones | length > 0 %}
|
|
{% for block in nodelocaldns_external_zones %}
|
|
{{ block['zones'] | join(' ') }} {
|
|
errors
|
|
cache {{ block['cache'] | default(30) }}
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ block['nameservers'] | join(' ') }}
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_secondary_prometheus_port }}
|
|
log
|
|
{% if dns_etchosts | default(None) %}
|
|
hosts /etc/coredns/hosts {
|
|
fallthrough
|
|
}
|
|
{% endif %}
|
|
}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{{ dns_domain }}:53 {
|
|
errors
|
|
cache {
|
|
success 9984 30
|
|
denial 9984 5
|
|
}
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ forwardTarget }} {
|
|
force_tcp
|
|
}
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_secondary_prometheus_port }}
|
|
health {{ nodelocaldns_ip }}:{{ nodelocaldns_second_health_port }}
|
|
{% if dns_etchosts | default(None) %}
|
|
hosts /etc/coredns/hosts {
|
|
fallthrough
|
|
}
|
|
{% endif %}
|
|
}
|
|
in-addr.arpa:53 {
|
|
errors
|
|
cache 30
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ forwardTarget }} {
|
|
force_tcp
|
|
}
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_secondary_prometheus_port }}
|
|
}
|
|
ip6.arpa:53 {
|
|
errors
|
|
cache 30
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ forwardTarget }} {
|
|
force_tcp
|
|
}
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_secondary_prometheus_port }}
|
|
}
|
|
.:53 {
|
|
errors
|
|
cache 30
|
|
reload
|
|
loop
|
|
bind {{ nodelocaldns_ip }}
|
|
forward . {{ upstreamForwardTarget }}{% if dns_upstream_forward_extra_opts is defined %} {
|
|
{% for optname, optvalue in dns_upstream_forward_extra_opts.items() %}
|
|
{{ (optname ~ ' ' ~ optvalue) | trim }}
|
|
{# do not add a trailing space when optvalue == ''
|
|
workaround for: https://github.com/kubernetes/kubernetes/issues/36222 #}
|
|
{% endfor %}
|
|
}{% endif %}
|
|
|
|
prometheus {% if nodelocaldns_bind_metrics_host_ip %}{$MY_HOST_IP}{% endif %}:{{ nodelocaldns_secondary_prometheus_port }}
|
|
{% if dns_etchosts | default(None) %}
|
|
hosts /etc/coredns/hosts {
|
|
fallthrough
|
|
}
|
|
{% endif %}
|
|
}
|
|
{% endif %}
|
|
{% if dns_etchosts | default(None) %}
|
|
hosts: |
|
|
{{ dns_etchosts | indent(width=4, first=False) }}
|
|
{% endif %}
|