Respect kube_override_hostname during removal/upgrade (#6347)

* respect kube_override_hostname during removal/upgrade

* Use hostvars in loop
This commit is contained in:
Qasim Sarfraz 2020-07-13 16:18:40 +02:00 committed by GitHub
parent b347aefd61
commit feeb701c13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View file

@ -1,5 +1,5 @@
---
- 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 }}"
ignore_errors: yes

View file

@ -1,7 +1,7 @@
---
- name: cordon-node | Mark all nodes as unschedulable before drain
command: >-
{{ bin_dir }}/kubectl cordon {{ item }}
{{ bin_dir }}/kubectl cordon {{ hostvars[item]['kube_override_hostname']|default(item) }}
with_items:
- "{{ node.split(',') | default(groups['kube-node']) }}"
failed_when: false
@ -16,7 +16,7 @@
--ignore-daemonsets
--grace-period {{ drain_grace_period }}
--timeout {{ drain_timeout }}
--delete-local-data {{ item }}
--delete-local-data {{ hostvars[item]['kube_override_hostname']|default(item) }}
with_items:
- "{{ node.split(',') | default(groups['kube-node']) }}"
failed_when: false

View file

@ -1,6 +1,6 @@
---
- 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] }}"
when:
- needs_cordoning|default(false)

View file

@ -3,7 +3,7 @@
# Node NotReady: type = ready, status = Unknown
- name: See if node is in ready state
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 }'
register: kubectl_node_ready
delegate_to: "{{ groups['kube-master'][0] }}"
@ -14,7 +14,7 @@
# else unschedulable key doesn't exist
- name: See if node is schedulable
shell: >-
{{ bin_dir }}/kubectl get node {{ inventory_hostname }}
{{ bin_dir }}/kubectl get node {{ kube_override_hostname|default(inventory_hostname) }}
-o jsonpath='{ .spec.unschedulable }'
register: kubectl_node_schedulable
delegate_to: "{{ groups['kube-master'][0] }}"
@ -31,7 +31,7 @@
{%- endif %}
- 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] }}"
when: needs_cordoning
@ -61,7 +61,7 @@
--ignore-daemonsets
--grace-period {{ drain_grace_period }}
--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 %}
delegate_to: "{{ groups['kube-master'][0] }}"
when: