remove-etcd-node: cleanups, correct change semantics

pull/11507/head
Max Gautier 2024-09-05 05:53:28 +02:00
parent 2a52e5f08c
commit ee0d9c5428
No known key found for this signature in database
2 changed files with 9 additions and 7 deletions

View File

@ -30,7 +30,8 @@
roles:
- { role: kubespray-defaults, when: reset_nodes | default(True) | bool }
- { role: remove-node/pre-remove, tags: pre-remove }
- { role: remove-node/remove-etcd-node }
- role: remove-node/remove-etcd-node
when: "'etcd' in group_names"
- { role: reset, tags: reset, when: reset_nodes | default(True) | bool }
# Currently cannot remove first control plane node or first etcd node

View File

@ -4,12 +4,12 @@
{{ kubectl }} get nodes {{ node }}
-o jsonpath-as-json='{.status.addresses[?(@.type=="InternalIP")].address}'
register: k8s_node_ips
changed_when: false
when:
- groups['kube_control_plane'] | length > 0
- ('etcd' in group_names)
- ip is not defined
- access_ip is not defined
delegate_to: "{{ groups['etcd'] | first }}"
- groups['kube_control_plane'] | length > 0
- ip is not defined
- access_ip is not defined
delegate_to: "{{ groups['kube_control_plane'] | first }}"
- name: Remove etcd member from cluster
environment:
@ -19,7 +19,6 @@
ETCDCTL_CACERT: "{{ kube_cert_dir + '/etcd/ca.crt' if etcd_deployment_type == 'kubeadm' else etcd_cert_dir + '/ca.pem' }}"
ETCDCTL_ENDPOINTS: "https://127.0.0.1:2379"
delegate_to: "{{ groups['etcd'] | first }}"
when: ('etcd' in group_names)
block:
- name: Lookup members infos
command: "{{ bin_dir }}/etcdctl member list"
@ -37,3 +36,5 @@
- member
- remove
- "{{ ((etcd_members.stdout_lines | select('contains', '//' + node_ip + ':'))[0] | split(','))[0] }}"
register: etcd_removal_output
changed_when: "'Removed member' in etcd_removal_output.stdout"