解决K8S报错: network open /run/flannel/subnet.env: no such file or directory

K8S network: open /run/flannel/subnet.env: no such file or directory

Posted by alovn on November 15, 2020

升级K8S到v1.19.4后,执行部署pod后状态一直是 ContainerCreating,查看下详情,可以看到:

1
2
3
4
5
6
kubectl describe pod nginx-7848d4b86f-tqrg2

 Failed to create pod sandbox: rpc error:
 code = Unknown desc = failed to set up sandbox container "f4be859a7865c6338c0e07351435bce8c59da26d2a5a1a05cbbf56f48143ed48" 
network for pod "nginx-7848d4b86f-tqrg2": networkPlugin cni failed to set up pod "nginx-7848d4b86f-tqrg2_default" 
network: open /run/flannel/subnet.env: no such file or directory

可以看下master节点上是有这个文件的:

1
2
3
4
5
6
cat  /run/flannel/subnet.env

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true

各个worker节点上并没有找到这个文件,只要把这个文件拷贝到各个worker节点,然后删除未启动的pod,稍等片刻就会自动重新创建完成pod了。