2018-12-11 09:28:03 +08:00
|
|
|
---
|
2019-01-29 15:39:27 +08:00
|
|
|
- name: Kubernetes Apps | set up necessary nodelocaldns parameters
|
|
|
|
set_fact:
|
2020-05-29 19:27:15 +08:00
|
|
|
primaryClusterIP: >-
|
2019-04-02 03:32:34 +08:00
|
|
|
{%- if dns_mode in ['coredns', 'coredns_dual'] -%}
|
2019-01-29 15:39:27 +08:00
|
|
|
{{ skydns_server }}
|
|
|
|
{%- elif dns_mode == 'manual' -%}
|
|
|
|
{{ manual_dns_server }}
|
|
|
|
{%- endif -%}
|
|
|
|
secondaryclusterIP: "{{ skydns_server_secondary }}"
|
2020-10-13 07:47:21 +08:00
|
|
|
when:
|
|
|
|
- enable_nodelocaldns
|
2021-03-24 08:26:05 +08:00
|
|
|
- inventory_hostname == groups['kube_control_plane'] | first
|
2020-10-13 07:47:21 +08:00
|
|
|
tags:
|
|
|
|
- nodelocaldns
|
|
|
|
- coredns
|
2019-01-29 15:39:27 +08:00
|
|
|
|
2018-12-11 09:28:03 +08:00
|
|
|
- name: Kubernetes Apps | Lay Down nodelocaldns Template
|
|
|
|
template:
|
|
|
|
src: "{{ item.file }}.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/{{ item.file }}"
|
2022-01-09 17:51:12 +08:00
|
|
|
mode: 0644
|
2018-12-11 09:28:03 +08:00
|
|
|
with_items:
|
|
|
|
- { name: nodelocaldns, file: nodelocaldns-config.yml, type: configmap }
|
|
|
|
- { name: nodelocaldns, file: nodelocaldns-sa.yml, type: sa }
|
2019-01-28 17:57:40 +08:00
|
|
|
- { name: nodelocaldns, file: nodelocaldns-daemonset.yml, type: daemonset }
|
2018-12-11 09:28:03 +08:00
|
|
|
register: nodelocaldns_manifests
|
|
|
|
vars:
|
2019-01-29 15:39:27 +08:00
|
|
|
forwardTarget: >-
|
|
|
|
{%- if secondaryclusterIP is defined and dns_mode == 'coredns_dual' -%}
|
2020-05-29 19:27:15 +08:00
|
|
|
{{ primaryClusterIP }} {{ secondaryclusterIP }}
|
2019-01-29 15:39:27 +08:00
|
|
|
{%- else -%}
|
2020-05-29 19:27:15 +08:00
|
|
|
{{ primaryClusterIP }}
|
2019-01-29 15:39:27 +08:00
|
|
|
{%- endif -%}
|
|
|
|
upstreamForwardTarget: >-
|
2022-10-11 15:47:02 +08:00
|
|
|
{%- if upstream_dns_servers is defined and upstream_dns_servers|length > 0 -%}
|
2019-01-29 15:39:27 +08:00
|
|
|
{{ upstream_dns_servers|join(' ') }}
|
|
|
|
{%- else -%}
|
|
|
|
/etc/resolv.conf
|
|
|
|
{%- endif -%}
|
2018-12-11 09:28:03 +08:00
|
|
|
when:
|
2019-04-17 23:42:03 +08:00
|
|
|
- enable_nodelocaldns
|
2021-03-24 08:26:05 +08:00
|
|
|
- inventory_hostname == groups['kube_control_plane'] | first
|
2018-12-11 09:28:03 +08:00
|
|
|
tags:
|
|
|
|
- nodelocaldns
|
2019-08-09 17:29:27 +08:00
|
|
|
- coredns
|
2021-11-10 01:57:47 +08:00
|
|
|
|
|
|
|
- name: Kubernetes Apps | Lay Down nodelocaldns-secondary Template
|
|
|
|
template:
|
|
|
|
src: "{{ item.file }}.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/{{ item.file }}"
|
2022-01-09 17:51:12 +08:00
|
|
|
mode: 0644
|
2021-11-10 01:57:47 +08:00
|
|
|
with_items:
|
|
|
|
- { name: nodelocaldns, file: nodelocaldns-second-daemonset.yml, type: daemonset }
|
|
|
|
register: nodelocaldns_second_manifests
|
|
|
|
vars:
|
|
|
|
forwardTarget: >-
|
|
|
|
{%- if secondaryclusterIP is defined and dns_mode == 'coredns_dual' -%}
|
|
|
|
{{ primaryClusterIP }} {{ secondaryclusterIP }}
|
|
|
|
{%- else -%}
|
|
|
|
{{ primaryClusterIP }}
|
|
|
|
{%- endif -%}
|
|
|
|
upstreamForwardTarget: >-
|
2022-10-11 15:47:02 +08:00
|
|
|
{%- if upstream_dns_servers is defined and upstream_dns_servers|length > 0 -%}
|
2021-11-10 01:57:47 +08:00
|
|
|
{{ upstream_dns_servers|join(' ') }}
|
|
|
|
{%- else -%}
|
|
|
|
/etc/resolv.conf
|
|
|
|
{%- endif -%}
|
|
|
|
when:
|
|
|
|
- enable_nodelocaldns
|
|
|
|
- enable_nodelocaldns_secondary
|
|
|
|
- inventory_hostname == groups['kube_control_plane'] | first
|
|
|
|
tags:
|
|
|
|
- nodelocaldns
|
|
|
|
- coredns
|