Fix can't remove etcd node (#6363)

* add remove_node_ip

* move remove_node_ip to remove etcd part

* fix: remove tail space

* fix: handle ubuntu: focal
This commit is contained in:
Sam Lin 2020-07-04 04:02:48 -05:00 committed by GitHub
parent 57eefdd458
commit 6bb47d8adb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 15 deletions

View file

@ -1,16 +1,4 @@
---
- name: Lookup node IP in kubernetes
shell: >-
{{ bin_dir }}/kubectl get nodes {{ node }}
-o jsonpath='{range.status.addresses[?(@.type=="InternalIP")]}{.address}{"\n"}{end}'
register: remove_node_ip
when:
- inventory_hostname in groups['etcd']
- ip is not defined
- access_ip is not defined
delegate_to: "{{ groups['etcd']|first }}"
failed_when: false
- name: Delete node
command: "{{ bin_dir }}/kubectl delete node {{ inventory_hostname }}"
delegate_to: "{{ groups['kube-master']|first }}"

View file

@ -1,4 +1,16 @@
---
- name: Lookup node IP in kubernetes
shell: >-
{{ bin_dir }}/kubectl get nodes {{ node }}
-o jsonpath='{range.status.addresses[?(@.type=="InternalIP")]}{.address}{"\n"}{end}'
register: remove_node_ip
when:
- inventory_hostname in groups['etcd']
- ip is not defined
- access_ip is not defined
delegate_to: "{{ groups['etcd']|first }}"
failed_when: false
- name: Set node IP
set_fact:
node_ip: "{{ ip | default(access_ip | default(remove_node_ip.stdout)) | trim }}"

View file

@ -1,5 +1,4 @@
---
- name: reset | include file with pre-reset tasks specific to the network_plugin if exists
include_tasks: "{{ (role_path + '/../network_plugin/' + kube_network_plugin + '/tasks/pre-reset.yml') | realpath }}"
when:
@ -142,7 +141,7 @@
- name: reset | unmount kubelet dirs
command: umount -f {{ item }}
with_items: '{{ mounted_dirs.stdout_lines }}'
with_items: "{{ mounted_dirs.stdout_lines }}"
register: umount_dir
retries: 4
until: umount_dir.rc == 0
@ -296,7 +295,7 @@
{%- else -%}
network
{%- endif -%}
{%- elif ansible_distribution == "Ubuntu" and ansible_distribution_release == "bionic" -%}
{%- elif ansible_distribution == "Ubuntu" and ansible_distribution_release in ["bionic", "focal"] -%}
systemd-networkd
{%- elif ansible_os_family == "Debian" -%}
networking