kubekey/builtin/core/playbooks/delete_cluster.yaml
redscholar c044b8aa26
fix: scaling down etcd
Signed-off-by: redscholar <blacktiledhouse@gmail.com>
2025-12-04 10:38:48 +08:00

45 lines
1.2 KiB
YAML

---
- hosts:
- all
roles:
- native/root
# Load default variables and perform prechecks on all hosts
- hosts:
- all
gather_facts: true
roles:
- defaults
- hosts:
- k8s_cluster
roles:
- uninstall/kubernetes
- role: uninstall/cri
when:
- .delete.cri
- .groups.image_registry | default list | has .inventory_hostname | not
post_tasks:
- name: delete localDNS file
ignore_errors: true
loop: "{{ .native.localDNS | toJson }}"
command: |
sed -i ':a;$!{N;ba};s@# kubekey hosts BEGIN.*# kubekey hosts END@@' {{ .item }}
sed -i ':a;$!{N;ba};s@# kubekey kubernetes control_plane_endpoint BEGIN.*# kubekey kubernetes control_plane_endpoint END@@' {{ .item }}
sed -i ':a;$!{N;ba};s@# kubekey image_registry control_plane_endpoint BEGIN.*# kubekey image_registry control_plane_endpoint END@@' {{ .item }}
when: .delete.dns
- hosts:
- etcd
roles:
- role: etcd/scaling_down
when:
- .delete.etcd
- .etcd.deployment_type | eq "external"
- hosts:
- image_registry
roles:
- role: uninstall/image-registry
when:
- .delete.image_registry