Scenario #
A pod named webserver fails to start with ImagePullBackOff errors. The pod consists of:
- Main container:
nginx-containerusingnginx:latest - Sidecar container:
sidecar-containerusingubuntu:latest
Problem Diagnosis #
Check pod events to identify the issue:
kubectl describe pod webserverKey Events:
Warning Failed 25s (x2 over 45s) kubelet Failed to pull image "nginx:latests": rpc error: code = NotFound desc = failed to pull and unpack image "docker.io/library/nginx:latests": failed to resolve reference "docker.io/library/nginx:latests": docker.io/library/nginx:latests: not found
Warning Failed 14s (x3 over 41s) kubelet Error: ImagePullBackOffIssue Identified: Image tag typo - nginx:latests instead of nginx:latest
Solution #
Option 1: Edit Pod Directly #
kubectl edit pod webserverChange image: nginx:latests to image: nginx:latest, save and exit. Then delete and recreate the pod.
Option 2: Delete and Recreate #
First, get the pod YAML:
kubectl get pod webserver -o yaml > webserver.yamlEdit the file to fix the image name, then:
kubectl delete pod webserver
kubectl apply -f webserver.yamlOption 3: Corrected YAML #
apiVersion: v1
kind: Pod
metadata:
name: webserver
spec:
containers:
- name: nginx-container
image: nginx:latest # Fixed from nginx:latests
- name: sidecar-container
image: ubuntu:latestVerification #
# Check pod status
kubectl get pods webserver
# Verify events show successful pulls
kubectl describe pod webserver
# Check container logs
kubectl logs webserver -c nginx-container
kubectl logs webserver -c sidecar-containerExpected output: Pod status should be Running with both containers started successfully.