Wondering how to troubleshoot ECR issues with Amazon EKS? We can help you with this!
As a part of our AWS Support Services, we often receive similar requests from our AWS customers.
Today, let’s see the steps followed by our Support Techs to help our customers to fix ECR issues with Amazon EKS.
ECR issues with Amazon EKS
Because of one of the following reasons we can’t pull images from Amazon ECR:
- Unable to communicate with Amazon ECR endpoints.
2. If we don’t have the proper permissions in the instance profileto pull images from an Amazon ECR repository.
We can resolve the above issues by following any of the options below:
- Troubleshooting the communication between worker nodes and Amazon ECR endpoints.
2. Updating the instance profile of worker nodes and confirming that repository policies are correct.
Troubleshooting the communication between worker nodes and Amazon ECR endpoints
We could receive the following error message if the worker nodes can’t communicate with the Amazon ECR endpoints:
Failed to pull image "ACCOUNT.dkr.ecr.REGION.amazonaws.com/imagename:tag": rpc error: code = Unknown desc =
Error response from daemon: Get https://ACCOUNT.dkr.ecr.REGION.amazonaws.com/v2/: net/http:
request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
We should confirm the following to resolve this error:
- Subnet for the worker node has a route to the internet.So we should check the route table associated with the subnet.
- The security group related to the worker node allows outbound internet traffic.
- The incoming and outgoing rule for the network ACLs allows access to the internet.
Updating the instance profile of the worker nodes
We could receive the following error message from your Amazon EKS pod if the worker node’s instance profile doesn’t have permission to pull images from Amazon ECR:
Warning Failed 14s (x2 over 28s) kubelet, ip-000-000-000-000.us-west-2.compute.internalFailed to pull image "ACCOUNT.dkr.ecr.REGION.amazonaws.com/imagename:tag": rpc error: code = Unknown desc = Error response from daemon: Get https://ACCOUNT.dkr.ecr.REGION.amazonaws.com/v2/imagename/manifests/tag: no basic auth credentials
Warning Failed 14s (x2 over 28s) kubelet, ip-000-000-000-000.us-west-2.compute.internal Error: ErrImagePull
Normal BackOff 2s (x2 over 28s) kubelet, ip-000-000-000-000.us-west-2.compute.internal Back-off pulling image "ACCOUNT.dkr.ecr.REGION.amazonaws.com/imagename:tag"
Warning Failed 2s (x2 over 28s) kubelet, ip-000-000-000-000.us-west-2.compute.internal Error: ImagePullBackOff
We need to confirm that the worker nodes use the AmazonEC2ContainerRegistryReadOnly AWS Identity and IAM policy to fix this error. The other option is by using the following IAM permissions to update theAmazon EC2 instance profile of worker nodes:
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:GetRepositoryPolicy",
"ecr:DescribeRepositories",
"ecr:ListImages",
"ecr:DescribeImages",
"ecr:BatchGetImage",
"ecr:GetLifecyclePolicy",
"ecr:GetLifecyclePolicyPreview",
"ecr:ListTagsForResource",
"ecr:DescribeImageScanFindings"
It is aways better to use the AmazonEC2ContainerRegistryReadOnly policy instead of creating a duplicate policy.This helps our worker nodes the permissions to access Amazon ECR and pull images through the kubelet. The kubelet helps in fetching and periodically refreshing Amazon ECR credentials.
To confirm the repository policies are correct
The repository policies are a subset of IAM policies. It control access to individual Amazon ECR repositories.
The IAM policies are used to apply permissions for the entire Amazon ECR service. It can also control access to specific resources.
1. Firstly log in to the AWS Mnagement console and open the Amazon ECR console for the account.
2. Select Repositories, and then select the repository.
3. Select Permissions, and then check if the repository has the correct permissions.
For example:
{
"Version": "2009-10-16",
"Statement": [
{
"Sid": "ECR Repository Policy",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::098765432112:user/MyUsername"
},
"Action": [
"ecr:DescribeImages",
"ecr:DescribeRepositories"
]
}
]
}
[Need help with more AWS queries? We’d be happy to assist]
Conclusion
To conclude, today we discussed the steps followed by our Support Engineers to help our customers to resolve ECR issues with Amazon EKS.
0 Comments