Skip to content
Snippets Groups Projects
Commit 44d851d5 authored by Matthew Mosesohn's avatar Matthew Mosesohn
Browse files

Only cordon Ready nodes

parent 5ed03ce7
No related branches found
No related tags found
No related merge requests found
......@@ -93,3 +93,5 @@
delegate_to: "{{item}}"
with_items: "{{groups['etcd']}}"
when: needs_etcd_migration|bool
notify: "Master | reload kubelet"
......@@ -3,3 +3,4 @@
- name: Uncordon node
command: "{{ bin_dir }}/kubectl uncordon {{ ansible_hostname }}"
delegate_to: "{{ groups['kube-master'][0] }}"
when: needs_cordoning|default(false)
---
- 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
command: "{{ bin_dir }}/kubectl cordon {{ ansible_hostname }}"
delegate_to: "{{ groups['kube-master'][0] }}"
when: needs_cordoning
- name: Drain node
command: >-
......@@ -13,6 +26,4 @@
--timeout {{ drain_timeout }}
--delete-local-data {{ ansible_hostname }}
delegate_to: "{{ groups['kube-master'][0] }}"
- name: Sleep for grace period for draining
pause: seconds=30
when: needs_cordoning
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment