Edited pre-upgrade task to uncordon a node failing to drain (#6546)
This commit is contained in:
parent
d9d11e2291
commit
fa378f09c3
1 changed files with 37 additions and 31 deletions
|
@ -30,40 +30,46 @@
|
||||||
false
|
false
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
- name: Cordon node
|
- name: Node draining
|
||||||
command: "{{ bin_dir }}/kubectl cordon {{ kube_override_hostname|default(inventory_hostname) }}"
|
block:
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
- name: Cordon node
|
||||||
when: needs_cordoning
|
command: "{{ bin_dir }}/kubectl cordon {{ kube_override_hostname|default(inventory_hostname) }}"
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
- name: Check kubectl version
|
- name: Check kubectl version
|
||||||
command: "{{ bin_dir }}/kubectl version --client --short"
|
command: "{{ bin_dir }}/kubectl version --client --short"
|
||||||
register: kubectl_version
|
register: kubectl_version
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
run_once: yes
|
run_once: yes
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when:
|
when:
|
||||||
- drain_nodes
|
- drain_nodes
|
||||||
- needs_cordoning
|
- drain_pod_selector
|
||||||
- drain_pod_selector
|
|
||||||
|
|
||||||
- name: Ensure minimum version for drain label selector if necessary
|
- name: Ensure minimum version for drain label selector if necessary
|
||||||
assert:
|
assert:
|
||||||
that: "kubectl_version.stdout.split(' ')[-1] is version('v1.10.0', '>=')"
|
that: "kubectl_version.stdout.split(' ')[-1] is version('v1.10.0', '>=')"
|
||||||
when:
|
when:
|
||||||
- drain_nodes
|
- drain_nodes
|
||||||
- needs_cordoning
|
- drain_pod_selector
|
||||||
- drain_pod_selector
|
|
||||||
|
|
||||||
- name: Drain node
|
- name: Drain node
|
||||||
command: >-
|
command: >-
|
||||||
{{ bin_dir }}/kubectl drain
|
{{ bin_dir }}/kubectl drain
|
||||||
--force
|
--force
|
||||||
--ignore-daemonsets
|
--ignore-daemonsets
|
||||||
--grace-period {{ drain_grace_period }}
|
--grace-period {{ drain_grace_period }}
|
||||||
--timeout {{ drain_timeout }}
|
--timeout {{ drain_timeout }}
|
||||||
--delete-local-data {{ kube_override_hostname|default(inventory_hostname) }}
|
--delete-local-data {{ kube_override_hostname|default(inventory_hostname) }}
|
||||||
{% if drain_pod_selector %}--pod-selector '{{ drain_pod_selector }}'{% endif %}
|
{% if drain_pod_selector %}--pod-selector '{{ drain_pod_selector }}'{% endif %}
|
||||||
|
when:
|
||||||
|
- drain_nodes
|
||||||
|
rescue:
|
||||||
|
- name: Set node back to schedulable
|
||||||
|
command: "{{ bin_dir }}/kubectl --kubeconfig /etc/kubernetes/admin.conf uncordon {{ inventory_hostname }}"
|
||||||
|
- name: Fail after rescue
|
||||||
|
fail:
|
||||||
|
msg: "Failed to drain node {{ inventory_hostname }}"
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
when:
|
when:
|
||||||
- drain_nodes
|
|
||||||
- needs_cordoning
|
- needs_cordoning
|
||||||
|
|
Loading…
Reference in a new issue