commit
5253153dbb
4 changed files with 55 additions and 0 deletions
29
remove-node.yml
Normal file
29
remove-node.yml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
|
||||||
|
- hosts: etcd:k8s-cluster:vault:calico-rr
|
||||||
|
vars_prompt:
|
||||||
|
name: "delete_nodes_confirmation"
|
||||||
|
prompt: "Are you sure you want to delete nodes state? Type 'yes' to delete nodes."
|
||||||
|
default: "no"
|
||||||
|
private: no
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: check confirmation
|
||||||
|
fail:
|
||||||
|
msg: "Delete nodes confirmation failed"
|
||||||
|
when: delete_nodes_confirmation != "yes"
|
||||||
|
|
||||||
|
- hosts: kube-master
|
||||||
|
roles:
|
||||||
|
- { role: remove-node/pre-remove, tags: pre-remove }
|
||||||
|
|
||||||
|
- hosts: kube-node
|
||||||
|
roles:
|
||||||
|
- { role: reset, tags: reset }
|
||||||
|
|
||||||
|
- hosts: kube-master
|
||||||
|
roles:
|
||||||
|
- { role: remove-node/post-remove, tags: post-remove }
|
8
roles/remove-node/post-remove/tasks/main.yml
Normal file
8
roles/remove-node/post-remove/tasks/main.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Delete node
|
||||||
|
command: kubectl delete node {{ item }}
|
||||||
|
with_items:
|
||||||
|
- "{{ groups['kube-node'] }}"
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
ignore_errors: yes
|
3
roles/remove-node/pre-remove/defaults/main.yml
Normal file
3
roles/remove-node/pre-remove/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
drain_grace_period: 300
|
||||||
|
drain_timeout: 360s
|
15
roles/remove-node/pre-remove/tasks/main.yml
Normal file
15
roles/remove-node/pre-remove/tasks/main.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: remove-node | Drain node except daemonsets resource
|
||||||
|
command: >-
|
||||||
|
{{ bin_dir }}/kubectl drain
|
||||||
|
--force
|
||||||
|
--ignore-daemonsets
|
||||||
|
--grace-period {{ drain_grace_period }}
|
||||||
|
--timeout {{ drain_timeout }}
|
||||||
|
--delete-local-data {{ item }}
|
||||||
|
with_items:
|
||||||
|
- "{{ groups['kube-node'] }}"
|
||||||
|
failed_when: false
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
ignore_errors: yes
|
Loading…
Reference in a new issue