在做测试时,想把集群的calico换成fannel,卸载calico并安装fannel后,coredns无法启动,报错
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 36s default-scheduler Successfully assigned kubesphere-system/ks-installer-59fb465b7-xjhrv to k8snode1
Warning FailedCreatePodSandBox 36s kubelet, k8snode1 Failed create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "eee9a9b1d5641a80ed55b63a073b61ac4c80b8935ff93b9a8e1fde043a2c57fd" network for pod "ks-installer-59fb465b7-xjhrv": NetworkPlugin cni failed to set up pod "ks-installer-59fb465b7-xjhrv_kubesphere-system" network: error getting ClusterInformation: connection is unauthorized: Unauthorized, failed to clean up sandbox container "eee9a9b1d5641a80ed55b63a073b61ac4c80b8935ff93b9a8e1fde043a2c57fd" network for pod "ks-installer-59fb465b7-xjhrv": NetworkPlugin cni failed to teardown pod "ks-installer-59fb465b7-xjhrv_kubesphere-system" network: error getting ClusterInformation: connection is unauthorized: Unauthorized]
Normal SandboxChanged 7s (x3 over 35s) kubelet, k8snode1 Pod sandbox changed, it will be killed and re-created.
[root@k8snode1 ~]#
查看文档 Kubernetes官方文档
从文档中可以看出,kubelet从默认目录读取配置文件,如果有多个配置文件,那么它会应用按字母顺序首先出现的配置文件中的 CNI 插件
CNI的配置文件默认在/etc/cni/net.d/目录,进入目录查看,
删除对应calico遗留文件
rm -rf /etc/cni/net.d/calico-kubeconfig
rm -rf /etc/cni/net.d/10-calico.conf
最后重启node节点,coredns pod恢复在正常