mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
fix: add Delete arp by kube-vip when uninstall/kubernetes (#2596)
Signed-off-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
parent
ff50e145ca
commit
71265adea8
|
|
@ -33,7 +33,7 @@
|
|||
{{- end }}
|
||||
|
||||
- name: Delete arp by kube-vip
|
||||
when: eq .kubernetes.control_plane_endpoint.type "vip"
|
||||
when: eq .kubernetes.control_plane_endpoint.type "kube_vip"
|
||||
command: |
|
||||
ip neigh show | grep {{ .kubernetes.control_plane_endpoint.kube_vip.address }} | awk '{print $1 " dev " $3}' | xargs -r -L1 ip neigh delete
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- name: Delete Node
|
||||
ignore_errors: true
|
||||
command: |
|
||||
kubeadm reset -f
|
||||
|
||||
- name: Stop kubelet service
|
||||
command: |
|
||||
rm -rf /etc/systemd/system/kubelet.service
|
||||
rm -rf /etc/systemd/system/kubelet.service.d
|
||||
systemctl daemon-reload
|
||||
|
||||
- name: Delete residue files
|
||||
command: |
|
||||
rm -rf /usr/local/bin/kubeadm && rm -rf /usr/local/bin/kubelet && rm -rf /usr/local/bin/kubectl
|
||||
rm -rf /var/lib/kubelet/
|
||||
rm -rf /etc/kubernetes/
|
||||
rm -rf .kube/config
|
||||
rm -rf /var/lib/etcd
|
||||
|
|
@ -1,53 +1,4 @@
|
|||
---
|
||||
- name: Reset kubeadm
|
||||
ignore_errors: true
|
||||
command: |
|
||||
kubeadm reset -f
|
||||
- include_tasks: kubernetes.yaml
|
||||
|
||||
- name: Stop kubelet service
|
||||
command: |
|
||||
rm -rf /etc/systemd/system/kubelet.service
|
||||
rm -rf /etc/systemd/system/kubelet.service.d
|
||||
systemctl daemon-reload
|
||||
|
||||
- name: Delete residue files
|
||||
command: |
|
||||
rm -rf /usr/local/bin/kubeadm && rm -rf /usr/local/bin/kubelet && rm -rf /usr/local/bin/kubectl
|
||||
rm -rf /var/lib/kubelet/
|
||||
# If /var/log/pods/ is not cleaned up, static pods may accumulate unexpected restarts due to lingering log files interfering with their lifecycle.
|
||||
rm -rf /var/log/pods/
|
||||
rm -rf /etc/kubernetes/
|
||||
rm -rf .kube/config
|
||||
|
||||
- name: Reset iptables
|
||||
command: |
|
||||
iptables -F
|
||||
iptables -X
|
||||
iptables -F -t nat
|
||||
iptables -X -t nat
|
||||
ipvsadm -C
|
||||
ip link del kube-ipvs0
|
||||
ip link del nodelocaldns
|
||||
ip link del cni0
|
||||
{{- if .kubernetes.kube_network_plugin | eq "flannel" }}
|
||||
ip link del flannel.1
|
||||
ip link del flannel-v6.1
|
||||
ip link del flannel-wg
|
||||
ip link del flannel-wg-v6
|
||||
{{- end }}
|
||||
{{- if .kubernetes.kube_network_plugin | eq "cilium" }}
|
||||
ip link del cilium_host
|
||||
ip link del cilium_vxlan
|
||||
{{- end }}
|
||||
{{- if .kubernetes.kube_network_plugin | eq "calico" }}
|
||||
ip -br link show | grep cali[a-f0-9]* | awk -F @ '{print $1}' | xargs -r -t -n 1 ip link del
|
||||
{{- end }}
|
||||
ip netns show 2>/dev/null | grep cni- | awk '{print $1}' | xargs -r -t -n 1 ip netns del
|
||||
|
||||
- name: Delete net.d
|
||||
command: |
|
||||
rm -rf /etc/cni/net.d/
|
||||
rm -rf /var/lib/cni/
|
||||
{{- if .kubernetes.kube_network_plugin | eq "calico" }}
|
||||
rm -rf /usr/local/bin/calicoctl
|
||||
{{- end }}
|
||||
- include_tasks: network.yaml
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
- name: Reset iptables
|
||||
command: |
|
||||
iptables -F
|
||||
iptables -X
|
||||
iptables -F -t nat
|
||||
iptables -X -t nat
|
||||
ipvsadm -C
|
||||
ip link del kube-ipvs0
|
||||
ip link del nodelocaldns
|
||||
ip link del cni0
|
||||
{{- if .cni.type | eq "flannel" }}
|
||||
ip link del flannel.1
|
||||
ip link del flannel-v6.1
|
||||
ip link del flannel-wg
|
||||
ip link del flannel-wg-v6
|
||||
{{- end }}
|
||||
{{- if .cni.type | eq "cilium" }}
|
||||
ip link del cilium_host
|
||||
ip link del cilium_vxlan
|
||||
{{- end }}
|
||||
{{- if .cni.type | eq "calico" }}
|
||||
ip -br link show | grep cali[a-f0-9]* | awk -F @ '{print $1}' | xargs -r -t -n 1 ip link del
|
||||
{{- end }}
|
||||
ip netns show 2>/dev/null | grep cni- | awk '{print $1}' | xargs -r -t -n 1 ip netns del
|
||||
|
||||
- name: Delete net.d
|
||||
command: |
|
||||
rm -rf /etc/cni/net.d/
|
||||
rm -rf /var/lib/cni/
|
||||
{{- if .cni.type | eq "calico" }}
|
||||
rm -rf /usr/local/bin/calicoctl
|
||||
{{- end }}
|
||||
|
||||
- name: Delete arp by kube-vip
|
||||
when: eq .kubernetes.control_plane_endpoint.type "kube_vip"
|
||||
command: |
|
||||
ip neigh show | grep {{ .kubernetes.control_plane_endpoint.kube_vip.address }} | awk '{print $1 " dev " $3}' | xargs -r -L1 ip neigh delete
|
||||
|
||||
|
|
@ -69,16 +69,16 @@ func (e playbookExecutor) Exec(ctx context.Context) (retErr error) {
|
|||
defer e.syncStatus(ctx, retErr)
|
||||
fmt.Fprint(e.logOutput, `
|
||||
|
||||
_ __ _ _ __
|
||||
| | / / | | | | / /
|
||||
| |/ / _ _| |__ ___| |/ / ___ _ _
|
||||
| \| | | | '_ \ / _ \ \ / _ \ | | |
|
||||
| |\ \ |_| | |_) | __/ |\ \ __/ |_| |
|
||||
\_| \_/\__,_|_.__/ \___\_| \_/\___|\__, |
|
||||
__/ |
|
||||
|___/
|
||||
|
||||
`)
|
||||
_ __ _ _ __
|
||||
| | / / | | | | / /
|
||||
| |/ / _ _| |__ ___| |/ / ___ _ _
|
||||
| \| | | | '_ \ / _ \ \ / _ \ | | |
|
||||
| |\ \ |_| | |_) | __/ |\ \ __/ |_| |
|
||||
\_| \_/\__,_|_.__/ \___\_| \_/\___|\__, |
|
||||
__/ |
|
||||
|___/
|
||||
|
||||
`)
|
||||
fmt.Fprintf(e.logOutput, "%s [Playbook %s] start\n", time.Now().Format(time.TimeOnly+" MST"), ctrlclient.ObjectKeyFromObject(e.playbook))
|
||||
klog.V(5).InfoS("deal project", "playbook", ctrlclient.ObjectKeyFromObject(e.playbook))
|
||||
pj, err := project.New(ctx, *e.playbook, true)
|
||||
|
|
|
|||
Loading…
Reference in New Issue