Skip to content

Commit

Permalink
Enable systemd-resolved DNS resolution mode (kubernetes-sigs#5318)
Browse files Browse the repository at this point in the history
Change-Id: If3e253a40782e03cde7fc4a91493517ae31fda17
  • Loading branch information
mattymo authored and k8s-ci-robot committed Nov 6, 2019
1 parent 471589f commit a005d19
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions roles/kubernetes/preinstall/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,8 @@
- inventory_hostname in groups['kube-master']
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'

- name: Preinstall | Restart systemd-resolved
service:
name: systemd-resolved
state: restarted
7 changes: 7 additions & 0 deletions roles/kubernetes/preinstall/tasks/0040-set_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
changed_when: false
check_mode: no

- name: check systemd-resolved
command: systemctl is-active systemd-resolved
register: systemd_resolved_enabled
failed_when: false
changed_when: false
check_mode: no

- name: set dns facts
set_fact:
resolvconf: >-
Expand Down
9 changes: 9 additions & 0 deletions roles/kubernetes/preinstall/tasks/0061-systemd-resolved.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Write resolved.conf
template:
src: resolved.conf.j2
dest: /etc/systemd/resolved.conf
owner: root
group: root
mode: 0644
notify: Preinstall | Restart systemd-resolved
10 changes: 10 additions & 0 deletions roles/kubernetes/preinstall/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
when:
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'
- systemd_resolved_enabled.rc != 0
tags:
- bootstrap-os
- resolvconf

- import_tasks: 0061-systemd-resolved.yml
when:
- dns_mode != 'none'
- resolvconf_mode == 'host_resolvconf'
- systemd_resolved_enabled.rc == 0
tags:
- bootstrap-os
- resolvconf
Expand Down
13 changes: 13 additions & 0 deletions roles/kubernetes/preinstall/templates/resolved.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Resolve]
{% if dns_late %}
DNS={{ ( coredns_server + nameservers|d([]) + cloud_resolver|d([])) | unique | join(' ') }}
{% else %}
DNS={{ ( nameservers|d([]) + cloud_resolver|d([])) | unique | join(' ') }}
{% endif %}
#FallbackDNS=
Domains={{ ([ 'default.svc.' + dns_domain, 'svc.' + dns_domain ] + searchdomains|default([])) | join(' ') }}
#LLMNR=no
#MulticastDNS=no
DNSSEC=no
Cache=no-negative
#DNSStubListener=yes

0 comments on commit a005d19

Please sign in to comment.