e40368ae2b
Added CoreDNS to downloads Updated with labels. Should now work without RBAC too Fix DNS settings on hosts Rename CoreDNS service from kube-dns to coredns Add rotate based on http://edgeofsanity.net/rant/2017/12/20/systemd-resolved-is-broken.html Updated docs with CoreDNS info Added labels and fixed minor settings from official yaml file: https://github.com/kubernetes/kubernetes/blob/release-1.9/cluster/addons/dns/coredns.yaml.sed Added a secondary deployment and secondary service ip. This is to mitigate dns timeouts and create high resitency for failures. See discussion at 'https://github.com/coreos/coreos-kubernetes/issues/641#issuecomment-281174806' Set dns list correct. Thanks to @whereismyjetpack Only download KubeDNS or CoreDNS if selected Move dns cleanup to its own file and import tasks based on dns mode Fix install of KubeDNS when dnsmask_kubedns mode is selected Add new dns option coredns_dual for dual stack deployment. Added variable to configure replicas deployed. Updated docs for dual stack deployment. Removed rotate option in resolv.conf. Run DNS manifests for CoreDNS and KubeDNS Set skydns servers on dual stack deployment Use only one template for CoreDNS dual deployment Set correct cluster ip for the dns server
75 lines
2.5 KiB
YAML
75 lines
2.5 KiB
YAML
---
|
|
|
|
- name: set dns server for docker
|
|
set_fact:
|
|
docker_dns_servers: |-
|
|
{%- if dns_mode in ['kubedns', 'coredns'] -%}
|
|
{{ [ skydns_server ] }}
|
|
{%- elif dns_mode == 'coredns_dual' -%}
|
|
{{ [ skydns_server ] + [ skydns_server_secondary ] }}
|
|
{%- elif dns_mode == 'dnsmasq_kubedns' -%}
|
|
{{ [ dnsmasq_dns_server ] }}
|
|
{%- elif dns_mode == 'manual' -%}
|
|
{{ [ manual_dns_server ] }}
|
|
{%- endif -%}
|
|
|
|
- name: set base docker dns facts
|
|
set_fact:
|
|
docker_dns_search_domains:
|
|
- 'default.svc.{{ dns_domain }}'
|
|
- 'svc.{{ dns_domain }}'
|
|
docker_dns_options:
|
|
- ndots:{{ ndots }}
|
|
- timeout:2
|
|
- attempts:2
|
|
|
|
- name: add upstream dns servers (only when dnsmasq is not used)
|
|
set_fact:
|
|
docker_dns_servers: "{{ docker_dns_servers + upstream_dns_servers|default([]) }}"
|
|
when: dns_mode in ['kubedns', 'coredns', 'coreos_dual']
|
|
|
|
- name: add global searchdomains
|
|
set_fact:
|
|
docker_dns_search_domains: "{{ docker_dns_search_domains + searchdomains|default([]) }}"
|
|
|
|
- name: check system nameservers
|
|
shell: grep "^nameserver" /etc/resolv.conf | sed 's/^nameserver\s*//'
|
|
changed_when: False
|
|
register: system_nameservers
|
|
check_mode: no
|
|
|
|
- name: check system search domains
|
|
shell: grep "^search" /etc/resolv.conf | sed 's/^search\s*//'
|
|
changed_when: False
|
|
register: system_search_domains
|
|
check_mode: no
|
|
|
|
- name: add system nameservers to docker options
|
|
set_fact:
|
|
docker_dns_servers: "{{ docker_dns_servers | union(system_nameservers.stdout_lines) | unique }}"
|
|
when: system_nameservers.stdout != ""
|
|
|
|
- name: add system search domains to docker options
|
|
set_fact:
|
|
docker_dns_search_domains: "{{ docker_dns_search_domains | union(system_search_domains.stdout.split()|default([])) | unique }}"
|
|
when: system_search_domains.stdout != ""
|
|
|
|
- name: check number of nameservers
|
|
fail:
|
|
msg: "Too many nameservers. You can relax this check by set docker_dns_servers_strict=no and we will only use the first 3."
|
|
when: docker_dns_servers|length > 3 and docker_dns_servers_strict|bool
|
|
|
|
- name: rtrim number of nameservers to 3
|
|
set_fact:
|
|
docker_dns_servers: "{{ docker_dns_servers[0:3] }}"
|
|
when: docker_dns_servers|length > 3 and not docker_dns_servers_strict|bool
|
|
|
|
- name: check number of search domains
|
|
fail:
|
|
msg: "Too many search domains"
|
|
when: docker_dns_search_domains|length > 6
|
|
|
|
- name: check length of search domains
|
|
fail:
|
|
msg: "Search domains exceeded limit of 256 characters"
|
|
when: docker_dns_search_domains|join(' ')|length > 256
|