有没有一种方法可以在不构建的情况下使用 skaffold 配置加载私有图像?

Is there a way to load private image using a skaffold config without building it?

我创建了一个只包含一行的 mock.Dockerfile。

FROM eu.gcr.io/some-org/mock-service:0.2.0

使用该配置并在构建部分对其进行引用,skaffold 使用私有 GCR 注册表构建该 dockerfile。但是,如果我删除该 Dockerfile,skaffold 不会构建它,并且在启动 skaffold 时它只会加载在该 build 部分中引用的图像(public 图像,例如 postgres 也可以工作)。所以在本地 kubernetes 配置中,比如 minikube,这会导致

ImagePullBackOff
Failed to pull image "eu.gcr.io/some-org/mock-service:0.2.0": rpc error: code = Unknown desc = Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials 

基本上,当我创建一个单行 Dockerfile 并将其包含在内时,skaffold 会构建该映像并将其加载到 minikube 中。现在可以更改 minikube 配置,以便对 GCR 的请求成功,但目标是开发人员不必更改他们的 minikube 配置...

有没有其他方法可以在不更改配置和单行 Dockerfile 的情况下将该图像加载到 Minikube 中?

skaffold.yaml:

apiVersion: skaffold/v2beta8
kind: Config
metadata:
  name: some-service
build:
  artifacts:
    - image: eu.gcr.io/some-org/some-service
      docker:
        dockerfile: Dockerfile
    - image: eu.gcr.io/some-org/mock-service
      docker:
        dockerfile: mock.Dockerfile
  local: { }

profiles:
  - name: mock
    activation:
      - kubeContext: (minikube|kind-.*|k3d-(.*))
    deploy:
      helm:
        releases:
          - name: postgres
            chartPath: test/postgres
          - name: mock-service
            chartPath: test/mock-service
          - name: skaffold-some-service
            chartPath: helm/some-service
            artifactOverrides:
              image: eu.gcr.io/some-org/some-service
            setValues:
              serviceAccount.create: true


尽管 GKE pre-configured 从同一项目中的注册表中拉取,但 Kubernetes 集群通常需要 special configuration at the pod level 从私有注册表中拉取。有点牵强。

幸运的是,minikube 引入了一个 registry-creds add-on,它将使用适当的凭据配置 minikube 实例以拉取图像。