Only cordon Ready nodes
This commit is contained in:
parent
5b8d6b5273
commit
f1f58166e5
3 changed files with 17 additions and 3 deletions
|
@ -93,3 +93,5 @@
|
||||||
delegate_to: "{{item}}"
|
delegate_to: "{{item}}"
|
||||||
with_items: "{{groups['etcd']}}"
|
with_items: "{{groups['etcd']}}"
|
||||||
when: needs_etcd_migration|bool
|
when: needs_etcd_migration|bool
|
||||||
|
notify: "Master | reload kubelet"
|
||||||
|
|
||||||
|
|
|
@ -3,3 +3,4 @@
|
||||||
- name: Uncordon node
|
- name: Uncordon node
|
||||||
command: "{{ bin_dir }}/kubectl uncordon {{ ansible_hostname }}"
|
command: "{{ bin_dir }}/kubectl uncordon {{ ansible_hostname }}"
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
when: needs_cordoning|default(false)
|
||||||
|
|
|
@ -1,8 +1,21 @@
|
||||||
---
|
---
|
||||||
|
- name: See if node is in ready state
|
||||||
|
command: "kubectl get nodes | grep {{ inventory_hostname }}"
|
||||||
|
register: kubectl_nodes
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
needs_cordoning: >-
|
||||||
|
{% if " Ready" in kubectl_nodes.stdout %}
|
||||||
|
true
|
||||||
|
{% else %}
|
||||||
|
false
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
- name: Cordon node
|
- name: Cordon node
|
||||||
command: "{{ bin_dir }}/kubectl cordon {{ ansible_hostname }}"
|
command: "{{ bin_dir }}/kubectl cordon {{ ansible_hostname }}"
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
when: needs_cordoning
|
||||||
|
|
||||||
- name: Drain node
|
- name: Drain node
|
||||||
command: >-
|
command: >-
|
||||||
|
@ -13,6 +26,4 @@
|
||||||
--timeout {{ drain_timeout }}
|
--timeout {{ drain_timeout }}
|
||||||
--delete-local-data {{ ansible_hostname }}
|
--delete-local-data {{ ansible_hostname }}
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
when: needs_cordoning
|
||||||
- name: Sleep for grace period for draining
|
|
||||||
pause: seconds=30
|
|
||||||
|
|
Loading…
Reference in a new issue