Fix DNS loop when resolvconf_mode is set to host_resolvconf (#3390)

* Fix DNS loop when resolvconf_mode is set to host_resolvconf

* Make sure upstream_dns_servers is defined when using resolvconf_mode == 'host_resolvconf'

* Only set upstream dns servers on KubeDNS and CoreDNS if they are defined

* Only set upstream dns servers on KubeDNS and CoreDNS if they are defined
This commit is contained in:
Andreas Krüger 2018-10-08 16:08:51 +02:00 committed by k8s-ci-robot
parent 30132d8c35
commit 7e195b06a6
3 changed files with 12 additions and 1 deletions

View file

@ -53,7 +53,7 @@ Kubernetes needs some parameters in order to get deployed. These are the
following default cluster paramters: following default cluster paramters:
* *cluster_name* - Name of cluster (default is cluster.local) * *cluster_name* - Name of cluster (default is cluster.local)
* *domain_name* - Name of cluster DNS domain (default is cluster.local) * *dns_domain* - Name of cluster DNS domain (default is cluster.local)
* *kube_network_plugin* - Plugin to use for container networking * *kube_network_plugin* - Plugin to use for container networking
* *kube_service_addresses* - Subnet for cluster IPs (default is * *kube_service_addresses* - Subnet for cluster IPs (default is
10.233.0.0/18). Must not overlap with kube_pods_subnet 10.233.0.0/18). Must not overlap with kube_pods_subnet

View file

@ -13,10 +13,18 @@ data:
health health
kubernetes {{ dns_domain }} in-addr.arpa ip6.arpa { kubernetes {{ dns_domain }} in-addr.arpa ip6.arpa {
pods insecure pods insecure
{% if resolvconf_mode == 'host_resolvconf' and upstream_dns_servers is defined and upstream_dns_servers|length > 0 %}
upstream {{ upstream_dns_servers|join(' ') }}
{% else %}
upstream /etc/resolv.conf upstream /etc/resolv.conf
{% endif %}
fallthrough in-addr.arpa ip6.arpa fallthrough in-addr.arpa ip6.arpa
} }
prometheus :9153 prometheus :9153
{% if resolvconf_mode == 'host_resolvconf' and upstream_dns_servers is defined and upstream_dns_servers|length > 0 %}
proxy . {{ upstream_dns_servers|join(' ') }}
{% else %}
proxy . /etc/resolv.conf proxy . /etc/resolv.conf
{% endif %}
cache 30 cache 30
} }

View file

@ -97,6 +97,9 @@ spec:
- --dns-port=10053 - --dns-port=10053
- --config-dir=/kube-dns-config - --config-dir=/kube-dns-config
- --v={{ kube_log_level }} - --v={{ kube_log_level }}
{% if resolvconf_mode == 'host_resolvconf' and upstream_dns_servers is defined and upstream_dns_servers|length > 0 %}
- --nameservers={{ upstream_dns_servers|join(',') }}
{% endif %}
env: env:
- name: PROMETHEUS_PORT - name: PROMETHEUS_PORT
value: "10055" value: "10055"