feat: implement AWS ECR credentials loader in Kubernetes keychains#3864
feat: implement AWS ECR credentials loader in Kubernetes keychains#3864Nachiket-Roy wants to merge 9 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Nachiket-Roy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
|
|
Welcome @Nachiket-Roy! It looks like this is your first PR to knative/func 🎉 |
|
Hi @Nachiket-Roy. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
This PR adds programmatic AWS ECR authentication support to the Kubernetes keychain credential loader pipeline, aligning it with the existing GCR and ACR loaders so image push/pull can automatically resolve ECR credentials.
Changes:
- Add ECR registry hostname detection (
isECRRegistry) and wire an ECR credential loader usingamazon-ecr-credential-helperviaauthn.NewKeychainFromHelper. - Return
creds.ErrCredentialsNotFoundwhen the loader should not apply (non‑ECR registries) to allow other loaders to proceed. - Add unit tests for ECR registry detection and basic loader behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/k8s/keychains.go | Implements ECR registry detection and an ECR credential loader using the AWS ECR credential helper. |
| pkg/k8s/keychains_test.go | Adds tests for ECR registry detection and ECR loader fallback behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/ok-to-test |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3864 +/- ##
===========================================
- Coverage 53.41% 42.71% -10.70%
===========================================
Files 200 200
Lines 23413 23524 +111
===========================================
- Hits 12505 10049 -2456
- Misses 9658 12581 +2923
+ Partials 1250 894 -356
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if !isECRRegistry(registry) { | ||
| return oci.Credentials{}, creds.ErrCredentialsNotFound | ||
| } |
There was a problem hiding this comment.
Do we really need this pre-check? Won't keychain.Resolve(res) do the job on it's own?
There was a problem hiding this comment.
To fail fast and same pattern is followed in GCP and ACR
Summary
This change adds programmatic AWS Elastic Container Registry (ECR) authentication support when resolving OCI registry keychains, aligning it with the existing GCP (Google Container Registry) and Azure (ACR) patterns. Previously, the ECR credentials loader was left unimplemented (GetECRCredentialLoader returned an empty slice), which prevented automatic, programmatic ECR credential resolution when pushing/pulling images in Kubernetes keychains workflows.
What changes were made?
public.ecr.awsas well as private registry formats across various AWS partitions.GetECRCredentialLoader): Leveraged the officialamazon-ecr-credential-helper/ecr-loginlibrary programmatically, wrapped viaauthn.NewKeychainFromHelper().io.Discardand ensured that if no ambient credentials exist,creds.ErrCredentialsNotFoundis returned, letting subsequent credential loaders in the chain attempt authentication.Testing
pkg/k8s/keychains_test.go)Closes : #3863