0
votes

First off, I'm completely new with Kubernetes and I'm having a hard time with the documentation. I'm trying to figure the behavior of the image option in the run command for kubectl.

kubectl run --image=image

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run

Second, as you can see, the documentation is very clear, but not helpful.

-----------------------------------------------
| Flag   |  Usage                             |
-----------------------------------------------
| image  | The image for the container to run |
-----------------------------------------------

I can't tell what is the expected behavior here. Can someone tell answer some this for me?

  1. Is this going to try find the image locally first?
  2. Or will it try to find it locally, and if it doesn't find it, it tries to pull it?
  3. Or does it default to pulling the image?
  4. And if it is going try to pull it where is pulling from?
  5. Does it matter if there are multiple registries listed?
  6. Also how does this work with images on ECR?

I hope someone can answer this or at least point me to some good documentation or tutorial.

Thanks.

1

1 Answers

1
votes
  1. This is the docker image, whether it pulls it locally or fetches it from the repo will depend on the imagePullPolicy which defaults to ifNotPresent. The image may be something simple like nginx:latest or it might be from your private registry such as myregistry.domain.com/my-ubuntu or gcr.io/my-project/fancy-new-image

2 & 3. As mentioned above, depends on the policy

  1. Where it is pulling from depends on the image. In many cases, you are specifying a registry and then the image such as my.registry.com/my-image. Many common images such as nginx or busybox will probably come from docker.io, however, you can also change the default registry that docker is using

  2. Yes, your container runtime (usually docker) will need to know which registry to pull from, it will not poll different registry at once.

  3. ECR can be private or public. You will define the ECR registry followed by the image name. ECR will use the following to create the registry name:

The URL for your default registry is https://aws_account_id.dkr.ecr.region.amazonaws.com.

See the AWS documentation for more information on how to use and access images from ECR