haishi 发表于 2018-1-5 11:40:59

kubernetes创建yaml,pod服务一直处于 ContainerCreating状态的原因查找与解决

  最近刚刚入手研究kubernetes,运行容器的时候,发现一直处于ContainerCreating状态,悲了个催,刚入手就遇到了点麻烦,下面来讲讲如何查找问题及解决的
  运行容器命令:
  kubectl -f create redis.yaml
  kubectl get pod redis
  NAME               READY   STATUS            RESTARTS   AGE
  redis-master-6jgsl   0/1       ContainerCreating   0          12s
  一直处于ContainerCreating,没有处于running状态
  查看相关日志
  kubectl describe pod redis-6jgsl
  Name:      redis-master-6jgsl
  Namespace:    default
  Node:      127.0.0.1/127.0.0.1
  Start Time:    Wed, 20 Sep 2017 09:07:39 +0800
  Labels:      name=redis-master
  Status:      Pending
  IP:
  Controllers:    ReplicationController/redis-master
  Containers:
  master:

  Container>  Image:            kubeguide/redis-master

  Image>  Port:            6379/TCP
  State:            Waiting
  Reason:            ContainerCreating
  Ready:            False
  Restart Count:      0
  Volume Mounts:      <none>
  Environment Variables:    <none>
  Conditions:
  Type      Status
  Initialized   True
  Ready   False
  PodScheduled   True
  No volumes.

  QoS>  Tolerations:    <none>
  Events:
  FirstSeen    LastSeen    Count    From            SubObjectPath    Type      Reason      Message
  ---------    --------    -----    ----            -------------    --------    ------      -------
  1m      1m      1    {default-scheduler }            Normal      Scheduled    Successfully assigned redis-master-6jgsl to 127.0.0.1
  1m      47s      3    {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)"
  1m    10s    4    {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\""
https://images2017.cnblogs.com/blog/802205/201711/802205-20171104181343045-1835811030.png
https://images2017.cnblogs.com/blog/802205/201711/802205-20171104181250310-1092541940.png
https://images2017.cnblogs.com/blog/802205/201711/802205-20171104180744716-532001403.png
  看到registry.access.redhat.com/rhel7/pod-infrastructure:latest感觉很奇怪,我设置的仓库是grc.io,为什么去拉取这个镜像,怀疑是不是什么没有安装好。尝试运行docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest,提示redhat-ca.crt: no such file or directory。ls查看改文件是个软连接,链接目标是/etc/rhsm,查看没有rhsm,尝试安装yum install *rhsm*,出现相关软件,感觉比较符合,所以安装查看产生了/etc/rhsm文件夹。
https://images2017.cnblogs.com/blog/802205/201711/802205-20171104180801295-1551209404.png
https://images2017.cnblogs.com/blog/802205/201711/802205-20171104180825638-162118224.png
  再次运行kubectl get pods
  NAME               READY   STATUS    RESTARTS   AGE
  redis-master-qhd12   1/1       Running   0          13m
页: [1]
查看完整版本: kubernetes创建yaml,pod服务一直处于 ContainerCreating状态的原因查找与解决