pod状态一直显示ContainerCreating

发布时间:2020-07-28 20:19:34 作者:九月朦胧
来源:网络 阅读:815

今天在学习kubernetes的时候启动了一个msyql服务,运行命令

[root@liuxuchong kubernetes]# kubectl create -f mysql-rc.yaml
replicationcontroller "mysql" created
[root@liuxuchong kubernetes]# kubectl get all
NAME       DESIRED   CURRENT   READY     AGE
rc/mysql   1         1         0         6m

NAME             CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
svc/kubernetes   10.254.0.1   <none>        443/TCP   10m

NAME             READY     STATUS              RESTARTS   AGE
po/mysql-f7df5   0/1       ContainerCreating   0          6m

pod状态一直显示ContainerCreating

可以看到rc没有ready,并且pod一直显示ContainerCreating
显示pod详细信息

[root@liuxuchong ca]# kubectl describe pod mysql-f7df5
Name:       mysql-f7df5
Namespace:  default
Node:       127.0.0.1/127.0.0.1
Start Time: Wed, 15 May 2019 11:56:38 +0800
Labels:     app=mysql
Status:     Pending
IP:     
Controllers:    ReplicationController/mysql
Containers:
  mysql:
    Container ID:   
    Image:      mysql
    Image ID:       
    Port:       3306/TCP
    State:      Waiting
      Reason:       ContainerCreating
    Ready:      False
    Restart Count:  0
    Volume Mounts:  <none>
    Environment Variables:
      MYSQL_ROOT_PASSWORD:  123456
Conditions:
  Type      Status
  Initialized   True 
  Ready     False 
  PodScheduled  True 
No volumes.
QoS Class:  BestEffort
Tolerations:    <none>
Events:
  FirstSeen LastSeen    Count   From            SubObjectPath   Type        Reason      Message
  --------- --------    -----   ----            -------------   --------    ------      -------
  5m        5m      1   {default-scheduler }            Normal      Scheduled   Successfully assigned mysql-f7df5 to 127.0.0.1
  5m        2m      5   {kubelet 127.0.0.1}         Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull faileredhat.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)"

  4m    5s  19  {kubelet 127.0.0.1}     Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redastructure:latest\""

看到了俩个警告,第一个是说拉取镜像请求失败,括号里的意思是没有这个目录,手动查了一遍发现有这个目录,网上说安装一下rhsm,yum install rhsm -y,发现问题还是没有解决,于是想到拉取镜像需要访问外网,阿里云的机器不能访问外网,于是从国外的服务器拉取了镜像。
用命令journalctl -u kubelet -f查看一下日志

[root@liuxuchong kubernetes]# journalctl -u kubelet -f
-- Logs begin at Tue 2018-04-10 03:20:48 CST. --
May 15 12:02:25 liuxuchong kubelet[28192]: E0515 12:02:25.614469   28192 docker_manager.go:2159] Failed to create pod infra container: ImagePullBackOff; Skipping pod "mysql-f7df5_default(70ce53f4-76c5-11e9-963f-00163e324a1f)": Back-off pulling image "registry.access.redhat.com/rhel7/pod-infrastructure:latest"
May 15 12:02:25 liuxuchong kubelet[28192]: E0515 12:02:25.614942   28192 pod_workers.go:184] Error syncing pod 70ce53f4-76c5-11e9-963f-00163e324a1f, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\""

果断拉取(可以访问外网的服务器)

docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest

然后上传到dockerhub上,上传过程就不详细说了,不会自行百度,然后在本地机器上拉取该镜像,改一下名字
命名为registry.access.redhat.com/rhel7/pod-infrastructure:latest
最后删除原来的rc和pod

[root@liuxuchong ca]# kubectl get all
NAME       DESIRED   CURRENT   READY     AGE
rc/mysql   1         1         0         6m

NAME             CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
svc/kubernetes   10.254.0.1   <none>        443/TCP   10m

NAME             READY     STATUS              RESTARTS   AGE
po/mysql-f7df5   0/1       ContainerCreating   0          6m
[root@liuxuchong ca]# kubectl delete rc mysql
replicationcontroller "mysql" deleted
[root@liuxuchong ca]# kubectl delete pod mysql-f7df5
pod "mysql-f7df5" deleted

重新创建

[root@liuxuchong kubernetes]# kubectl create -f mysql-rc.yaml 
replicationcontroller "mysql" created
[root@liuxuchong kubernetes]# kubectl get rc
NAME      DESIRED   CURRENT   READY     AGE
mysql     1         1         1         7s
[root@liuxuchong kubernetes]# kubectl get pods
NAME          READY     STATUS    RESTARTS   AGE
mysql-r4kxq   1/1       Running   0          12s

pod的状态终于变成了Running

推荐阅读:
  1. kubernetes 创建pod 启动不了 处于ContainerCreating状态
  2. 解决k8s-pod的Evicted状态

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

podcontainercreatin kubernetes ne

上一篇:zookeeper生产环境搭建

下一篇:laravel底层拜读

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》