使用k8s创建容器一直处于ContainerCreating状态

时间:2023-12-30 08:22:56

容器报错信息为(两种):

FailedSynError 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)" 13m 11s  {kubelet 127.0.0.1} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\""

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)"

大致意思就是:未能通过ErrImagePull为“POD”启动“StartContainer”:“对于registry.access.redhat.com/rhel7/pod-infrastructure:latest,图像拉出失败,这可能是因为此请求上没有证书

检查发现:/etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt这个目录中是一个软连接

使用k8s创建容器一直处于ContainerCreating状态

发现实际上并没有这个文件:

使用k8s创建容器一直处于ContainerCreating状态

其实在我的k8s编排工具使用文档中我提过这个错误,说是因为证书导致的, 然后下载一个  yum remove *rhsm* -y  就可以解决,但是我最近温习一遍后发现这个rhsm文件被调换了,下载后发现是空的,然后找方法解决。

解决方法:下载rpm包安装

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm
rpm2cpio python-rhsm-certificates-1.19.-.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem

注释:rpm2cpio命令用于将rpm软件包转换为cpio格式的文件

cpio命令主要是用来建立或者还原备份档的工具程序,cpio命令可以复制文件到归档包中,或者从归档包中复制文件。

-i   还原备份档

-v  详细显示指令的执行过程

最后解决了!

使用k8s创建容器一直处于ContainerCreating状态