首页 > 解决方案 > Kubernetes 在非默认命名空间中拉取镜像错误

问题描述

我有一个在默认命名空间中运行良好的清单。该图像缓存在我的笔记本电脑 docker 注册表中,并且我已将清单拉取策略设置为IfNotPresent.

一切正常,但是当我切换到非默认命名空间时,由于拉取错误,pod 无法启动:

message: Back-off pulling image "myprivaterepo/myapp:latest"
reason: ImagePullBackOff

该图像位于我的本地 docker 注册表中,具有相同的路径。

只是想知道为什么它在默认命名空间中工作,但在非默认命名空间中工作?

标签: kubernetes

解决方案


很简单,你需要在每个命名空间中添加注册表

查看文档https://kubernetes.io/docs/concepts/containers/images/

Note: Pods can only reference image pull secrets in their own namespace, so this process needs to be done one time per namespace


推荐阅读