kubekey/builtin/core/roles/etcd/tasks/expansion.yaml
liujian 3885b443ac
fix: change builtin/core architectures (#2718)
Signed-off-by: redscholar <blacktiledhouse@gmail.com>
2025-08-22 21:59:40 +08:00

37 lines
1.3 KiB
YAML

- name: Expansion | Expand cluster on existing etcd nodes
when: .etcd_install_LoadState.stdout | eq "loaded"
block:
- name: Expansion | Update /etc/etcd.env configuration file
template:
src: etcd.env
dest: /etc/etcd.env
- name: Expansion | Restart etcd service
command: |
systemctl restart etcd.service
- name: Expansion | Verify etcd service becomes healthy within 1 minute
command: |
for ((i=1; i<=12; i++)); do
if ETCDCTL_API=3 etcdctl \
--endpoints=https://localhost:2379 \
--cacert=/etc/ssl/etcd/ssl/ca.crt \
--cert=/etc/ssl/etcd/ssl/server.crt \
--key=/etc/ssl/etcd/ssl/server.key \
endpoint health >/dev/null 2>&1; then
echo "✅ etcd is health"
exit 0
fi
sleep 5
done
echo "❌ etcd etcd is not health in 1 minute"
exit 1
- name: Expansion | Add new etcd member from non-installed node
when: .etcd_install_LoadState.stdout | eq "not-found"
delegate_to: "{{ .installed_etcd }}"
command: |
ETCDCTL_API=3 etcdctl \
--endpoints=https://localhost:2379 \
--cacert=/etc/ssl/etcd/ssl/ca.crt \
--cert=/etc/ssl/etcd/ssl/server.crt \
--key=/etc/ssl/etcd/ssl/server.key \
member add {{ .inventory_hostname }}