Merge pull request #2416 from riverzhang/delete-node

Remove nodes
This commit is contained in:
RongZhang 2018-03-08 01:55:20 -06:00 committed by GitHub
commit 5253153dbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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