remove-etcd-node: cleanups, correct change semantics
parent
2a52e5f08c
commit
ee0d9c5428
|
@ -30,7 +30,8 @@
|
||||||
roles:
|
roles:
|
||||||
- { role: kubespray-defaults, when: reset_nodes | default(True) | bool }
|
- { role: kubespray-defaults, when: reset_nodes | default(True) | bool }
|
||||||
- { role: remove-node/pre-remove, tags: pre-remove }
|
- { 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 }
|
- { role: reset, tags: reset, when: reset_nodes | default(True) | bool }
|
||||||
|
|
||||||
# Currently cannot remove first control plane node or first etcd node
|
# Currently cannot remove first control plane node or first etcd node
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
{{ kubectl }} get nodes {{ node }}
|
{{ kubectl }} get nodes {{ node }}
|
||||||
-o jsonpath-as-json='{.status.addresses[?(@.type=="InternalIP")].address}'
|
-o jsonpath-as-json='{.status.addresses[?(@.type=="InternalIP")].address}'
|
||||||
register: k8s_node_ips
|
register: k8s_node_ips
|
||||||
|
changed_when: false
|
||||||
when:
|
when:
|
||||||
- groups['kube_control_plane'] | length > 0
|
- groups['kube_control_plane'] | length > 0
|
||||||
- ('etcd' in group_names)
|
- ip is not defined
|
||||||
- ip is not defined
|
- access_ip is not defined
|
||||||
- access_ip is not defined
|
delegate_to: "{{ groups['kube_control_plane'] | first }}"
|
||||||
delegate_to: "{{ groups['etcd'] | first }}"
|
|
||||||
|
|
||||||
- name: Remove etcd member from cluster
|
- name: Remove etcd member from cluster
|
||||||
environment:
|
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_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"
|
ETCDCTL_ENDPOINTS: "https://127.0.0.1:2379"
|
||||||
delegate_to: "{{ groups['etcd'] | first }}"
|
delegate_to: "{{ groups['etcd'] | first }}"
|
||||||
when: ('etcd' in group_names)
|
|
||||||
block:
|
block:
|
||||||
- name: Lookup members infos
|
- name: Lookup members infos
|
||||||
command: "{{ bin_dir }}/etcdctl member list"
|
command: "{{ bin_dir }}/etcdctl member list"
|
||||||
|
@ -37,3 +36,5 @@
|
||||||
- member
|
- member
|
||||||
- remove
|
- remove
|
||||||
- "{{ ((etcd_members.stdout_lines | select('contains', '//' + node_ip + ':'))[0] | split(','))[0] }}"
|
- "{{ ((etcd_members.stdout_lines | select('contains', '//' + node_ip + ':'))[0] | split(','))[0] }}"
|
||||||
|
register: etcd_removal_output
|
||||||
|
changed_when: "'Removed member' in etcd_removal_output.stdout"
|
||||||
|
|
Loading…
Reference in New Issue