无法从 minikube 中提取图像 docker

Cannot pull image from minikube docker

当我尝试 运行 集群中的容器时,我收到一条消息“deployment test created”,但是当我查看仪表板时,我可以看到它处于错误状态(Failed to pull image...,由于授权问题

,无法从本地 minikube docker env 中拉取镜像

我的步骤是:

  1. 使用 hyperv 启动 minikube 并将 --insecure-registry 开关设置为 10.0.0.0/8,也尝试了 0.0.0.0/0 - Kubernetes 版本 1.9.0 也尝试了 1.8.0
  2. 通过 minikube docker-env | Invoke-Expression
  3. docker env 设置为 minikube docker
  4. build docker image - image 构建并存在于 minikube local docker
  5. kubectl run test --image test-service --port 1101

这是结果:

我错过了什么?

正如评论中所讨论的那样,openfaas/faas-netes 问题 135 说明了一个类似的问题,并提及作为可能的解决方案:

imagePullPolicy if not mentioned should have defaulted to Never instead of Always.

然后OP Tim Jarvis实现了:

I realized it was not an auth issue, but that it was always wanting to pull from an external repo.
The fix for me was to use the imagePullPolicy of IfNotPresent.

这也发生在我身上,检查发送检索图像的策略很重要,有些论坛中描述了一些方法,您可以通过设置您喜欢的注册表来启动您的 minikube,如下所示,一条路。

$ minikube start --cpus 2 --disk-size 50g --memory 5000 --insecure-registry your.registry.com:5000

另一种方法是在您的 minikube 开始时通过 docker-env 呈现环境变量,如下所示,并在命令后生成您的图像构建。

$ eval $(minikube docker-env)

另一种方法是通过 docker 加载将图像导入现有的。

在容器定义中设置以下 属性:

imagePullPolicy: IfNotPresent

示例:

  ...
  containers:
    - name: podhealthexample
      image: podhealth-pod-a:latest
      ports:
        - containerPort: 80
      imagePullPolicy: IfNotPresent