1.使用kubectl get pod
檢視pod狀態出現status為ErrImageNeverPull
NAME READY STATUS RESTARTS AGE
flaskapi-deployment-59bcb745ff-4x2d2 0/1 ErrImageNeverPull 0 3m58s
flaskapi-deployment-59bcb745ff-6mgqx 0/1 ErrImageNeverPull 0 3m58s
flaskapi-deployment-59bcb745ff-7xtgf 0/1 ErrImageNeverPull 0 3m58s
- 使用
kubectl describe pod <pod_name>
檢視相應pod的狀態情況
由此可以看出原因是pull本地的image出現了問題Name: flaskapi-deployment-59bcb745ff-4x2d2 Namespace: default Priority: 0 Node: kmaster1/192.168.0.165 Start Time: Mon, 31 Oct 2022 11:23:41 -0400 Labels: app=flaskapi pod-template-hash=59bcb745ff Annotations: <none> Status: Pending IP: 10.244.1.24 IPs: IP: 10.244.1.24 Controlled By: ReplicaSet/flaskapi-deployment-59bcb745ff Containers: flaskapi: Container ID: Image: flask-api Image ID: Port: 5000/TCP Host Port: 0/TCP State: Waiting Reason: ErrImageNeverPull Ready: False Restart Count: 0 Environment: db_root_password: <set to the key 'db_root_password' in secret 'flaskapi-secrets'> Optional: false db_name: flaskapi Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-nm6gp (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: kube-api-access-nm6gp: 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 5m default-scheduler Successfully assigned default/flaskapi-deployment-59bcb745ff-4x2d2 to kmaster1 Warning Failed 2m57s (x12 over 4m53s) kubelet Error: ErrImageNeverPull Warning ErrImageNeverPull 2m44s (x13 over 4m53s) kubelet Container image "flask-api" is not present with pull policy of Never
- 解決方案
把deployment.yaml檔案中的imagePullPolicy: Never
刪除掉就好了
[References]: Error: ErrImageNeverPull
本作品採用《CC 協議》,轉載必須註明作者和本文連結