How Do You Solve the Kubernetes Error “networkPlugin cni failed to set up pod network: open /run/flannel/subnet.env: no such file or directory”?

Problem scenario
You run kubectl describe pods. You see a message in the output that says

networkPlugin cni failed to set up pod network: open /run/flannel/subnet.env: no such file or directory.

How do you fix this?

Possible Solution #1
Log into every worker node. Make sure it has /run/flannel/subnet.env with the following four lines:

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

(This solution was adapted from https://www.programmersought.com/article/7824768991/)

Possible Solution #2
Run this: kubectl get pods. It could be that the error message shows up, but there is no problem. If the problem has since subsided, it may be ignorable.

Possible Solution #3
"More often than not, there is another issue that could be causing this error that needs to be investigated first."
(This one was taken from this Microsoft website.)

Leave a comment

Your email address will not be published. Required fields are marked *