From 92bfcf04677d79170f8e44a470b6c0ed5f47431c Mon Sep 17 00:00:00 2001 From: w33dw0r7d Date: Wed, 31 Jul 2019 21:26:15 +0300 Subject: [PATCH] Add CoreDNS endpoint_pod_names option (#5012) --- docs/vars.md | 4 +++- inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml | 2 ++ roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 | 3 +++ roles/kubespray-defaults/defaults/main.yaml | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/vars.md b/docs/vars.md index e158ee882..2542a91d1 100644 --- a/docs/vars.md +++ b/docs/vars.md @@ -65,6 +65,8 @@ following default cluster parameters: on the CoreDNS service. * *coredns_k8s_external_zone* - Zone that will be used when CoreDNS k8s_external plugin is enabled (default is k8s_external.local) +* *enable_coredns_k8s_endpoint_pod_names* - If enabled, it configures endpoint_pod_names option for kubernetes plugin. + on the CoreDNS service. * *cloud_provider* - Enable extra Kubelet option if operating inside GCE or OpenStack (default is unset) * *kube_hostpath_dynamic_provisioner* - Required for use of PetSets type in @@ -102,7 +104,7 @@ Stack](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/dns-stack.m * *docker_options* - Commonly used to set ``--insecure-registry=myregistry.mydomain:5000`` -* *docker_plugins* - This list can be used to define [Docker plugins](https://docs.docker.com/engine/extend/) to install. +* *docker_plugins* - This list can be used to define [Docker plugins](https://docs.docker.com/engine/extend/) to install. * *http_proxy/https_proxy/no_proxy* - Proxy variables for deploying behind a proxy. Note that no_proxy defaults to all internal cluster IPs and hostnames that correspond to each node. diff --git a/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml b/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml index f0dc90108..df8fcdba0 100644 --- a/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml +++ b/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml @@ -138,6 +138,8 @@ nodelocaldns_health_port: 9254 # Enable k8s_external plugin for CoreDNS enable_coredns_k8s_external: false coredns_k8s_external_zone: k8s_external.local +# Enable endpoint_pod_names option for kubernetes plugin +enable_coredns_k8s_endpoint_pod_names: false # Can be docker_dns, host_resolvconf or none resolvconf_mode: docker_dns diff --git a/roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 b/roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 index ad8be8958..a7d1378d1 100644 --- a/roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 +++ b/roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 @@ -14,6 +14,9 @@ data: ready kubernetes {{ dns_domain }} in-addr.arpa ip6.arpa { pods insecure +{% if enable_coredns_k8s_endpoint_pod_names %} + endpoint_pod_names +{% endif %} {% if resolvconf_mode == 'host_resolvconf' and upstream_dns_servers is defined and upstream_dns_servers|length > 0 %} upstream {{ upstream_dns_servers|join(' ') }} {% else %} diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml index 88e9f2eed..fe22a68f9 100644 --- a/roles/kubespray-defaults/defaults/main.yaml +++ b/roles/kubespray-defaults/defaults/main.yaml @@ -92,6 +92,8 @@ dns_servers: "{{kube_dns_servers[dns_mode]}}" enable_coredns_k8s_external: false coredns_k8s_external_zone: k8s_external.local +enable_coredns_k8s_endpoint_pod_names: false + # Kubernetes configuration dirs and system namespace. # Those are where all the additional config stuff goes # the kubernetes normally puts in /srv/kubernetes.