본문 바로가기

Cloud/Kubernetes

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

CNI를 flannel 로 이용할 때 coredns pod가 아래로그를 발생시키면서 생성 실패 할때가 있다.

Warning  FailedCreatePodSandBox  22h (x17 over 22h)  kubelet            (combined from similar events): Failed to create pod sandbox: rpc error: 
code = Unknown desc = failed to setup network for sandbox "7d14c4c56fe66d322fccb0f29d88dd658e4f52c2632998a40a4010cf4a1295a1": 
plugin type="flannel" failed (add): loadFlannelSubnetEnv failed: open /run/flannel/subnet.env: no such file or directory

 

말 그대로 /run/flannel/subnet.env가 없기 때문에 발생하는 오류이다.

$ ll /run/flannel/subnet.env
ls: cannot access '/run/flannel/subnet.env': No such file or directory

 

 

아래와 같이 생성시켜준다.

$ vi /run/flannel/subnet.env

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true
$ kubectl get pods --all-namespaces
NAMESPACE      NAME                              READY   STATUS    RESTARTS        AGE
..
..
kube-system    coredns-787d4945fb-4gkk6          1/1     Running   8 (9m44s ago)   22h
kube-system    coredns-787d4945fb-lrcjf          1/1     Running   8 (9m56s ago)   22h