Remove nodes

Drain node except daemonsets resource
Use reset cluser for delete deploy data
Then delete node
This commit is contained in:
rong.zhang 2018-03-05 15:02:47 +08:00 committed by riverzhang
parent 84e47f4aaa
commit 12c78e622b
4 changed files with 55 additions and 0 deletions

29
remove-node.yml Normal file
View 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 }

View 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

View file

@ -0,0 +1,3 @@
---
drain_grace_period: 300
drain_timeout: 360s

View 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