K8s集群中flannel组件处于CrashLoopBackOff状态的解决思路

参考:
K8s问题【flannel一直重启问题,CrashLoopBackOff】
https://www.cnblogs.com/360linux/p/12933594.html
作为一名合格的管理者,首先查看日志

[root@master ~]# kubectl get pods -n kube-system
NAME                             READY   STATUS              RESTARTS   AGE
coredns-5bfd685c78-795kh         0/1     ContainerCreating   0          137m
coredns-5bfd685c78-rlzs2         0/1     ContainerCreating   0          137m
etcd-master                      1/1     Running             0          136m
kube-apiserver-master            1/1     Running             0          136m
kube-controller-manager-master   1/1     Running             0          136m
kube-flannel-ds-djr26            0/1     Error               15         63m
kube-flannel-ds-fk225            0/1     CrashLoopBackOff    10         30m
kube-flannel-ds-jhd6p            0/1     CrashLoopBackOff    17         63m
kube-proxy-6r25s                 1/1     Running             0          137m
kube-proxy-m8gxx                 1/1     Running             0          136m
kube-proxy-s2jb8                 1/1     Running             0          136m
kube-scheduler-master            1/1     Running             0          136m
[root@master ~]# kubectl logs kube-flannel-ds-djr26 -n kube-system
I0528 11:36:04.076849       1 main.go:201] Could not find valid interface matching enss33: error looking up interface enss33: route ip+net: no such network interface
I0528 11:36:04.077557       1 main.go:201] Could not find valid interface matching eth0: error looking up interface eth0: route ip+net: no such network interface
E0528 11:36:04.077564       1 main.go:225] Failed to find interface to use that matches the interfaces and/or regexes provided

由于flannel需要调用内核模块,请确保这些模块已经安装完成

加载ipvs相关内核模块
如果重新开机,需要重新加载(可以写在 /etc/rc.local 中开机自动加载)
# modprobe ip_vs
# modprobe ip_vs_rr
# modprobe ip_vs_wrr
# modprobe ip_vs_sh
# modprobe nf_conntrack_ipv4
查看是否加载成功
# lsmod | grep ip_vs
ip_vs_sh               12688  0 
ip_vs_wrr              12697  0 
ip_vs_rr               12600  0 
ip_vs                 145497  6 ip_vs_rr,ip_vs_sh,ip_vs_wrr
nf_conntrack          133095  9 ip_vs,nf_nat,nf_nat_ipv4,nf_nat_ipv6,xt_conntrack,nf_nat_masquerade_ipv4,nf_conntrack_netlink,nf_conntrack_ipv4,nf_conntrack_ipv6
libcrc32c              12644  4 xfs,ip_vs,nf_nat,nf_conntrack

你可能感兴趣的:(Kubernetes)