Pod status always shows ContainerCreating
Today, when I was learning kubernetes, I started a msyql service and ran the command
[root@liuxuchong kubernetes] # kubectl create-f mysql-rc.yamlreplicationcontroller "mysql" created [root@liuxuchong kubernetes] # kubectl get allNAME DESIRED CURRENT READY AGErc/mysql 1 10 6mNAME CLUSTER-IP EXTERNAL-IP PORT (S) AGEsvc/kubernetes 10.254.0.1 443/TCP 10mNAME READY STATUS RESTARTS AGEpo/ Mysql-f7df5 0/1 ContainerCreating 0 6m
You can see that rc does not have ready, and pod keeps displaying ContainerCreating
Show pod details
[root@liuxuchong ca] # kubectl describe pod mysql-f7df5Name: mysql-f7df5Namespace: defaultNode: 127.0.0.1/127.0.0.1Start Time: Wed 15 May 2019 11:56:38 + 0800Labels: app=mysqlStatus: PendingIP: Controllers: ReplicationController/mysqlContainers: mysql: Container ID: Image: mysql Image ID: Port: 3306/TCP State: Waiting Reason: ContainerCreating Ready: False Restart Count: 0 Volume Mounts: Environment Variables: MYSQL_ROOT_PASSWORD: 123456Conditions: Type Status Initialized True Ready False PodScheduled True No volumes.QoS Class: BestEffortTolerations: Events: FirstSeen LastSeen Count From SubObjectPath Type Reason Message- -- 5m 5m 1 {default-scheduler} Normal Scheduled Successfully assigned mysql-f7df5 to 127.0.15m 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 is that the request to pull the image failed. It means that there is no such directory in parentheses. I checked it manually and found this directory. When I installed rhsm,yum install rhsm-y on the Internet, I found that the problem was still unsolved. So I thought that pulling the image needed to access the public network, and Aliyun's machine could not access the public network, so I pulled the image from a foreign server.
Check the log with the command journalctl-u kubelet-f
[root@liuxuchong kubernetes] # journalctl-u kubelet-Fmuri-Logs begin at Tue 2018-04-10 03:20:48 CST. -- May 15 12:02:25 liuxuchong kubelet [28192]: E0515 12 purl 02 docker_manager.go:2159 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 purl 0270ce53f4 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\ ""
Decisively pull (can access the server of the external network)
Docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
Then upload to dockerhub, the upload process will not be detailed, not Baidu, and then pull the image on the local machine, change the name
Named registry.access.redhat.com/rhel7/pod-infrastructure:latest
Finally, delete the original rc and pod
[root@liuxuchong ca] # kubectl get allNAME DESIRED CURRENT READY AGErc/mysql 1 10 6mNAME CLUSTER-IP EXTERNAL-IP PORT (S) AGEsvc/kubernetes 10.254.0.1 443/TCP 10mNAME READY STATUS RESTARTS AGEpo/mysql-f7df5 0 443/TCP 10mNAME READY STATUS RESTARTS AGEpo/mysql-f7df5 1 ContainerCreating 0 6m [root @ liuxuchong ca] # kubectl delete rc mysqlreplicationcontroller "mysql" deleted [root@liuxuchong ca] # kubectl delete pod mysql-f7df5pod "mysql-f7df5" deleted
Re-create
[root@liuxuchong kubernetes] # kubectl create-f mysql-rc.yaml replicationcontroller "mysql" created [root@liuxuchong kubernetes] # kubectl get rcNAME DESIRED CURRENT READY AGEmysql 1 1 1 7s [root@liuxuchong kubernetes] # kubectl get podsNAME READY STATUS RESTARTS AGEmysql-r4kxq 1 Union 1 Running 0 12s
The state of pod has finally become Running.