Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Part 1
You run kubectl apply, and it succeeds. The API server accepts the Deployment and creates the Pod. Then the Pod goes from Pending to InvalidImageName instead of pulling anything. Nothing is wrong with the cluster. The problem is the image string the Deployment carries: MyCompany/Api.
deployment.yaml
Look at the image line in this Deployment. If you run kubectl describe pod, the events say it couldn't parse the image reference, and that the repository name must be lowercase. That's the clue. The capitals in MyCompany slash Api are the cause. The tag, 1.0, isn't the problem.
spec:
containers:
- name: api
image: MyCompany/Api:1.0Parsing fails before any download
kubectl apply succeeds because the API server just stores the image string without fully parsing it. The kubelet is the one that parses the reference, and it fails right there. The pull to the registry is refused, so nothing is downloaded. That's why this isn't ErrImagePull. The Pod goes to InvalidImageName.
Name part vs tag part
Split the reference at the colon, and you get two parts with different rules. The repository, MyCompany slash Api, allows only lowercase letters, digits and separators. The tag, 1.0, allows capitals, so something like v1.0-RC is valid. The fault is the name, not the version.
Before and after: only the name changes
In the Before version, the repository MyCompany/Api is rejected because of the capital M, C and A, while the tag 1.0 is fine. In the After version, the repository becomes mycompany/api, and both parts pass. The tag never changed. Only the name did.
Use one lowercase name everywhere
The fix has three places that must agree. Build the image as mycompany/api:1.0, push that same name, and put it in the Deployment's image field. Docker rejects uppercase repository names too, and if the names drift apart, you'd just swap this error for a pull failure.
docker build -t mycompany/api:1.0 .
docker push mycompany/api:1.0
# deployment.yaml
image: mycompany/api:1.0Fixed: the pull actually happens
Now walk the same path with mycompany/api. The Deployment goes through kubectl apply to the API server, which schedules the Pod spec to the kubelet. The kubelet checks the name, parsing passes, and the pull reaches the registry. The image layers arrive, and the Pod moves from Pending to Running, assuming that name was pushed.
The kubelet parses the image name first; capitals stop it there.
One capital letter stops the Pod before any download is attempted. The kubelet checks the name first, and when parsing fails, the registry is never contacted. So when you see InvalidImageName, check the case of the repository name first, then fix that string itself.