念念不忘
必会回响

解决k8s出现pod服务一直处于ContainerCreating状态的问题

在创建Dashborad时,查看状态总是ContainerCreating

kubectl get pods -n kube-system 
NAME                                           READY     STATUS              RESTARTS   AGE
kubernetes-dashboard-latest-4167338039-cjh13   0/1       ContainerCreating   0          47s

查看日志/var/log/message,发现有如下日志信息:

kubectl get pods -n kube-system 
May 31 17:29:19 apm-slave03 kubelet: E0531 17:29:19.526941   24919 docker_manager.go:2159] Failed to create pod infra container: ImagePullBackOff; Skipping pod "kubernetes-dashboard-latest-4167338039-cjh13_kube-system(0ba4a71f-64ae-11e8-9a31-005056bc2ad1)": Back-off pulling image "registry.access.redhat.com/rhel7/pod-infrastructure:latest"

发现此时会pull一个镜像registry.access.redhat.com/rhel7/pod-infrastructure:latest,当我手动pull时,提示如下错误:

kubectl get pods -n kube-system 
docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ... 
open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory

通过搜索得知,需要安装rhsm

kubectl get pods -n kube-system 
yum install *rhsm*
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.lzu.edu.cn
 * extras: mirror.lzu.edu.cn
 * updates: ftp.sjtu.edu.cn
base                                                                                                                                                                                  | 3.6 kB  00:00:00     
extras                                                                                                                                                                                | 3.4 kB  00:00:00     
updates                                                                                                                                                                               | 3.4 kB  00:00:00     
软件包 python-rhsm-1.19.10-1.el7_4.x86_64 被已安装的 subscription-manager-rhsm-1.20.11-1.el7.centos.x86_64 取代
软件包 subscription-manager-rhsm-1.20.11-1.el7.centos.x86_64 已安装并且是最新版本
软件包 python-rhsm-certificates-1.19.10-1.el7_4.x86_64 被已安装的 subscription-manager-rhsm-certificates-1.20.11-1.el7.centos.x86_64 取代
软件包 subscription-manager-rhsm-certificates-1.20.11-1.el7.centos.x86_64 已安装并且是最新版本

但是在/etc/rhsm/ca/目录下依旧没有证书文件,于是反复卸载与安装都不靠谱,后来发现大家所谓yum install *rhsm*其实安装的的是python-rhsm-1.19.10-1.el7_4.x86_64python-rhsm-certificates-1.19.10-1.el7_4.x86_64,但是在实际安装过程中会有如下提示:

kubectl get pods -n kube-system 
软件包 python-rhsm-1.19.10-1.el7_4.x86_64 被已安装的 subscription-manager-rhsm-1.20.11-1.el7.centos.x86_64 取代
软件包 subscription-manager-rhsm-1.20.11-1.el7.centos.x86_64 已安装并且是最新版本
软件包 python-rhsm-certificates-1.19.10-1.el7_4.x86_64 被已安装的 subscription-manager-rhsm-certificates-1.20.11-1.el7.centos.x86_64 取代
软件包 subscription-manager-rhsm-certificates-1.20.11-1.el7.centos.x86_64 已安装并且是最新版本

罪魁祸首在这里。原来我们想要安装的rpm包被取代了。而取代后的rpm包在安装完成后之创建了目录,并没有证书文件redhat-uep.pem。于是乎,手动下载以上两个包

kubectl get pods -n kube-system 
wget ftp://ftp.icm.edu.pl/vol/rzm6/linux-scientificlinux/7.4/x86_64/os/Packages/python-rhsm-certificates-1.19.9-1.el7.x86_64.rpm
wget ftp://ftp.icm.edu.pl/vol/rzm6/linux-scientificlinux/7.4/x86_64/os/Packages/python-rhsm-1.19.9-1.el7.x86_64.rpm

注意版本要匹配,卸载安装错的包

kubectl get pods -n kube-system 
yum remove *rhsm*

然后执行安装命令

kubectl get pods -n kube-system 
rpm -ivh *.rpm
kubectl get pods -n kube-system 
rpm -ivh *.rpm
警告:python-rhsm-1.19.9-1.el7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 192a7d7d: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:python-rhsm-certificates-1.19.9-1################################# [ 50%]
   2:python-rhsm-1.19.9-1.el7         ################################# [100%]

接着验证手动pull镜像

kubectl get pods -n kube-system 
docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ... 
latest: Pulling from registry.access.redhat.com/rhel7/pod-infrastructure
26e5ed6899db: Pull complete 
66dbe984a319: Pull complete 
9138e7863e08: Pull complete 
Digest: sha256:92d43c37297da3ab187fc2b9e9ebfb243c1110d446c783ae1b989088495db931
Status: Downloaded newer image for registry.access.redhat.com/rhel7/pod-infrastructure:latest

此时才算是解决这个问题。

当然同样的问题同样的解法可能有人可以有人不可以,我目测是因为系统发行版的缘故吧。我是用的是CentOS Linux release 7.5.1804 (Core) 他们的版本稍微低一点吧。

赞(1) 打赏
未经允许不得转载:堆上小栈 » 解决k8s出现pod服务一直处于ContainerCreating状态的问题

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册