卸载 Calico

删除 k8s 资源

kubectl -n kube-system delete deploy calico-kube-controllers
kubectl -n kube-system delete ds calico-node
kubectl -n kube-system delete cm calico-config
# 删除 CRD 及相关资源
kubectl get crd -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | while read crd; do
  if ! echo $crd | grep '.crd.projectcalico.org$' >/dev/null; then
    continue
  fi

  for name in $(kubectl get $crd -o jsonpath='{.items[*].metadata.name}'); do
    kubectl delete $crd $name
  done
  kubectl delete crd $crd
done
# 其它资源
kubectl delete --ignore-not-found clusterrolebinding calico-node calico-kube-controllers
kubectl delete --ignore-not-found clusterrole calico-node calico-kube-controllers
kubectl delete --ignore-not-found sa -n kube-system calico-kube-controllers calico-node
kubectl delete --ignore-not-found pdb -n kube-system calico-kube-controllers

 

清理节点文件

在每个节点中执行:

rm -f /etc/cni/net.d/10-calico.conflist /etc/cni/net.d/calico-kubeconfig
rm -f /opt/cni/bin/calico /opt/cni/bin/calico-ipam

 

posted @ 2023-07-13 22:17  xiaohaoge  阅读(694)  评论(1编辑  收藏  举报