创建单机Kubenetes集群环境后,Pod一直处于ContainerCreating状态:

1
2
3
[root@VM_0_3_centos]# kubectl get pods
NAME          READY     STATUS              RESTARTS   AGE
myweb-pgn80   0/1       ContainerCreating   0          10m

查看Pod的Event记录

1
[root@VM_0_3_centos]# kubectl describe pod myweb-pgn80

问题

无法创建的原因提示:

1
Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request.  details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)"

查找缺失的文件,显示是一个软连接,链接目标是/etc/rhsm:

1
2
[root@VM_0_3_centos conf.d]# ll /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt
lrwxrwxrwx 1 root root 27 Jun 10 11:37 /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt -> /etc/rhsm/ca/redhat-uep.pem

尝试手动拉取镜像

1
[root@VM_0_3_centos]# docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest

提示:

1
open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory

依据google的解决办法,尝试使用

1
2
3
4
5
6
7
8
[root@VM_0_3_centos]# yum install *rhsm*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package python-rhsm-1.19.10-1.el7_4.x86_64 is obsoleted by subscription-manager-rhsm-1.20.11-1.el7.centos.x86_64 which is already installed
Package subscription-manager-rhsm-1.20.11-1.el7.centos.x86_64 already installed and latest version
Package python-rhsm-certificates-1.19.10-1.el7_4.x86_64 is obsoleted by subscription-manager-rhsm-certificates-1.20.11-1.el7.centos.x86_64 which is already installed
Package subscription-manager-rhsm-certificates-1.20.11-1.el7.centos.x86_64 already installed and latest version
Nothing to do

问题出在目标的两个包被subscription-manager-rhsm-certificates-1.20.11-1.el7.centos.x86_64 和subscription-manager-rhsm-1.20.11-1.el7.centos.x86_64替代。

解决办法

删除已经安装的这两个包,手动安装目标包

1
[root@VM_0_3_centos]# yum remove *rhsm*

下载目标包,注意版本

1
2
#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

然后执行安装命令

1
2
3
4
5
6
[root@VM_0_3_centos centos]# rpm -ivh *.rpm
warning: python-rhsm-1.19.9-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:python-rhsm-certificates-1.19.9-1################################# [ 50%]
   2:python-rhsm-1.19.9-1.el7         ################################# [100%]

重新拉取镜像

1
[root@VM_0_3_centos centos]#docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest

查看POD状态

1
2
3
4
5
[root@VM_0_3_centos centos]# kubectl get pods
NAME          READY     STATUS    RESTARTS   AGE
mysql-m4n1g   1/1       Running   0          9h
myweb-pgn80   1/1       Running   0          9h
myweb-z7q4v   1/1       Running   0          9h

解决问题