Skip to content

Commit

Permalink
Merge pull request #11700 from VannTen/feat/kubectl_stdin
Browse files Browse the repository at this point in the history
Convert kubernetes-apps to use kubectl directly
  • Loading branch information
k8s-ci-robot authored Dec 17, 2024
2 parents 30f0a14 + 7c71f25 commit da077ab
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 272 deletions.
50 changes: 0 additions & 50 deletions roles/kubernetes-apps/ansible/tasks/coredns.yml

This file was deleted.

21 changes: 0 additions & 21 deletions roles/kubernetes-apps/ansible/tasks/dashboard.yml

This file was deleted.

22 changes: 0 additions & 22 deletions roles/kubernetes-apps/ansible/tasks/etcd_metrics.yml

This file was deleted.

117 changes: 82 additions & 35 deletions roles/kubernetes-apps/ansible/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,62 +12,109 @@
when: inventory_hostname == groups['kube_control_plane'][0]

- name: Kubernetes Apps | CoreDNS
import_tasks: "coredns.yml"
when:
- dns_mode in ['coredns', 'coredns_dual']
- inventory_hostname == groups['kube_control_plane'][0]
command:
cmd: "{{ kubectl_apply_stdin }}"
stdin: "{{ lookup('template', item) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
run_once: true
loop: "{{ coredns_manifests | flatten }}"
tags:
- coredns
vars:
clusterIP: "{{ skydns_server }}"
when: dns_mode in ['coredns', 'coredns_dual']

- name: Kubernetes Apps | CoreDNS Secondary
command:
cmd: "{{ kubectl_apply_stdin }}"
stdin: "{{ lookup('template', item) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
run_once: true
loop: "{{ coredns_manifests | flatten }}"
tags:
- coredns
vars:
clusterIP: "{{ skydns_server_secondary }}"
coredns_ordinal_suffix: "-secondary"
when:
- dns_mode == 'coredns_dual'

- name: Kubernetes Apps | nodelocalDNS
import_tasks: "nodelocaldns.yml"
command:
cmd: "{{ kubectl_apply_stdin }}"
stdin: "{{ lookup('template', item) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
run_once: true
loop: "{{ nodelocaldns_manifests | flatten }}"
when:
- enable_nodelocaldns
- inventory_hostname == groups['kube_control_plane'] | first
tags:
- nodelocaldns

- 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:
- "{{ coredns_manifests.results | default({}) }}"
- "{{ coredns_secondary_manifests.results | default({}) }}"
- "{{ nodelocaldns_manifests.results | default({}) }}"
- "{{ nodelocaldns_second_manifests.results | default({}) }}"
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
tags:
- coredns
- nodelocaldns
loop_control:
label: "{{ item.item.file }}"
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
import_tasks: etcd_metrics.yml
command:
cmd: "{{ kubectl_apply_stdin }}"
stdin: "{{ lookup('template', item) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
run_once: true
loop:
- etcd_metrics-endpoints.yml.j2
- etcd_metrics-service.yml.j2
when: etcd_metrics_port is defined and etcd_metrics_service_labels is defined
tags:
- etcd_metrics

- name: Kubernetes Apps | Netchecker
import_tasks: netchecker.yml
command:
cmd: "{{ kubectl_apply_stdin }}"
stdin: "{{ lookup('template', item) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
run_once: true
vars:
namespace: "{{ netcheck_namespace }}"
when: deploy_netchecker
tags:
- netchecker
loop:
- netchecker-ns.yml.j2
- netchecker-agent-sa.yml.j2
- netchecker-agent-ds.yml.j2
- netchecker-agent-hostnet-ds.yml.j2
- netchecker-server-sa.yml.j2
- netchecker-server-clusterrole.yml.j2
- netchecker-server-clusterrolebinding.yml.j2
- netchecker-server-deployment.yml.j2
- netchecker-server-svc.yml.j2

- name: Kubernetes Apps | Dashboard
import_tasks: dashboard.yml
command:
cmd: "{{ kubectl_apply_stdin }}"
stdin: "{{ lookup('template', 'dashboard.yml.j2') }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
run_once: true
vars:
namespace: "{{ dashboard_namespace }}"
when: dashboard_enabled
tags:
- dashboard
47 changes: 0 additions & 47 deletions roles/kubernetes-apps/ansible/tasks/netchecker.yml

This file was deleted.

79 changes: 0 additions & 79 deletions roles/kubernetes-apps/ansible/tasks/nodelocaldns.yml

This file was deleted.

Loading

0 comments on commit da077ab

Please sign in to comment.