kubectl get pod 出现CrashLoopBackOff Error
1.背景
使用kubectl 创建pod后出现RunContainerError
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
flaskapi 0/1 RunContainerError 0 (6s ago) 15s
2.解决方法
- 使用
kubectl describe pod <Your pod name>
查看pod状态Name: flaskapi Namespace: default Priority: 0 Node: kmaster1/192.168.0.165 Start Time: Mon, 31 Oct 2022 16:33:40 -0400 Labels: run=flaskapi Annotations: <none> Status: Running IP: 10.244.1.37 IPs: IP: 10.244.1.37 Containers: flaskapi: Container ID: docker://f676b664af055c3badc58fd7791cb65038ea53959d41133ba0e4c20f765e82c3 Image: wuwanga/flask-api:latest Image ID: docker-pullable://wuwanga/flask-api@sha256:bbd42e426c26714a539daedc9af522def7a6cd909373f6c5e1b6fad7dfa32833 Port: <none> Host Port: <none> Args: pod/flaskapi created State: Waiting Reason: CrashLoopBackOff Last State: Terminated Reason: ContainerCannotRun Message: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "pod/flaskapi": stat pod/flaskapi: no such file or directory: unknown Exit Code: 127 Started: Mon, 31 Oct 2022 16:33:57 -0400 Finished: Mon, 31 Oct 2022 16:33:57 -0400 Ready: False Restart Count: 2 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-gmxjm (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: kube-api-access-gmxjm: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 24s default-scheduler Successfully assigned default/flaskapi to kmaster1 Normal Pulled 15s kubelet Successfully pulled image "wuwanga/flask-api:latest" in 639.148627ms Normal Pulled 13s kubelet Successfully pulled image "wuwanga/flask-api:latest" in 665.620845ms Normal Pulling 1s (x3 over 16s) kubelet Pulling image "wuwanga/flask-api:latest" Normal Pulled 1s kubelet Successfully pulled image "wuwanga/flask-api:latest" in 609.033772ms Normal Created 0s (x3 over 15s) kubelet Created container flaskapi Warning Failed 0s (x3 over 14s) kubelet Error: failed to start container "flaskapi": Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "pod/flaskapi": stat pod/flaskapi: no such file or directory: unknown Warning BackOff <invalid> (x2 over <invalid>) kubelet Back-off restarting failed container
- 这个时候发现是由于创建的pod是临时资源加载造成的,这个时候在yaml添加
periodSeconds or timeoutSeconds
就可以了
[Reference]:
1. CrashLoopBackOff Error: Common Causes and Resolution
2. Kubernetes : Configure Liveness and Readiness Probes
Kubernetes ImagePullBackOff: Troubleshooting With Examples
How to Deploy docker image to Kubernetes
本作品采用《CC 协议》,转载必须注明作者和本文链接