Home > other >  Need help referencing image correctly in minikube private registry
Need help referencing image correctly in minikube private registry

Time:10-09

I'm trying to deploy a custom pod on minikube and I'm getting the following message regardless of my twicks:

Failed to load logs: container "my-pod" in pod "my-pod-766c646c85-nbv4c" is waiting to start: image can't be pulled
Reason: BadRequest (400)

I did all sorts of experiments based on https://minikube.sigs.k8s.io/docs/handbook/pushing/ and https://number1.co.za/minikube-deploy-a-container-using-a-private-image-registry/ without success. I ended up trying to use minikube image load myimage:latest and reference it in the container spec as:

  ...
  containers:
    - name: my-pod
      image: myimage:latest
      ports:
        - name: my-pod
          containerPort: 8080
          protocol: TCP
   ...

Should/can I use minikube image? If so, should I use the full image name docker.io/library/myimage:latest or just the image suffix myimage:latest? Is there anything else I need to do to make minikube locate the image? Is there a way to get the logs of the bad request itself to see what is going on (I don't see anything in the api server logs)?

I also see the following error in the minikube system:

Failed to load logs: container "registry-creds" in pod "registry-creds-6b884645cf-gkgph" is waiting to start: ContainerCreating
Reason: BadRequest (400)

Thanks! Amos

CodePudding user response:

You should set the imagePullPolicy to IfNotPresent. Changing that will tell kubernetes to not pull the image if it does not need to.

  ...
  containers:
    - name: my-pod
      image: myimage:latest
      imagePullPolicy: IfNotPresent
      ports:
        - name: my-pod
          containerPort: 8080
          protocol: TCP
   ...

A quirk of kubernetes is that if you specify an image with the latest tag as you have here, it will default to using imagePullPolicy=Always, which is why you are seeing this error.

More on how kubernetes decides the default image pull policy

If you need your image to always be pulled in production, consider using helm to template your kubernetes yaml configuration.

  • Related