Fix the condition of drain on pre-remove task (#8634)

When running cluster.yml for new machines what containerd is already
install but Kubernetes cluster were not installed before, the task
"remove-node | List nodes" is failed like

  "changed": false,
  "cmd": [
    "/usr/local/bin/kubectl", "--kubeconfig",
    "/etc/kubernetes/admin.conf", "get", "nodes", "-o",
    "go-template={{ range .items }}{{ .metadata.name }}
    {{ "\n" }}{{ end }}"
   ],
   ..
   "stderr": "error: stat /etc/kubernetes/admin.conf: no such file or directory",

That was due to lack to check the existing Kubernetes cluster exists
or not before running "kubectl drain" command.
This adds the check to avoid the issue.
pull/8639/head
Kenichi Omichi 2022-03-21 01:39:10 -07:00 committed by GitHub
parent 5e67ebeb9e
commit 7b1dc600d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -63,6 +63,8 @@
apply: apply:
tags: tags:
- pre-remove - pre-remove
when:
- kubelet_systemd_unit_exists
- name: Stop kubelet - name: Stop kubelet
service: service:
name: kubelet name: kubelet
@ -89,6 +91,8 @@
apply: apply:
tags: tags:
- pre-remove - pre-remove
when:
- kubelet_systemd_unit_exists
- name: Stop kubelet - name: Stop kubelet
service: service:
name: kubelet name: kubelet
@ -114,6 +118,8 @@
apply: apply:
tags: tags:
- pre-remove - pre-remove
when:
- kubelet_systemd_unit_exists
- name: Stop kubelet - name: Stop kubelet
service: service:
name: kubelet name: kubelet