kubeasz/tools/13.delmaster.yml

36 lines
1.0 KiB
YAML
Raw Normal View History

2019-06-03 11:25:05 +08:00
# 警告:此脚本将清理指定 kube-master 节点
# 使用:`easzctl del-master 1.1.1.1`
- hosts: "{{ NODE_TO_DEL }}"
tasks:
- name: fail info1
fail: msg="you CAN NOT delete the last member of kube-master!"
when: "groups['kube-master']|length < 2 and NODE_TO_DEL in groups['kube-master']"
- name: 执行 kubectl drain 迁移 pod
shell: "{{ bin_dir }}/kubectl drain {{ NODE_TO_DEL }} --ignore-daemonsets --delete-local-data"
connection: local
ignore_errors: true
- hosts: "{{ NODE_TO_DEL }}"
vars:
DEL_MASTER: "yes"
DEL_NODE: "yes"
DEL_LB: "yes"
2019-06-08 16:07:46 +08:00
DEL_CHRONY: "yes"
DEL_ENV: "yes"
2019-06-03 11:25:05 +08:00
roles:
- clean
2019-06-04 13:06:11 +08:00
tasks:
2019-06-03 11:25:05 +08:00
- name: 执行 kubectl delete node
shell: "{{ bin_dir }}/kubectl delete node {{ NODE_TO_DEL }}"
delegate_to: "{{ groups['kube-node'][0] }}"
# 删除 ansible hosts 中节点配置
# - name: rm {{ NODE_TO_DEL }} in ansible hosts
# lineinfile:
# dest: "{{ base_dir }}/hosts"
# state: absent
# regexp: '^{{ NODE_TO_DEL }}$|^{{ NODE_TO_DEL }}[^0-9]'
# connection: local