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

Viewed 610

I have created an mock.Dockerfile which just contains one line.

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

With that config and a reference to it the build section, skaffold builds that dockerfile using the private GCR registry. However, if I remove that Dockerfile, skaffold does not build it, and when starting skaffold it only loads the images which are referenced in that build section(public images, like postgres work as well). So in that local kubernetes config, like minikube, this results in a

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 

So basically when I create a one-line Dockerfile, and include that, skaffold builds that image and loads it into minikube. Now it is possible to change the minikube config so that request to GCR succeds, but the goal is that developers don't have to change their minikube config...

Is there any other way to get that image loaded into Minikube, without changing the config and without that one-line Dockerfile?

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


1 Answers

Although GKE comes pre-configured to pull from registries within the same project, Kubernetes clusters generally require special configuration at the pod level to pull from private registries. It's a bit involved.

Fortunately minikube introduced a registry-creds add-on that will configure the minikube instance with appropriate credentials to pull images.

Related