找回密码
 注册
查看: 11|回复: 0

Kube flannel in CrashLoopBackOff status 解决办法

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2025-1-2 17:00:00 | 显示全部楼层 |阅读模式
kubectl describe pod -n kube-system kube-flannel-ds-amd64-42rl7
% k8 p( p2 @" r- x
* f" X% G5 f" g( ]2 \
/ l- W8 F( U% B9 W2 `2 i  x  O9 o

5 l3 H, K) ~, H: y/ Q/ L( e* x
5 A9 N) r1 f0 }5 t
Name:               kube-flannel-ds-amd64-42rl7Namespace:         
4 j2 Z6 }8 f& m4 x7 P kube-systemPriority:           0PriorityClassName:  <none>% b: {" ^3 I7 f. U5 n
Node:               node5/10.168.209.17& |, n) {) j5 Z: ^8 _/ E
Start Time:         Wed, 22 Aug 2018 16:47:10 +0300Labels:             app=flannel                    controller-revision-hash=911701653                    pod-template-generation=1                    tier=nodeAnnotations:        <none>Status:             RunningIP:                 10.168.209.17Controlled By:      DaemonSet/kube-flannel-ds-amd64Init Containers:  install-cni:    Container ID:  docker://eb7ee47459a54d401969b1770ff45b39dc5768b0627eec79e189249790270169    Image:         quay.io/coreos/flannel:v0.10.0-amd64    Image ID:      docker-pullable://quay.io/coreos/flannel@sha256:88f2b4d96fae34bfff3d46293f7f18d1f9f3ca026b4a4d288f28347fcb6580ac    Port:          <none>    Host Port:     <none>    Command:      cp    Args:      -f      /etc/kube-flannel/cni-conf.json      /etc/cni/net.d/10-flannel.conflist    State:          Terminated      Reason:       Completed      Exit Code:    0      Started:      Wed, 22 Aug 2018 16:47:24 +0300      Finished:     Wed, 22 Aug 2018 16:47:24 +0300    Ready:          True    Restart Count:  0    Environment:    <none>    Mounts:      /etc/cni/net.d from cni (rw)      /etc/kube-flannel/ from flannel-cfg (rw)      /var/run/secrets/kubernetes.io/serviceaccount from flannel-token-9wmch (ro)Containers:  kube-flannel:    Container ID:  docker://521b457c648baf10f01e26dd867b8628c0f0a0cc0ea416731de658e67628d54e    Image:         quay.io/coreos/flannel:v0.10.0-amd64    Image ID:      docker-pullable://quay.io/coreos/flannel@sha256:88f2b4d96fae34bfff3d46293f7f18d1f9f3ca026b4a4d288f28347fcb6580ac    Port:          <none>    Host Port:     <none>    Command:      /opt/bin/flanneld    Args:      --ip-masq      --kube-subnet-mgr    State:          Waiting      Reason:       CrashLoopBackOff    Last State:     Terminated      Reason:       Error      Exit Code:    1      Started:      Thu, 30 Aug 2018 10:15:04 +0300      Finished:     Thu, 30 Aug 2018 10:15:08 +0300    Ready:          False    Restart Count:  2136    Limits:      cpu:     100m      memory:  50Mi    Requests:      cpu:     100m      memory:  50Mi    Environment:      POD_NAME:       kube-flannel-ds-amd64-42rl7 (v1:metadata.name)      POD_NAMESPACE:  kube-system (v1:metadata.namespace)    Mounts:      /etc/kube-flannel/ from flannel-cfg (rw)      /run from run (rw)      /var/run/secrets/kubernetes.io/serviceaccount from flannel-token-9wmch (ro)Conditions:  Type              Status  Initialized       True  Ready             False  ContainersReady   False  PodScheduled      TrueVolumes:  run:    Type:          HostPath (bare host directory volume)    Path:          /run    HostPathType:  cni:    Type:          HostPath (bare host directory volume)    Path:          /etc/cni/net.d    HostPathType:  flannel-cfg:    Type:      ConfigMap (a volume populated by a ConfigMap)    Name:      kube-flannel-cfg    Optional:  false  flannel-token-9wmch:    Type:        Secret (a volume populated by a Secret)    SecretName:  flannel-token-9wmch    Optional:    falseQoS Class:       GuaranteedNode-Selectors:  beta.kubernetes.io/arch=amd64Tolerations:     node-role.kubernetes.io/master:NoSchedule                 node.kubernetes.io/disk-pressure:NoSchedule                 node.kubernetes.io/memory-pressure:NoSchedule                 node.kubernetes.io/not-ready:NoExecute                 node.kubernetes.io/unreachable:NoExecuteEvents:  Type     Reason   Age                  From            Message  ----     ------   ----                 ----            -------  Normal   Pulled   51m (x2128 over 7d)  kubelet, node5  Container image "quay.io/coreos/flannel:v0.10.0-amd64" already present on machine  Warning  BackOff  1m (x48936 over 7d)  kubelet, node5  Back-off restarting failed container
) r5 T8 A5 B3 Y  }# }: `  Q
# ~, X$ v+ e/ p* d: z" U& A检查kube-controller-manager.yaml

% U' x; y8 E) i0 T6 W, [
8 ^5 ]& A9 I2 X: N9 J1 ~! D) O" M/ |+ P

$ p5 }* ]3 O, s:apiVersion: v1* n" Q( X, `! v8 O
kind: Podmetadata:  annotations:    scheduler.alpha.kubernetes.io/critical-pod: ""  creationTimestamp: null  labels:    component: kube-controller-manager    tier: control-plane  name: kube-controller-manager  namespace: kube-systemspec:  containers:  - command:    - kube-controller-manager    - --address=127.0.0.1    - --allocate-node-cidrs=true    - --cluster-cidr=192.168.0.0/24    - --cluster-signing-cert-file=/etc/kubernetes/pki/ca.crt    - --cluster-signing-key-file=/etc/kubernetes/pki/ca.key    - --controllers=*,bootstrapsigner,tokencleaner    - --kubeconfig=/etc/kubernetes/controller-manager.conf    - --leader-elect=true    - --node-cidr-mask-size=24    - --root-ca-file=/etc/kubernetes/pki/ca.crt    - --service-account-private-key-file=/etc/kubernetes/pki/sa.key    - --use-service-account-credentials=true    image: k8s.gcr.io/kube-controller-manager-amd64:v1.11.2    imagePullPolicy: IfNotPresent    livenessProbe:      failureThreshold: 8      httpGet:        host: 127.0.0.1        path: /healthz        port: 10252        scheme: HTTP      initialDelaySeconds: 15      timeoutSeconds: 15    name: kube-controller-manager    resources:      requests:        cpu: 200m    volumeMounts:    - mountPath: /etc/ssl/certs      name: ca-certs      readOnly: true    - mountPath: /etc/kubernetes/controller-manager.conf      name: kubeconfig      readOnly: true    - mountPath: /usr/libexec/kubernetes/kubelet-plugins/volume/exec      name: flexvolume-dir    - mountPath: /etc/pki      name: etc-pki      readOnly: true    - mountPath: /etc/kubernetes/pki      name: k8s-certs      readOnly: true  hostNetwork: true  priorityClassName: system-cluster-critical  volumes:  - hostPath:      path: /etc/ssl/certs      type: DirectoryOrCreate    name: ca-certs  - hostPath:      path: /etc/kubernetes/controller-manager.conf      type: FileOrCreate    name: kubeconfig  - hostPath:      path: /usr/libexec/kubernetes/kubelet-plugins/volume/exec      type: DirectoryOrCreate    name: flexvolume-dir  - hostPath:      path: /etc/pki      type: DirectoryOrCreate    name: etc-pki  - hostPath:      path: /etc/kubernetes/pki      type: DirectoryOrCreate    name: k8s-certsstatus: {}
: K( _; F$ x. W, }
" P& y' W" ^3 M& S. Akubectl logs --namespace kube-system kube-flannel-ds-amd64-5fx2

* ^+ r( M: x/ ^6 L
! T* U, p6 }& h, F  q2 Q$ R  t- t

2 k* ~2 t+ f0 S  r! qpmain.go:475] Determining IP address of default interfacemain.go:488] * S& `7 d2 Z- u

& G& Z- O" y3 Z2 r! j0 S

1 X$ r6 V7 _2 V+ RUsing interface with name eth0 and address 10.168.209.14main.go:505] Defaulting external address to interface address (10.168.209.14)kube.go:131] Waiting 10m0s for node controller to synckube.go:294] Starting kube subnet managerkube.go:138] Node controller sync successfulmain.go:235] Created subnet manager: Kubernetes Subnet Manager - node2main.go:238] Installing signal handlersmain.go:353] Found network config - Backend type: vxlanvxlan.go:120] VXLAN config: VNI=1 Port=0 GBP=false DirectRouting=falsemain.go:280] Error registering network: failed to acquire lease: node "node2" pod cidr not assignedmain.go:333] Stopping shutdownHandler...8 H+ O. e+ o6 K" o1 b5 ~# C

! [# }8 a* i! @6 Q  P( J5 E
: Y) k1 e/ d$ p: U0 V

- C) j: q$ K$ s4 b9 V: S. V
- e+ q) j0 M( i- c  `: ?8 b. c2 @
cat /etc/kubernetes/manifests/kube-controller-manager.yaml | grep -i cluster-cidr- --cluster-cidr=172.168.10.0/24" o+ v7 L4 f0 M) r. j8 R9 ?# i2 R

- Q8 n' I5 N, H2 G% A$ w0 a- _6 d
5 m/ r- A! @; j) g2 M; B
6 f$ K' R' V  V% G0 B+ m! q, L0 J0 e6 f
kubectl patch node podname -p '{"spec":{"podCIDR":"172.168.10.0/24"}}'

1 j7 Y5 k1 j5 ^) W0 Z# B- f1 L$ e( M+ A  x: D$ r1 ]2 p
! W. m3 `. N8 S3 V+ Z1 }
例如:kubectl patch node slave-node-1 -p '{"spec":{"podCIDR":"172.168.10.0/24"}}'6 ?- I6 [5 a5 i# U# S& u

1 q/ {2 ]8 c5 [5 i7 D$ Z. q1 w! i

# `: W* F0 ?+ Z% e1 x* C% @( b0 usudo ifconfig cni0 down;7 m: Q) q% \$ n0 K5 R& }8 e
sudo ifconfig flannel.1 down;
" O" e$ v# Q! A
sudo ip link delete cni0;
1 M- {! K4 P! n" P1 v! G' gsudo ip link delete flannel.1;
To fix this, please following the step below:
  • Step 0: Reset all Nodes within your Cluster. Run all nodes with: o9 N4 B' I/ [8 l& w
kubeadm reset --force;
  • Step 1: Down Interface cni0 and flannel.1.
    5 j' @* k8 [, g! p4 a
sudo ifconfig cni0 down;
8 O, v" J4 X  H3 t9 i, Z: H+ tsudo ifconfig flannel.1 down;
  • Step 2: Delete Interface cni0 and flannel.1.
    2 H) J  m" x5 c
sudo ip link delete cni0;+ v: Q: x' `* g( e8 {7 @
sudo ip link delete flannel.1;
  • Step 3: Remove all items within /etc/cni/net.d/.
    ) W: C4 l+ s) W- |% b  ^, U& ^
sudo rm -rf /etc/cni/net.d/;
  • Step 4: Re-Bootstrap your Kubernetes Cluster again.$ V: B/ k' q" H' q- [: X
kubeadm init --control-plane-endpoint="..." --pod-network-cidr=10.244.0.0/16;
  • Step 5: Re-deploy CNIs.) g/ S! }0 q0 t" h& E- {* F) {
  • Step 6: Restart your CNIs, here I used Container Daemon (Containerd).
    . r1 S2 q9 Y" E' ]! e: \: E* E
systemctl restart containerd;
0 {* u# T+ z1 N6 R& O' i
3 T+ d+ t& v6 F5 S& f7 l

$ ~8 S4 ~/ ?& K9 c
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:26 , Processed in 0.017056 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表