[บันทึกกันลืม] แก้ปัญหา kube-flannel เกิด CrashLoopBackOff

Problem reproduce

kubectl describe pod/airflow-postgresql-0 -n airflow

result:

Warning  FailedCreatePodSandBox  26m                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "ad25da9611dd6ae39e9124ccbd497783db28b2e2de333128f18ee148e01952d7": plugin type="flannel" failed (add): loadFlannelSubnetEnv failed: open /run/flannel/subnet.env: no such file or directory

Resolution

edit file /run/flannel/subnet.env and paste the content *ON EVERY NODES*:

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

Hope this help