Respect kube_override_hostname during removal/upgrade (#6347)
* respect kube_override_hostname during removal/upgrade * Use hostvars in loop
This commit is contained in:
parent
b347aefd61
commit
feeb701c13
4 changed files with 8 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: Delete node
|
- name: Delete node
|
||||||
command: "{{ bin_dir }}/kubectl delete node {{ inventory_hostname }}"
|
command: "{{ bin_dir }}/kubectl delete node {{ kube_override_hostname|default(inventory_hostname) }}"
|
||||||
delegate_to: "{{ groups['kube-master']|first }}"
|
delegate_to: "{{ groups['kube-master']|first }}"
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
- name: cordon-node | Mark all nodes as unschedulable before drain
|
- name: cordon-node | Mark all nodes as unschedulable before drain
|
||||||
command: >-
|
command: >-
|
||||||
{{ bin_dir }}/kubectl cordon {{ item }}
|
{{ bin_dir }}/kubectl cordon {{ hostvars[item]['kube_override_hostname']|default(item) }}
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ node.split(',') | default(groups['kube-node']) }}"
|
- "{{ node.split(',') | default(groups['kube-node']) }}"
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
--ignore-daemonsets
|
--ignore-daemonsets
|
||||||
--grace-period {{ drain_grace_period }}
|
--grace-period {{ drain_grace_period }}
|
||||||
--timeout {{ drain_timeout }}
|
--timeout {{ drain_timeout }}
|
||||||
--delete-local-data {{ item }}
|
--delete-local-data {{ hostvars[item]['kube_override_hostname']|default(item) }}
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ node.split(',') | default(groups['kube-node']) }}"
|
- "{{ node.split(',') | default(groups['kube-node']) }}"
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Uncordon node
|
- name: Uncordon node
|
||||||
command: "{{ bin_dir }}/kubectl --kubeconfig /etc/kubernetes/admin.conf uncordon {{ inventory_hostname }}"
|
command: "{{ bin_dir }}/kubectl --kubeconfig /etc/kubernetes/admin.conf uncordon {{ kube_override_hostname|default(inventory_hostname) }}"
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
when:
|
when:
|
||||||
- needs_cordoning|default(false)
|
- needs_cordoning|default(false)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# Node NotReady: type = ready, status = Unknown
|
# Node NotReady: type = ready, status = Unknown
|
||||||
- name: See if node is in ready state
|
- name: See if node is in ready state
|
||||||
shell: >-
|
shell: >-
|
||||||
{{ bin_dir }}/kubectl get node {{ inventory_hostname }}
|
{{ bin_dir }}/kubectl get node {{ kube_override_hostname|default(inventory_hostname) }}
|
||||||
-o jsonpath='{ range .status.conditions[?(@.type == "Ready")].status }{ @ }{ end }'
|
-o jsonpath='{ range .status.conditions[?(@.type == "Ready")].status }{ @ }{ end }'
|
||||||
register: kubectl_node_ready
|
register: kubectl_node_ready
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
# else unschedulable key doesn't exist
|
# else unschedulable key doesn't exist
|
||||||
- name: See if node is schedulable
|
- name: See if node is schedulable
|
||||||
shell: >-
|
shell: >-
|
||||||
{{ bin_dir }}/kubectl get node {{ inventory_hostname }}
|
{{ bin_dir }}/kubectl get node {{ kube_override_hostname|default(inventory_hostname) }}
|
||||||
-o jsonpath='{ .spec.unschedulable }'
|
-o jsonpath='{ .spec.unschedulable }'
|
||||||
register: kubectl_node_schedulable
|
register: kubectl_node_schedulable
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
- name: Cordon node
|
- name: Cordon node
|
||||||
command: "{{ bin_dir }}/kubectl cordon {{ inventory_hostname }}"
|
command: "{{ bin_dir }}/kubectl cordon {{ kube_override_hostname|default(inventory_hostname) }}"
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
when: needs_cordoning
|
when: needs_cordoning
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
--ignore-daemonsets
|
--ignore-daemonsets
|
||||||
--grace-period {{ drain_grace_period }}
|
--grace-period {{ drain_grace_period }}
|
||||||
--timeout {{ drain_timeout }}
|
--timeout {{ drain_timeout }}
|
||||||
--delete-local-data {{ 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 %}
|
||||||
delegate_to: "{{ groups['kube-master'][0] }}"
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
when:
|
when:
|
||||||
|
|
Loading…
Reference in a new issue