pods處於ContainerCreating狀態

1、錯誤信息

建立 rc 以後 pods 起不來,一直處於 ContainerCreating 狀態python

[root@k8s-all-in-one pod-testweb]# kubectl get pods
NAME          READY     STATUS              RESTARTS   AGE
mysql-vmm72   0/1       ContainerCreating   0          2s

# 查看pods狀態
[root@k8s-all-in-one pod-testweb]# kubectl describe pods mysql-vmm72
Name:           mysql-vmm72
Namespace:      default
Node:           127.0.0.1/127.0.0.1
Start Time:     Thu, 28 Feb 2019 21:36:08 -0500
······
Events:
  FirstSeen     LastSeen        Count   From                    SubObjectPath   Type            Reason          Message
  ---------     --------        -----   ----                    -------------   --------        ------          -------
  47s           47s             1       {default-scheduler }                    Normal          Scheduled       Successfully assigned mysql-vmm72 to 127.0.0.1
  23s           23s             1       {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\""

  47s   10s     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)"

 

2、排查過程

一、查看到缺失的文件是個連接文件mysql

[root@k8s-all-in-one pod-testweb]# ll /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt
lrwxrwxrwx 1 root root 27 Feb 28 21:32 /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt -> /etc/rhsm/ca/redhat-uep.pem

二、連接到的文件也處於缺失狀態web

[root@k8s-all-in-one pod-testweb]# ll /etc/rhsm/ca/redhat-uep.pem
ls: cannot access /etc/rhsm/ca/redhat-uep.pem: No such file or directory

 

3、生成證書

一、下載rpm包

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm

 二、生成證書

[root@k8s-all-in-one ~]# 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

三、查看文件

[root@k8s-all-in-one ~]# ll /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt
lrwxrwxrwx 1 root root 27 Feb 28 21:32 /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt -> /etc/rhsm/ca/redhat-uep.pem
[root@k8s-all-in-one ~]# 
[root@k8s-all-in-one ~]# ll /etc/rhsm/ca/redhat-uep.pem 
-rw-r--r-- 1 root root 7732 Feb 28 21:52 /etc/rhsm/ca/redhat-uep.pem

四、重建rc

[root@k8s-all-in-one pod-testweb]# kubectl delete  -f mysql-rc.yaml 
replicationcontroller "mysql" deleted
[root@k8s-all-in-one pod-testweb]# 
[root@k8s-all-in-one pod-testweb]# kubectl get pods
No resources found.
[root@k8s-all-in-one pod-testweb]# 
[root@k8s-all-in-one pod-testweb]# kubectl create -f mysql-rc.yaml 
replicationcontroller "mysql" created

五、狀態成功

[root@k8s-all-in-one pod-testweb]# kubectl get pods
NAME          READY     STATUS              RESTARTS   AGE
mysql-t2l96   0/1       ContainerCreating   0          2s
[root@k8s-all-in-one pod-testweb]# 
[root@k8s-all-in-one pod-testweb]# kubectl get pods
NAME          READY     STATUS    RESTARTS   AGE
mysql-t2l96   1/1       Running   0          9m

 

 

 

 

 

 

參考資料

1. K8S上mysql,沒法建立rc解決,打不開/registry.access.redhat.com/redhat-ca.crt問題的解決sql

相關文章
相關標籤/搜索