ls /etc/cni/net.d
查看CNI插件,可以得知使用的是flannel
cat /etc/cni/net.d/10-flannel.conflist
{ "name": "cbr0", "cniVersion": "0.3.1", "plugins": [ { "type": "flannel", "delegate": { "hairpinMode": true, "isDefaultGateway": true } }, { "type": "portmap", "capabilities": { "portMappings": true } } ] } |
如果是calico则显示
cat /etc/cni/net.d/10-calico.conflist
{ "name": "k8s-pod-network", "cniVersion": "0.3.1", "plugins": [ { "type": "calico", "log_level": "info", "log_file_path": "/var/log/calico/cni/cni.log", "datastore_type": "kubernetes", "nodename": "k8s-develop-master-1", "mtu": 1440, "ipam": { "type": "calico-ipam" }, "policy": { "type": "k8s" }, "kubernetes": { "kubeconfig": "/etc/cni/net.d/calico-kubeconfig" } }, { "type": "portmap", "snat": true, "capabilities": {"portMappings": true} }, { "type": "bandwidth", "capabilities": {"bandwidth": true} } ] } |
删除flannel的pod
使用一开始创建pod时同样的yaml文件
kubectl delete -f https://zhengyu1992.cn/file/deployment/kubeadm/flannel-1.1.2.yaml |
在集群各节点清理flannel网络的残留文件
ifconfig cni0 down ip link delete cni0 ifconfig flannel.1 down ip link delete flannel.1 rm -rf /var/lib/cni rm -rf /etc/cni/net.d |
部署calico3.25
wget --no-check-certificate https://projectcalico.docs.tigera.io/archive/v3.25/manifests/calico.yaml ##上面的镜像地址在国外拉去不到,我把一些镜像拉去下来传到了阿里云 kubectl create -f https://zhengyu1992.cn/file/deployment/kubeadm/calico-3.2.5.yaml |
官方最新版:
calico官方文档:
https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
利用operator部署3.26.3
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.3/manifests/tigera-operator.yaml kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.3/manifests/custom-resources.yaml |