From ab8034275031c35fe63d3483f88095bac29f422c Mon Sep 17 00:00:00 2001 From: Marijn van der Giesen <55738566+mvandergiesen@users.noreply.github.com> Date: Wed, 28 Dec 2022 03:21:27 +0100 Subject: [PATCH] [feat] Add custom options to coredns kubernets plugin (#9608) --- docs/dns-stack.md | 4 ++++ inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml | 3 +++ roles/kubernetes-apps/ansible/defaults/main.yml | 4 ++++ .../kubernetes-apps/ansible/templates/coredns-config.yml.j2 | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/docs/dns-stack.md b/docs/dns-stack.md index cc1d6d293..60eadc4b6 100644 --- a/docs/dns-stack.md +++ b/docs/dns-stack.md @@ -56,6 +56,10 @@ Whether or not upstream DNS servers come from `upstream_dns_servers` variable or These are configurable in inventory in as a dictionary in the `dns_upstream_forward_extra_opts` variable. By default, no other option than the ones hardcoded (see `roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2` and `roles/kubernetes-apps/ansible/templates/nodelocaldns-config.yml.j2`). +### coredns_kubernetes_extra_opts + +Custom options to be added to the kubernetes coredns plugin. + ### coredns_external_zones Array of optional external zones to coredns forward queries to. It's injected into diff --git a/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml b/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml index b9740058d..b4c1de7dc 100644 --- a/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml +++ b/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml @@ -208,6 +208,9 @@ enable_coredns_k8s_endpoint_pod_names: false # Set forward options for upstream DNS servers in coredns (and nodelocaldns) config # dns_upstream_forward_extra_opts: # policy: sequential +# Apply extra options to coredns kubernetes plugin +# coredns_kubernetes_extra_opts: +# - 'fallthrough example.local' # Can be docker_dns, host_resolvconf or none resolvconf_mode: host_resolvconf diff --git a/roles/kubernetes-apps/ansible/defaults/main.yml b/roles/kubernetes-apps/ansible/defaults/main.yml index 66b767341..9fa1ac141 100644 --- a/roles/kubernetes-apps/ansible/defaults/main.yml +++ b/roles/kubernetes-apps/ansible/defaults/main.yml @@ -18,6 +18,10 @@ coredns_default_zone_cache_block: | # dns_upstream_forward_extra_opts: # policy: sequential +# Apply extra options to coredns kubernetes plugin +# coredns_kubernetes_extra_opts: +# - 'fallthrough example.local' + # nodelocaldns nodelocaldns_cpu_requests: 100m nodelocaldns_memory_limit: 200Mi diff --git a/roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 b/roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 index 44eea93bc..d92d78849 100644 --- a/roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 +++ b/roles/kubernetes-apps/ansible/templates/coredns-config.yml.j2 @@ -43,6 +43,11 @@ data: {% endif %} {% if enable_coredns_reverse_dns_lookups %} fallthrough in-addr.arpa ip6.arpa +{% endif %} +{% if coredns_kubernetes_extra_opts is defined %} +{% for opt in coredns_kubernetes_extra_opts %} + {{ opt }} +{% endfor %} {% endif %} } prometheus :9153 -- GitLab