一个拼写错误引发的问题:Failed to pull image "nignx": rpc error: code = Unknown desc = Error response from daemon: pull access denied for nignx, repository does not exist or may require 'docker login'
1|0问题
在引入阿里镜像加速器后,手动命令行部署nginx,发现pod的status为ImagePullBackOff
2|0排查思路
1.使用kubectl describe pod web-64d985c689-49d4b
检查pod的一些信息,发现最关键的一句是:Failed to pull image "nignx": rpc error: code = Unknown desc = Error response from daemon: pull access denied for nignx, repository does not exist or may require 'docker login',原来是nginx拼写成了nignx
[root@k8s-master ~]# kubectl describe pod web-64d985c689-49d4b
Name: web-64d985c689-49d4b Namespace: default Priority: 0 Node: k8s-node1/192.168.1.166 Start Time: Sat, 15 Oct 2022 16:03:42 +0800 Labels: app=web pod-template-hash=64d985c689 Annotations: <none> Status: Pending IP: 10.244.2.6 IPs: IP: 10.244.2.6 Controlled By: ReplicaSet/web-64d985c689 Containers: nignx: Container ID: Image: nignx Image ID: Port: <none> Host Port: <none> State: Waiting Reason: ImagePullBackOff Ready: False Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-597tl (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: default-token-597tl: Type: Secret (a volume populated by a Secret) SecretName: default-token-597tl Optional: false QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 5m54s default-scheduler Successfully assigned default/web-64d985c689-49d4b to k8s-node1 Normal Pulling 3m6s (x4 over 5m53s) kubelet, k8s-node1 Pulling image "nignx" Warning Failed 2m45s (x4 over 5m21s) kubelet, k8s-node1 Failed to pull image "nignx": rpc error: code = Unknown desc = Error response from daemon: pull access denied for nignx, repository does not exist or may require 'docker login' Warning Failed 2m45s (x4 over 5m21s) kubelet, k8s-node1 Error: ErrImagePull Normal BackOff 2m32s (x6 over 5m21s) kubelet, k8s-node1 Back-off pulling image "nignx" Warning Failed 51s (x13 over 5m21s) kubelet, k8s-node1 Error: ImagePullBackOff
2.依次删除deployment、pod、service, 当删除了deployment的时候,pod也会自动被删除
root@k8s-master ~]# kubectl delete deployment web -n default
deployment.apps "web" deleted [root@k8s-master ~]# kubectl get deployment -n default No resources found in default namespace. [root@k8s-master ~]# kubectl get pod -n default No resources found in default namespace. [root@k8s-master ~]# kubectl get pods No resources found in default namespace. [root@k8s-master ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d15h web1 NodePort 10.102.149.13 <none> 80:32398/TCP 14m [root@k8s-master ~]# kubectl delete svc web1 -n default service "web1" deleted
3|0重新部署
先删除上次的yaml文件,再按照顺序依次部署,最后发现pod的状态是Running
[root@k8s-master ~]# ls
anaconda-ks.cfg web1.yaml web.yaml [root@k8s-master ~]# rm -rf web* [root@k8s-master ~]# ls anaconda-ks.cfg [root@k8s-master ~]# kubectl create deployment web --image=nginx --dry-run -o yaml > web.yaml W1015 16:21:34.834821 55655 helpers.go:535] --dry-run is deprecated and can be replaced with --dry-run=client. [root@k8s-master ~]# ls anaconda-ks.cfg web.yaml [root@k8s-master ~]# kubectl apply -f web.yaml deployment.apps/web created [root@k8s-master ~]# kubectl get deployment NAME READY UP-TO-DATE AVAILABLE AGE web 0/1 1 0 15s [root@k8s-master ~]# kubectl expose deployment web --port=80 --type=NodePort --target-port=80 --name=web1 -o yaml > web1.yaml [root@k8s-master ~]# ls anaconda-ks.cfg web1.yaml web.yaml [root@k8s-master ~]# kubectl get deployment NAME READY UP-TO-DATE AVAILABLE AGE web 1/1 1 1 84s [root@k8s-master ~]# kubectl get pods NAME READY STATUS RESTARTS AGE web-5dcb957ccc-hmx7h 1/1 Running 0 91s [root@k8s-master ~]# kubectl apply -f web1.yaml Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply service/web1 configured [root@k8s-master ~]# kubectl get pods,svc NAME READY STATUS RESTARTS AGE pod/web-5dcb957ccc-hmx7h 1/1 Running 0 112s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d15h service/web1 NodePort 10.104.228.101 <none> 80:31425/TCP 35s
__EOF__

本文作者:cnhkzyy
本文链接:https://www.cnblogs.com/my_captain/p/16794475.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
本文链接:https://www.cnblogs.com/my_captain/p/16794475.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2017-10-15 html5 frameset5内嵌框架集
2017-10-15 Sublime Text3取消自动补全结束标签