diff --git a/roles/remove-node/post-remove/tasks/main.yml b/roles/remove-node/post-remove/tasks/main.yml index a0dbcd6fe..6896ecba1 100644 --- a/roles/remove-node/post-remove/tasks/main.yml +++ b/roles/remove-node/post-remove/tasks/main.yml @@ -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 diff --git a/roles/remove-node/pre-remove/tasks/main.yml b/roles/remove-node/pre-remove/tasks/main.yml index 26cf42003..f287aa3dd 100644 --- a/roles/remove-node/pre-remove/tasks/main.yml +++ b/roles/remove-node/pre-remove/tasks/main.yml @@ -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 diff --git a/roles/upgrade/post-upgrade/tasks/main.yml b/roles/upgrade/post-upgrade/tasks/main.yml index d5d59025c..5e6309e17 100644 --- a/roles/upgrade/post-upgrade/tasks/main.yml +++ b/roles/upgrade/post-upgrade/tasks/main.yml @@ -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) diff --git a/roles/upgrade/pre-upgrade/tasks/main.yml b/roles/upgrade/pre-upgrade/tasks/main.yml index f47954b1c..e67c4a52e 100644 --- a/roles/upgrade/pre-upgrade/tasks/main.yml +++ b/roles/upgrade/pre-upgrade/tasks/main.yml @@ -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: