NAME READY STATUS RESTARTS AGE mysql-gjg9h 0/1 ContainerCreating 0 1m
坑二
查看pod状态,发现永远是ContainerCreating状态,查看日志:
1 2 3
kubectl logs mysql-gjg9h
Error from server (BadRequest): container "mysql" in pod "mysql-gjg9h" is waiting to start: ContainerCreating
就这一句话。用kubectl describe pod xxx查看
1 2 3 4 5 6 7 8 9 10 11
kubectl describe pod mysql-gjg9h
... ... Events: FirstSeen LastSeen Count From SubObjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 7m 7m 1 {default-scheduler } Normal Scheduled Successfully assigned mysql-gjg9h to 127.0.0.1 7m 1m 6 {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)"
6m 0s 26 {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\""
Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ... open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory
[root@QA registry.access.redhat.com]# docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ... latest: Pulling from registry.access.redhat.com/rhel7/pod-infrastructure 26e5ed6899db: Pull complete 66dbe984a319: Pull complete 9138e7863e08: Pull complete Digest: sha256:92d43c37297da3ab187fc2b9e9ebfb243c1110d446c783ae1b989088495db931 Status: Image is up to date for registry.access.redhat.com/rhel7/pod-infrastructure:latest
成功。 删除RC,删除pod,重新发布:
1 2 3 4
kubectl delete -f mysql-rc.yaml # 验证 kubectl get rc kubectl get pod
因为压根没有部署pod成功,所以删除pod时候,只需要
1
kubectl delete pod mysql-xxxx
就行了,如果是部署成功的,还需要查出deployment再删除
1 2
kubectl get deployment kubectl delete deployment xxx
发布到kubernetes集群里:kubectl create -f mysql-rc.yaml
这次发现还是没成功创建pod,继续describe:Error syncing pod, skipping: failed to "StartContainer" for "mysql" with ErrImagePull: "net/http: request canceled" 看这样子,是拉镜像时候网络超时了,配置新的镜像加速器vim /etc/docker/daemon.json: