Rename default_resolver to cloud_resolver (#2209)

Cloud resolvers are mandatory for hosts on GCE and OpenStack
clouds. The 8.8.8.8 alternative resolver was dropped because
there is already a default nameserver. The new var name
reflects the purpose better.

Also restart apiserver when modifying dns settings.
This commit is contained in:
Matthew Mosesohn 2018-01-31 00:26:07 +03:00 committed by GitHub
parent 3846384d56
commit 2df4b6c5d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 7 deletions

View file

@ -5,7 +5,9 @@
- Preinstall | reload network - Preinstall | reload network
- Preinstall | reload kubelet - Preinstall | reload kubelet
- Preinstall | kube-controller configured - Preinstall | kube-controller configured
- Preinstall | kube-apiserver configured
- Preinstall | restart kube-controller-manager - Preinstall | restart kube-controller-manager
- Preinstall | restart kube-apiserver
when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
# FIXME(bogdando) https://github.com/projectcalico/felix/issues/1185 # FIXME(bogdando) https://github.com/projectcalico/felix/issues/1185
@ -37,14 +39,27 @@
state: restarted state: restarted
notify: notify:
- Preinstall | kube-controller configured - Preinstall | kube-controller configured
- Preinstall | kube-apiserver configured
- Preinstall | restart kube-controller-manager - Preinstall | restart kube-controller-manager
- Preinstall | restart kube-apiserver
when: not dns_early|bool when: not dns_early|bool
# FIXME(mattymo): Also restart for kubeadm mode
- name: Preinstall | kube-apiserver configured
stat: path="{{ kube_manifest_dir }}/kube-apiserver.manifest"
register: kube_apiserver_set
when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
# FIXME(mattymo): Also restart for kubeadm mode
- name: Preinstall | kube-controller configured - name: Preinstall | kube-controller configured
stat: path="{{ kube_manifest_dir }}/kube-controller-manager.manifest" stat: path="{{ kube_manifest_dir }}/kube-controller-manager.manifest"
register: kube_controller_set register: kube_controller_set
when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf' when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'
- name: Preinstall | restart kube-controller-manager - name: Preinstall | restart kube-controller-manager
shell: "docker ps -f name=k8s_kube-controller-manager* -q | xargs --no-run-if-empty docker rm -f" shell: "docker ps -f name=k8s_POD_kube-controller-manager* -q | xargs --no-run-if-empty docker rm -f"
when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf' and kube_controller_set.stat.exists when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf' and kube_controller_set.stat.exists
- name: Preinstall | restart kube-apiserver
shell: "docker ps -f name=k8s_POD_kube-apiserver* -q | xargs --no-run-if-empty docker rm -f"
when: inventory_hostname in groups['kube-master'] and dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'

View file

@ -15,13 +15,13 @@
{% for d in [ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([]) -%} {% for d in [ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([]) -%}
{{dns_domain}}.{{d}}./{{d}}.{{d}}./com.{{d}}./ {{dns_domain}}.{{d}}./{{d}}.{{d}}./com.{{d}}./
{%- endfor %} {%- endfor %}
default_resolver: >- cloud_resolver: >-
{%- if cloud_provider is defined and cloud_provider == 'gce' -%} {%- if cloud_provider is defined and cloud_provider == 'gce' -%}
169.254.169.254 ['169.254.169.254']
{%- elif cloud_provider is defined and cloud_provider == 'aws' -%} {%- elif cloud_provider is defined and cloud_provider == 'aws' -%}
169.254.169.253 ['169.254.169.253']
{%- else -%} {%- else -%}
8.8.8.8 []
{%- endif -%} {%- endif -%}
- name: check if kubelet is configured - name: check if kubelet is configured
@ -106,6 +106,6 @@
- name: generate nameservers to resolvconf - name: generate nameservers to resolvconf
set_fact: set_fact:
nameserverentries: nameserverentries:
nameserver {{( dnsmasq_server + nameservers|default([default_resolver])) | join(',nameserver ')}} nameserver {{( dnsmasq_server + nameservers|d([]) + cloud_resolver|d([])) | join(',nameserver ')}}
supersede_nameserver: supersede_nameserver:
supersede domain-name-servers {{( dnsmasq_server + nameservers|default([default_resolver])) | join(', ') }}; supersede domain-name-servers {{( dnsmasq_server + nameservers|d([]) + cloud_resolver|d([])) | join(', ') }};