AWS ECR Authentication not working

I am really stuck here I have tried everything I could find on the web but nothing seems to work and manage to have Rancher 2.0 authenticating with ECR.

Could someone be so nice to please post a step by step working howto on how to use ECR on Rancher 2.0 ?

I have tried basically everything I could find but nothing seems to work. I am using Rancher 2.0 with kubelet 1.20.

I keep on getting ErrImagePull: rpc error: code = Unknown desc = unauthorized: authentication required.

I am using EC2 cluster and I have created a role (specified with the IAM instance profile while configuring the Node template) with the following policy attached:

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Effect”: “Allow”,
“Action”: “ec2:Describe*”,
“Resource”: “"
},
{
“Effect”: “Allow”,
“Action”: “ec2:AttachVolume”,
“Resource”: "

},
{
“Effect”: “Allow”,
“Action”: “ec2:DetachVolume”,
“Resource”: “"
},
{
“Effect”: “Allow”,
“Action”: [
"ec2:

],
“Resource”: [
"
]
},
{
“Effect”: “Allow”,
“Action”: [
"elasticloadbalancing:

],
“Resource”: [
“*”
]
}
]
}

I have also attached to the Role another Policy:

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Effect”: “Allow”,
“Action”: [
“ecr:"
],
“Resource”: "

}
]
}

I have checked and the nodes on EC2 have the correct IAM role attached. The same I have specified in the Node template. Regardless this I keep on getting the error while trying to pull an image from the ECR repository. For us is vital to be able to use ECR for our applications docker images.

Please help.

Thanks.

Francesco

I had a similar issue but it wasn’t with ECR. This might not be related to your situation at all but what happened to me was I tried deploying using a yaml file from a previous deployment, but I didn’t notice that I named the “secret” that stores the registry credentials something else.

Double check the yaml file for the workload to see that

      imagePullSecrets:
      - name: codefresh

Matches the credential name under Registry Credentials