Interview Prep/Kubernetes/EKS-specific issues

Pods on EKS fail to pull from ECR with `failed to resolve reference ... 401 Unauthorized` or `no basic auth credentials`.

IntermediateTroubleshootingEKS-specific issues
Answer

Likely causes → The kubelet uses the node IAM role (through the ECR credential provider) to pull, not the Pod's IRSA role. The node role lacks AmazonEC2ContainerRegistryReadOnly, the repo is in another account without a repository policy, or in private subnets the ECR VPC endpoints are missing (i/o timeout rather than 401).

Diagnose →

aws iam list-attached-role-policies --role-name eks-node-role
aws ecr get-repository-policy --repository-name web   # cross-account
# On the node
sudo crictl pull 111122223333.dkr.ecr.ap-south-1.amazonaws.com/web:1.4

Fix → Attach the ECR read policy to the node role; for cross-account, add a repository policy allowing the node role's account; add ecr.api, ecr.dkr interface endpoints and the S3 gateway endpoint for private subnets.

Prevent → Node role policies in IaC; ECR replication to each account/region that pulls.

All Kubernetes questions

More on EKS-specific issues