Today, when learning kubernetes, I started an msyql service and ran the command
[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
It can be seen that rc has no ready, and pod always shows ContainerCreating
Show pod details
[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\""
I saw two warnings. The first one was that the pull image request failed. The meaning in parentheses was that there was no such directory. I manually checked and found that there was such a directory. On the Internet, I said to install RHSM, yum install rhsm-y. I found that the problem still hasn't been solved. So I thought that the pull image needs to access the Internet. Alibaba cloud's machines can't access the Internet, so I pulled it from foreign servers Image taken.
Check the log with the command 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\""
Pull decisively (servers that can access the Internet)
docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
Then upload it to dockerhub, the upload process will not be detailed, Baidu will not do it by itself, then pull the image on the local machine, change the name
Name it registry.access.redhat.com/rhel7/pod-infrastructure:latest
Finally, delete the original rc and 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
Re create
[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 status finally becomes Running