From 81da231b1ed48aa6f752512b2cf9482628efa3aa Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Fri, 25 Oct 2019 12:23:40 +0300 Subject: [PATCH] Set cluster DNS in kubeadm config for kubelet dynamic config (#5293) Change-Id: I23116efefe8626d361d1904fc6fb8448f66cf3c5 --- .../templates/kubeadm-config.v1beta2.yaml.j2 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/roles/kubernetes/master/templates/kubeadm-config.v1beta2.yaml.j2 b/roles/kubernetes/master/templates/kubeadm-config.v1beta2.yaml.j2 index 327fcc6f2..5da491dcc 100644 --- a/roles/kubernetes/master/templates/kubeadm-config.v1beta2.yaml.j2 +++ b/roles/kubernetes/master/templates/kubeadm-config.v1beta2.yaml.j2 @@ -331,3 +331,22 @@ nodePortAddresses: {{ kube_proxy_nodeport_addresses }} oomScoreAdj: {{ kube_proxy_oom_score_adj }} portRange: {{ kube_proxy_port_range }} udpIdleTimeout: {{ kube_proxy_udp_idle_timeout }} +{# DNS settings for kubelet #} +{% if enable_nodelocaldns %} +{% set kubelet_cluster_dns = [nodelocaldns_ip] %} +{% elif dns_mode in ['coredns'] %} +{% set kubelet_cluster_dns = [skydns_server] %} +{% elif dns_mode == 'coredns_dual' %} +{% set kubelet_cluster_dns = [skydns_server,skydns_server_secondary] %} +{% elif dns_mode == 'manual' %} +{% set kubelet_cluster_dns = [manual_dns_server] %} +{% else %} +{% set kubelet_cluster_dns = [] %} +{% endif %} +--- +apiVersion: kubelet.config.k8s.io/v1beta1 +kind: KubeletConfiguration +clusterDNS: +{% for dns_address in kubelet_cluster_dns %} +- {{ dns_address }} +{% endfor %}