当前位置: 首页 > 工具软件 > PortMap > 使用案例 >

k8s部署flannel时报failed to find plugin “portmap“ in path [/opt/cni/bin]]

壤驷阳波
2023-12-01

现象

# 部署好flannel后,部署coredns,报错,检查/opt/cni/bin目录下,发现没有文件
	Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "3bf7500d12ae67983dcd2795d2feb168dceb563ac78afa5508d973db84ed5b47" network for pod "coredns-6f4c9cb7c5-jg5mj": networkPlugin cni failed to set up pod "coredns-6f4c9cb7c5-jg5mj_kube-system" network: failed to find plugin "loopback" in path [/opt/cni/bin], failed to clean up sandbox container "3bf7500d12ae67983dcd2795d2feb168dceb563ac78afa5508d973db84ed5b47" network for pod "coredns-6f4c9cb7c5-jg5mj": networkPlugin cni failed to teardown pod "coredns-6f4c9cb7c5-jg5mj_kube-system" network: failed to find plugin "portmap" in path [/opt/cni/bin]]

# kubelet 日志
	Unable to update cni config: no valid networks found in /etc/cni/net.d

方法一

# 解决办法
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

# 安装软件,存在BUG:这个会自己下载kubelet,对于二进制安装的K8S来说不可能用这种方法,且卸载的时候还会卸掉一些自己配置的东西
	yum clean all && yum makecache && yum -y install kubernetes-cni

方法二

# 解决办法

# 下载cni插件,下载后解压到/opt/cni/bin之后kubelet,然后重新部署flannel和coredns
	https://github.com/containernetworking/plugins/releases
 类似资料: