-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
host-ctr: add support for authenticated image pulls from ECR Public #1296
host-ctr: add support for authenticated image pulls from ECR Public #1296
Conversation
6bb0461
to
e0934fa
Compare
e0934fa
to
7f5853a
Compare
Push above and below addresses all of @samuelkarp 's comments. |
453b0de
to
7c33500
Compare
Push above fixes a small issue with double checking the host part of the url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤗
if !strings.HasPrefix(host, "public.ecr.aws") { | ||
return "", "", errors.New("ecr-public: expected image to start with public.ecr.aws") | ||
} | ||
session := session.Must(session.NewSession()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the pre-conditions for this to work? The instance needs an instance role? Same as for the old resolver, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the instance needs to be launched with an instance role profile that has the ECRPublic:GetAuthorizationToken permission. For the normal resolver, the role just needs the managed policy for ECR (not public). All other registries just uses the default resolver.
I think this brings up a good point on how we should make host-ctr more cloud-agnostic. I don't think it's easy to make a determination at runtime to check if we're running in EC2 (or at least not in a hacky way). So this is something that needs to be conditionally compiled... I can follow up with a issue to investigate that further if that's alright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe it just makes sense to fallback to using the default resolver if we fail a call to ecrpublic:GetAuthorizationToken. I think that's probably better and makes things easier. I'll go ahead and do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since ECR Public specifically allows unauthenticated requests (albeit with more throttling), a lack of credentials/permission should fall-through to an anonymous pull.
7c33500
to
1c264df
Compare
Push above and below makes it so that we fallback to using the default resolver with no creds if we can't get creds for ECR Public. Tested things and they work as they should. If I don't have permission to get authorization creds, host-ctr correctly falls back to using the default resovler:
|
1c264df
to
d7da695
Compare
Can you also explicitly test the case where no AWS credentials are available as opposed to the case where AWS credentials are available but don't have permission? |
d7da695
to
4b37ccb
Compare
Push above addresses @samuelkarp 's latest comments.
I moved my
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👍🏽
I would like to see the error messages slightly tweaked to avoid the potential of misleading users in some situations before merging - let me know what you think.
Add support for authenticated image pulls from ECR Public registries. Unlike ECR private registries, we have to use Docker's registry API for resolving ECR Public image references. This means having to manage ECR Public registry auth credentials ourselves
4b37ccb
to
f994c53
Compare
Push above addresses @jahkeup 's comments. |
Issue number:
N/A
Description of changes:
Testing done:
Verified that
ecrpublic::GetAuthorizationToken
calls from host-ctr are successful and I get credentials back without problems.Verified the request header includes the base64-encoded authorization token and the image gets pulled successfully:
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.