在服务完成阶段性部署,coredns内存溢出问题解决后,仍然存在状态异常。

[root@lolicp ~]# kubectl get pod -o wide --all-namespaces
NAMESPACE            NAME                                      READY   STATUS             RESTARTS   AGE   IP                NODE    NOMINATED NODE   READINESS GATES
kube-system          coredns-876c489b-trq55                    0/1     CrashLoopBackOff   7          24m   10.244.1.61       node2   <none>           <none>
kube-system          coredns-876c489b-xsb4d                    0/1     CrashLoopBackOff   6          23m   10.244.0.67       node1   <none>           <none>
[root@lolicp ~]# kubectl describe pod -n kube-system  coredns-876c489b-xsb4d
  Warning  FailedCreatePodSandBox  3m43s                  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "212b1d942b7081a9a10e5119a5f407b819f6d1d6f2cf5e4d38f90d5f913c3fbf" network for pod "coredns-876c489b-xsb4d": networkPlugin cni failed to set up pod "coredns-876c489b-xsb4d_kube-system" network: open /run/flannel/subnet.env: no such file or directory
  Normal   SandboxChanged          3m37s (x12 over 4m2s)  kubelet            Pod sandbox changed, it will be killed and re-created.
  Normal   Pulled                  3m36s                  kubelet            Container image "lolicp:8424/coredns/coredns:v1.8.0" already present on machine
  Normal   Created                 3m36s                  kubelet            Created container coredns
  Warning  FailedCreatePodSandBox  3m20s (x2 over 3m24s)  kubelet            (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "663d2c007b193113f81bc9ea5f90e325326c50424466b0b9c969a942aa6a90c3" network for pod "coredns-876c489b-xsb4d": networkPlugin cni failed to set up pod "coredns-876c489b-xsb4d_kube-system" network: open /run/flannel/subnet.env: no such file or directory

解决办法

重启flannel组件服务
[root@lolicp ~]# kubectl get pod -o wide -n kube-system -l app=flannel|awk 'NR>1 {print $1}'|xargs -i kubectl delete pod -n kube-system {}
重启coredns组件服务
[root@lolicp ~]# kubectl get deploy -n kube-system -o wide
NAME             READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS       IMAGES                                                           SELECTOR
coredns          0/2     2            0           21h   coredns          lolicp:8424/coredns/coredns:v1.8.0                            k8s-app=kube-dns
[root@lolicp ~]# kubectl get pod -o wide -n kube-system -l k8s-app=kube-dns|awk 'NR>1 {print $1}'|xargs -i kubectl delete pod -n kube-system {}
验证
[root@hxb-node1 ~]# kubectl get pod -o wide -n kube-system
NAME                              READY   STATUS    RESTARTS   AGE     IP                NODE    NOMINATED NODE   READINESS GATES
coredns-876c489b-2htwk            1/1     Running   1          3m52s   10.244.1.62       node2   <none>           <none>
coredns-876c489b-lft4f            1/1     Running   1          3m44s   10.244.0.68       node1   <none>           <none>
END

本文标题:重启服务器后k8s集群coredns组件状态为CrashLoopBackOff

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/kubernetes/202301623.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归 (lolicp.com) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2023 年 09 月 01 日
如果觉得我的文章对你有用,请随意赞赏