“K8s基础”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
第50行: 第50行:
 
[ k8s中正确删除一个pod  k8s中正确删除一个pod ]
 
[ k8s中正确删除一个pod  k8s中正确删除一个pod ]
  
 +
 +
=coredns状态为ImagePullBackOff问题=
 +
<pre>
 +
 +
kubectl get pods --all-namespaces
 +
 +
kube-system  coredns-7f6cbbb7b8-knhl8            0/1    ImagePullBackOff  0              24h
 +
kube-system  coredns-7f6cbbb7b8-lt4k5            0/1    ImagePullBackOff  0              24h
 +
 +
 +
解决办法:
 +
 +
确定pod所使用的镜像
 +
 +
kubectl get pods coredns-7f6cbbb7b8-knhl8 -n kube-system -o yaml | grep image
 +
 +
 +
 +
 +
    image: registry.aliyuncs.com/google_containers/coredns:v1.8.4
 +
    imagePullPolicy: IfNotPresent
 +
  - image: registry.aliyuncs.com/google_containers/coredns:v1.8.4
 +
    imageID: ""
 +
        message: Back-off pulling image "registry.aliyuncs.com/google_containers/coredns:v1.8.4"
 +
 +
root@k8s-master:~# docker pull registry.aliyuncs.com/google_containers/coredns:v1.8.4
 +
Error response from daemon: manifest for registry.aliyuncs.com/google_containers/coredns:v1.8.4 not found: manifest unknown: manifest unknown
 +
 +
拉个latest 再别名
 +
docker pull registry.aliyuncs.com/google_containers/coredns
 +
 +
root@k8s-master:~# docker  images | grep coredns
 +
registry.aliyuncs.com/google_containers/coredns                  latest    8d147537fb7d  3 months ago  47.6MB
 +
 +
强制 改一下 tag
 +
root@k8s-master:~# docker tag 8d147537fb7d  registry.aliyuncs.com/google_containers/coredns:v1.8.4
 +
 +
root@k8s-master:~# kubectl get pods --all-namespaces | grep coredns 
 +
kube-system  coredns-7f6cbbb7b8-knhl8            1/1    Running            0                24h
 +
kube-system  coredns-7f6cbbb7b8-lt4k5            1/1    Running            0                24h
 +
root@k8s-master:~#
 +
 +
 +
root@k8s-master:~#  kubectl get all -n kube-system
 +
NAME                                    READY  STATUS            RESTARTS        AGE
 +
pod/coredns-7f6cbbb7b8-knhl8            0/1    ImagePullBackOff  0              24h
 +
pod/coredns-7f6cbbb7b8-lt4k5            0/1    ImagePullBackOff  0              24h
 +
 +
docker pull registry.aliyuncs.com/google_containers/coredns
 +
 +
</pre>
 +
 +
[https://blog.csdn.net/weifangwei100/article/details/118940876  coredns状态为ImagePullBackOff问题]
 +
 +
[https://blog.csdn.net/hbuxiaofei/article/details/117632562  k8s解决coredns 的ImagePullBackOff 和ErrImagePull 问题]
 +
 +
https://stackoverflow.com/questions/53559291/kubernetes-coredns-in-crashloopbackoff
 +
 +
[https://blog.csdn.net/qq_24046745/article/details/93988920  Kubernetes CoreDNS 状态是 CrashLoopBackOff 解决思路]
  
 
=CrashLoopBackOff的解决方法=
 
=CrashLoopBackOff的解决方法=

2021年8月30日 (一) 07:26的版本

base

#使用glusterfs做存储,不懂glusterfs的请参考其他文章

k8s-imagePullPolicy拉取策略

imagePullPolicy: Always 总是拉取 pull  以前好像是这个默认值
imagePullPolicy: IfNotPresent 默认值,本地有则使用本地镜像,不拉取
imagePullPolicy: Never 只使用本地镜像,从不拉取

k8s删除pod

1、先删除pod2、再删除对应的deployment否则只是删除pod是不管用的,还会看到pod,因为deployment.yaml文件中定义了副本数量


实例如下:

删除pod

[root@test2 ~]# kubectl get pod -n jenkins
NAME                        READY     STATUS    RESTARTS   AGE
jenkins2-8698b5449c-grbdm   1/1       Running   0          8s
[root@test2 ~]# kubectl delete pod jenkins2-8698b5449c-grbdm -n jenkins
pod "jenkins2-8698b5449c-grbdm" deleted

查看pod仍然存储

[root@test2 ~]# kubectl get pod -n jenkins
NAME                        READY     STATUS    RESTARTS   AGE
jenkins2-8698b5449c-dbqqb   1/1       Running   0          8s
[root@test2 ~]# 

删除deployment

[root@test2 ~]# kubectl get deployment -n jenkins
NAME       DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
jenkins2   1         1         1            1           17h
[root@test2 ~]# kubectl delete deployment jenkins2 -n jenkins

再次查看pod消失

deployment.extensions "jenkins2" deleted
[root@test2 ~]# kubectl get deployment -n jenkins
No resources found.
[root@test2 ~]# 
[root@test2 ~]# kubectl get pod -n jenkins
No resources found.

[ k8s中正确删除一个pod k8s中正确删除一个pod ]


coredns状态为ImagePullBackOff问题


kubectl get pods --all-namespaces

kube-system   coredns-7f6cbbb7b8-knhl8             0/1     ImagePullBackOff   0               24h
kube-system   coredns-7f6cbbb7b8-lt4k5             0/1     ImagePullBackOff   0               24h


解决办法:

确定pod所使用的镜像

kubectl get pods coredns-7f6cbbb7b8-knhl8 -n kube-system -o yaml | grep image




    image: registry.aliyuncs.com/google_containers/coredns:v1.8.4
    imagePullPolicy: IfNotPresent
  - image: registry.aliyuncs.com/google_containers/coredns:v1.8.4
    imageID: ""
        message: Back-off pulling image "registry.aliyuncs.com/google_containers/coredns:v1.8.4"

root@k8s-master:~# docker pull registry.aliyuncs.com/google_containers/coredns:v1.8.4
Error response from daemon: manifest for registry.aliyuncs.com/google_containers/coredns:v1.8.4 not found: manifest unknown: manifest unknown

拉个latest 再别名 
docker pull registry.aliyuncs.com/google_containers/coredns

root@k8s-master:~# docker  images | grep coredns 
registry.aliyuncs.com/google_containers/coredns                   latest    8d147537fb7d   3 months ago   47.6MB

强制 改一下 tag 
root@k8s-master:~# docker tag 8d147537fb7d  registry.aliyuncs.com/google_containers/coredns:v1.8.4

root@k8s-master:~# kubectl get pods --all-namespaces | grep coredns  
kube-system   coredns-7f6cbbb7b8-knhl8             1/1     Running            0                24h
kube-system   coredns-7f6cbbb7b8-lt4k5             1/1     Running            0                24h
root@k8s-master:~# 


root@k8s-master:~#  kubectl get all -n kube-system 
NAME                                     READY   STATUS             RESTARTS        AGE
pod/coredns-7f6cbbb7b8-knhl8             0/1     ImagePullBackOff   0               24h
pod/coredns-7f6cbbb7b8-lt4k5             0/1     ImagePullBackOff   0               24h

docker pull registry.aliyuncs.com/google_containers/coredns

coredns状态为ImagePullBackOff问题

k8s解决coredns 的ImagePullBackOff 和ErrImagePull 问题

https://stackoverflow.com/questions/53559291/kubernetes-coredns-in-crashloopbackoff

Kubernetes CoreDNS 状态是 CrashLoopBackOff 解决思路

CrashLoopBackOff的解决方法

记录一次修复k8s pod长时间处于CrashLoopBackOff状态问题

k8s启动Pod遇到CrashLoopBackOff的解决方法

see also

几款k8s快速部署的开源项目对比


kuernetes 修改pod时区的方法

docker基础知识

Linux的namespace和cgroups简介