From 917006a4ec5e9726e360cb0a72a39f9cd7a3bacf Mon Sep 17 00:00:00 2001 From: Leo Ryu Date: Mon, 10 Oct 2022 17:25:38 +0800 Subject: [PATCH] feat(console): add clean iptabel script (#2089) --- tools/clean.sh | 51 +++++++++++++------ .../src/modules/cluster/constants/Config.ts | 9 +++- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/tools/clean.sh b/tools/clean.sh index 30e3f2ee1..acc5e435b 100755 --- a/tools/clean.sh +++ b/tools/clean.sh @@ -16,26 +16,47 @@ # WARRANTIES OF ANY KIND, either express or implied. See the License for the # specific language governing permissions and limitations under the License. -rm -rf /etc/kubernetes - -systemctl stop kubelet 2>/dev/null - -docker rm -f $(docker ps -aq) 2>/dev/null -systemctl stop docker 2>/dev/null +#!/bin/bash +# common +kubeadm reset -f +rm -fv /root/.kube/config +rm -rfv /etc/kubernetes +rm -rfv /var/lib/kubelet +rm -rfv /var/lib/etcd +rm -rfv /var/lib/cni +rm -rfv /etc/cni +rm -rfv /var/lib/tke-registry-api +rm -rfv /opt/tke-installer +rm -rfv /var/lib/postgresql /etc/core/token /var/lib/redis /storage /chart_storage ip link del cni0 2>/etc/null for port in 80 2379 6443 8086 {10249..10259} ; do fuser -k -9 ${port}/tcp done -rm -rfv /etc/kubernetes +# docker +docker rm -f $(docker ps -aq) 2>/dev/null +systemctl disable docker 2>/dev/null +systemctl stop docker 2>/dev/null rm -rfv /etc/docker -rm -fv /root/.kube/config -rm -rfv /var/lib/kubelet -rm -rfv /var/lib/cni -rm -rfv /etc/cni -rm -rfv /var/lib/etcd -rm -rfv /var/lib/postgresql /etc/core/token /var/lib/redis /storage /chart_storage - -systemctl start docker 2>/dev/null +ip link del docker0 2>/etc/null + +# containerd +nerdctl rm -f $(nerdctl ps -aq) 2>/dev/null +ip netns list | cut -d' ' -f 1 | xargs -n1 ip netns delete 2>/dev/null +systemctl disable containerd 2>/dev/null +systemctl stop containerd 2>/dev/null +rm -rfv /var/lib/nerdctl/* + +## ip link +ip link delete cilium_net 2>/dev/null +ip link delete cilium_vxlan 2>/dev/null +ip link delete flannel.1 2>/dev/null + +## iptables +iptables --flush +iptables --flush --table nat +iptables --flush --table filter +iptables --table nat --delete-chain +iptables --table filter --delete-chain \ No newline at end of file diff --git a/web/console/src/modules/cluster/constants/Config.ts b/web/console/src/modules/cluster/constants/Config.ts index 4ccdb2b43..1f63144c5 100644 --- a/web/console/src/modules/cluster/constants/Config.ts +++ b/web/console/src/modules/cluster/constants/Config.ts @@ -743,7 +743,14 @@ rm -rfv /var/lib/nerdctl/* ## ip link ip link delete cilium_net 2>/dev/null ip link delete cilium_vxlan 2>/dev/null -ip link delete flannel.1 2>/dev/null`; +ip link delete flannel.1 2>/dev/null + +## iptables +iptables --flush +iptables --flush --table nat +iptables --flush --table filter +iptables --table nat --delete-chain +iptables --table filter --delete-chain`; export enum GPUTYPE { PGPU = 'Physical',