0.vps-k8s-clear.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. systemctl disable --now kubelet
  3. systemctl disable --now kube-proxy
  4. systemctl disable --now kube-scheduler
  5. systemctl disable --now kube-controller-manager
  6. systemctl disable --now kube-apiserver
  7. systemctl disable --now etcd
  8. rm -rf /etc/etcd /etc/kubernetes
  9. rm -rf /etc/cni/net.d
  10. rm -rf /var/lib/cni/
  11. rm -rf /var/lib/etcd
  12. crictl ps -q | xargs crictl stop
  13. crictl ps -a -q | xargs crictl rm
  14. mount -l | grep '/var/lib/kubelet' | awk '{print $3}' | xargs umount
  15. rm -rf /var/lib/kubelet
  16. systemctl stop containerd
  17. rm -rf /var/lib/containerd
  18. systemctl start containerd
  19. export_addr=$(curl ipv4.icanhazip.com)
  20. sed "/$export_addr .*/d" /etc/hosts -i
  21. markS="##### ca-etcd-k8s envionment #####"
  22. markE="##################################"
  23. remove_env_profile() {
  24. sed "/$markS/d" /etc/profile -i
  25. sed "/export expiry=.*/d" /etc/profile -i
  26. sed "/export ca_config_path=.*/d" /etc/profile -i
  27. sed "/export etcd_pki_path=.*/d" /etc/profile -i
  28. sed "/export etcd_ips_list=.*/d" /etc/profile -i
  29. sed "/export k8s_pki_path=.*/d" /etc/profile -i
  30. sed "/export k8s_ips_list=.*/d" /etc/profile -i
  31. sed "/export export_addr=.*/d" /etc/profile -i
  32. sed "/export export_port=.*/d" /etc/profile -i
  33. sed "/$markE/d" /etc/profile -i
  34. }
  35. remove_env_profile