|
|
@ -17,9 +17,9 @@ |
|
|
|
# Node Ready: type = ready, status = True |
|
|
|
# Node NotReady: type = ready, status = Unknown |
|
|
|
- name: See if node is in ready state |
|
|
|
shell: >- |
|
|
|
{{ bin_dir }}/kubectl get node {{ kube_override_hostname|default(inventory_hostname) }} |
|
|
|
-o jsonpath='{ range .status.conditions[?(@.type == "Ready")].status }{ @ }{ end }' |
|
|
|
command: > |
|
|
|
{{ kubectl }} get node {{ kube_override_hostname|default(inventory_hostname) }} |
|
|
|
-o jsonpath={ range .status.conditions[?(@.type == "Ready")].status }{ @ }{ end } |
|
|
|
register: kubectl_node_ready |
|
|
|
delegate_to: "{{ groups['kube_control_plane'][0] }}" |
|
|
|
failed_when: false |
|
|
@ -28,9 +28,9 @@ |
|
|
|
# SchedulingDisabled: unschedulable = true |
|
|
|
# else unschedulable key doesn't exist |
|
|
|
- name: See if node is schedulable |
|
|
|
shell: >- |
|
|
|
{{ bin_dir }}/kubectl get node {{ kube_override_hostname|default(inventory_hostname) }} |
|
|
|
-o jsonpath='{ .spec.unschedulable }' |
|
|
|
command: > |
|
|
|
{{ kubectl }} get node {{ kube_override_hostname|default(inventory_hostname) }} |
|
|
|
-o jsonpath={ .spec.unschedulable } |
|
|
|
register: kubectl_node_schedulable |
|
|
|
delegate_to: "{{ groups['kube_control_plane'][0] }}" |
|
|
|
failed_when: false |
|
|
@ -48,11 +48,11 @@ |
|
|
|
- name: Node draining |
|
|
|
block: |
|
|
|
- name: Cordon node |
|
|
|
command: "{{ bin_dir }}/kubectl cordon {{ kube_override_hostname|default(inventory_hostname) }}" |
|
|
|
command: "{{ kubectl }} cordon {{ kube_override_hostname|default(inventory_hostname) }}" |
|
|
|
delegate_to: "{{ groups['kube_control_plane'][0] }}" |
|
|
|
|
|
|
|
- name: Check kubectl version |
|
|
|
command: "{{ bin_dir }}/kubectl version --client --short" |
|
|
|
command: "{{ kubectl }} version --client --short" |
|
|
|
register: kubectl_version |
|
|
|
delegate_to: "{{ groups['kube_control_plane'][0] }}" |
|
|
|
run_once: yes |
|
|
@ -70,7 +70,7 @@ |
|
|
|
|
|
|
|
- name: Drain node |
|
|
|
command: >- |
|
|
|
{{ bin_dir }}/kubectl drain |
|
|
|
{{ kubectl }} drain |
|
|
|
--force |
|
|
|
--ignore-daemonsets |
|
|
|
--grace-period {{ hostvars['localhost']['drain_grace_period_after_failure'] | default(drain_grace_period) }} |
|
|
@ -98,7 +98,7 @@ |
|
|
|
|
|
|
|
- name: Drain node - fallback with disabled eviction |
|
|
|
command: >- |
|
|
|
{{ bin_dir }}/kubectl drain |
|
|
|
{{ kubectl }} drain |
|
|
|
--force |
|
|
|
--ignore-daemonsets |
|
|
|
--grace-period {{ drain_fallback_grace_period }} |
|
|
@ -117,7 +117,7 @@ |
|
|
|
|
|
|
|
rescue: |
|
|
|
- name: Set node back to schedulable |
|
|
|
command: "{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf uncordon {{ inventory_hostname }}" |
|
|
|
command: "{{ kubectl }} uncordon {{ inventory_hostname }}" |
|
|
|
when: upgrade_node_uncordon_after_drain_failure |
|
|
|
- name: Fail after rescue |
|
|
|
fail: |
|
|
|