Skip to content

Commit

Permalink
Convert nodelocaldns to kubectl_apply_stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
VannTen committed Nov 10, 2024
1 parent c118bdf commit c28d60f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 108 deletions.
58 changes: 29 additions & 29 deletions roles/kubernetes-apps/ansible/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
delay: 1
when: inventory_hostname == groups['kube_control_plane'][0]

- name: Kubernetes Apps | nodelocalDNS
import_tasks: "nodelocaldns.yml"
when:
- enable_nodelocaldns
- inventory_hostname == groups['kube_control_plane'] | first
tags:
- nodelocaldns

- name: Kubernetes Apps | CoreDNS
command:
cmd: "{{ kubectl_apply_stdin }}"
Expand Down Expand Up @@ -47,30 +39,38 @@
when:
- dns_mode == 'coredns_dual'

- name: Kubernetes Apps | Start Resources
kube:
name: "{{ item.item.name }}"
namespace: "kube-system"
kubectl: "{{ bin_dir }}/kubectl"
resource: "{{ item.item.type }}"
filename: "{{ kube_config_dir }}/{{ item.item.file }}"
state: "latest"
with_items:
- "{{ nodelocaldns_manifests.results | default({}) }}"
- "{{ nodelocaldns_second_manifests.results | default({}) }}"
- name: Kubernetes Apps | nodelocalDNS
command:
cmd: "{{ kubectl_apply_stdin }}"
stdin: "{{ lookup('template', item) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
run_once: true
loop: "{{ nodelocaldns_manifests | flatten }}"
when:
- dns_mode != 'none'
- inventory_hostname == groups['kube_control_plane'][0]
- not item is skipped
register: resource_result
until: resource_result is succeeded
retries: 4
delay: 5
- enable_nodelocaldns
tags:
- coredns
- nodelocaldns
loop_control:
label: "{{ item.item.file }}"
- coredns
vars:
primaryClusterIP: >-
{%- if dns_mode in ['coredns', 'coredns_dual'] -%}
{{ skydns_server }}
{%- elif dns_mode == 'manual' -%}
{{ manual_dns_server }}
{%- endif -%}
secondaryclusterIP: "{{ skydns_server_secondary }}"
forwardTarget: >-
{%- if secondaryclusterIP is defined and dns_mode == 'coredns_dual' -%}
{{ primaryClusterIP }} {{ secondaryclusterIP }}
{%- else -%}
{{ primaryClusterIP }}
{%- endif -%}
upstreamForwardTarget: >-
{%- if upstream_dns_servers is defined and upstream_dns_servers | length > 0 -%}
{{ upstream_dns_servers | join(' ') }}
{%- else -%}
/etc/resolv.conf
{%- endif -%}
- name: Kubernetes Apps | Etcd metrics endpoints
command:
Expand Down
79 changes: 0 additions & 79 deletions roles/kubernetes-apps/ansible/tasks/nodelocaldns.yml

This file was deleted.

6 changes: 6 additions & 0 deletions roles/kubernetes-apps/ansible/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ coredns_manifests:
- coredns-svc.yml.j2
- "{{ dns_autoscaler_manifests if enable_dns_autoscaler else [] }}"
- "{{ coredns-poddisruptionbudget.yml.j2 if coredns_pod_disruption_budget else [] }}"

nodelocaldns_manifests:
- nodelocaldns-config.yml
- nodelocaldns-daemonset.yml
- nodelocaldns-sa.yml
- "{{ nodelocaldns-second-daemonset.yml if enable_nodelocaldns_secondary else [] }}"

0 comments on commit c28d60f

Please sign in to comment.