blob: 5647e3d683dc8b811331f0e0a7c34ded094e537e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
---
- name: check for nodes to be removed
hosts: _kubernetes_primary_master_
tasks:
- name: fetch list of current nodes
command: kubectl get nodes -o name
changed_when: False
check_mode: no
register: kubectl_node_list
- name: generate list of nodes to be removed
loop: "{{ kubectl_node_list.stdout_lines | map('replace', 'node/', '') | list | difference(groups['_kubernetes_nodes_']) }}"
add_host:
name: "{{ item }}"
inventory_dir: "{{ hostvars[item].inventory_dir }}"
group: _kubernetes_nodes_prune_
changed_when: False
- name: drain superflous nodes
loop: "{{ groups['_kubernetes_nodes_prune_'] | default([]) }}"
command: "kubectl drain {{ item }} --delete-local-data --force --ignore-daemonsets"
- name: prune superflous nodes from cluster
hosts: _kubernetes_nodes_
roles:
- role: kubernetes/kubeadm/prune
- name: wipe superflous nodes
hosts: _kubernetes_nodes_prune_
roles:
- role: kubernetes/kubeadm/reset
|