Skip to content

Commit

Permalink
feat(console): add clean iptabel script
Browse files Browse the repository at this point in the history
  • Loading branch information
leonarliu committed Sep 20, 2022
1 parent 9c8f476 commit 7e52188
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
51 changes: 36 additions & 15 deletions tools/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion web/console/src/modules/cluster/constants/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 7e52188

Please sign in to comment.