标准 Hello-World 应用程序可在https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app不起作用。虽然在 GCP 上结合使用 Kubernetes 与 Google Cloud 时一切应该可以立即正常工作,但似乎存在一些拉取访问问题。
例如参考:https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod
其中提到:
“使用 Google 容器注册表 Kubernetes 在 Google Compute Engine (GCE) 上运行时对 Google 容器注册表 (GCR) 具有原生支持。如果您在 GCE 或 Google Kubernetes Engine 上运行集群,只需使用完整的映像名称(例如 gcr.io/my_project/image:tag)。集群中的所有 pod 都具有对此注册表中映像的读取权限。
我仔细检查了我是否使用了正确的图像名称(从容器注册表中复制粘贴)。
错误信息:
C:\Users\rober>kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-web-694bc87958-rcdvg 0/1 ImagePullBackOff 0 7s
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 7m default-scheduler Successfully assigned default/hello-web-694bc87958-rcdvg to gke-hello-cluster-default-pool-9cbfb505-588j
Normal SandboxChanged 7m (x3 over 7m) kubelet, gke-hello-cluster-default-pool-9cbfb505-588j Pod sandbox changed, it will be killed and re-created.
Normal BackOff 7m (x6 over 7m) kubelet, gke-hello-cluster-default-pool-9cbfb505-588j Back-off pulling image "gcr.io/data-platform-tst/hello-app:v1"
Normal Pulling 6m (x3 over 7m) kubelet, gke-hello-cluster-default-pool-9cbfb505-588j pulling image "gcr.io/data-platform-tst/hello-app:v1"
Warning Failed 6m (x3 over 7m) kubelet, gke-hello-cluster-default-pool-9cbfb505-588j Failed to pull image "gcr.io/data-platform-tst/hello-app:v1": rpc error: code = Unknown desc = Error response from daemon: repository gcr.io/data-platform-tst/hello-app not found: does not exist or no pull access
Warning Failed 6m (x3 over 7m) kubelet, gke-hello-cluster-default-pool-9cbfb505-588j Error: ErrImagePull
Warning Failed 2m (x24 over 7m) kubelet, gke-hello-cluster-default-pool-9cbfb505-588j Error: ImagePullBackOff