kubernetes pod一直是ContainerCreating,READY是0/1

背景

  • 新创建的nginx-deployment,情况如下所示。
[root@localhost software]# kubectl get pods
NAME                              READY     STATUS              RESTARTS   AGE
nginx-deployment-94093859-51185   0/1       ContainerCreating   0          11m
nginx-deployment-94093859-8744s   0/1       ContainerCreating   0          11m
nginx-deployment-94093859-zvbb1   0/1       ContainerCreating   0          11m

  • 状态一直是ContainerCreating ,READY0/1

解决方案

  • 查看pod详情,使用命令 kubectl describe pod nginx-deployment-94093859-51185nginx-deployment-94093859-51185是我pod名称)。
[root@localhost software]# kubectl describe pod nginx-deployment-94093859-51185
Name:		nginx-deployment-94093859-51185
Namespace:	default
Node:		127.0.0.1/127.0.0.1
Start Time:	Sat, 26 Jun 2021 21:30:06 -0400
Labels:		app=nginx
		pod-template-hash=94093859
		track=stable
Status:		Pending
IP:		
Controllers:	ReplicaSet/nginx-deployment-94093859
Containers:
  nginx:
    Container ID:	
    Image:		nginx:1.7.9
    Image ID:		
    Port:		80/TCP
    State:		Waiting
      Reason:		ContainerCreating
    Ready:		False
    Restart Count:	0
    Volume Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-k3tq8 (ro)
    Environment Variables:	<none>
Conditions:
  Type		Status
  Initialized 	True 
  Ready 	False 
  PodScheduled 	True 
Volumes:
  default-token-k3tq8:
    Type:	Secret (a volume populated by a Secret)
    SecretName:	default-token-k3tq8
QoS Class:	BestEffort
Tolerations:	<none>
Events:
  FirstSeen	LastSeen	Count	From			SubObjectPath	Type		Reason		Message
  ---------	--------	-----	----			-------------	--------	------		-------
  12m		12m		1	{default-scheduler }			Normal		Scheduled	Successfully assigned nginx-deployment-94093859-51185 to 127.0.0.1
  12m		1m		7	{kubelet 127.0.0.1}			Warning		FailedSync	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)"

  11m	7s	50	{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\""

有一个错误"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/docker/certs.d/registry.access.redhat.com/redhat-ca.crt后发现是个软链接。
    在这里插入图片描述
  • 并且没有 /etc/rhsm/ca/redhat-uep.pem文件。
  • 尝试直接docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest也拉不下来,也会报找不到文件。
  • 只要我们能生成/etc/rhsm/ca/redhat-uep.pem文件,问题也就迎刃而解了。
  • 有的人用yum install *rhsm*解决了问题,但是在我的电脑上不行,所以下面是另一个方案。
    • 1、下载python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm文件

       wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm
      
    • 2、生成/etc/rhsm/ca/redhat-uep.pem文件

      	rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem
      
  • 再次拉取registry.access.redhat.com/rhel7/pod-infrastructure:latest,执行命令 docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
    在这里插入图片描述
  • 再次查看pod状态,已经正常了,如下图所示。
    在这里插入图片描述
  • docker进程运行状态如下所示。
    在这里插入图片描述

posted on   愤怒的苹果ext  阅读(875)  评论(0编辑  收藏  举报

编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示