Skip to content

Commit

Permalink
remove-etcd-node: cleanups, correct change semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
VannTen committed Sep 24, 2024
1 parent 2a52e5f commit ee0d9c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion playbooks/remove_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions roles/remove-node/remove-etcd-node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Expand All @@ -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"

0 comments on commit ee0d9c5

Please sign in to comment.