-
Notifications
You must be signed in to change notification settings - Fork 147
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
Support team-id annotation #139
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zicongmei The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @zicongmei. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions 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/test-infra repository. |
/ok-to-test |
@zicongmei: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions 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/test-infra repository. |
/ok-to-test |
/retest |
1 similar comment
/retest |
fbea1e6
to
4e36209
Compare
/retest |
/retest |
/retest |
/retest |
/ok-to-test |
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.
This is great, thank you so much @zicongmei ! I left few comments and thoughts below
TeamID, ok := nsa[ackv1alpha1.AnnotationTeamID] | ||
if ok { | ||
nsInfo.teamID = TeamID | ||
} |
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.
Just taking notes.. during the refactor we will need to use lowerCamelCase variable names
pkg/runtime/cache/cache.go
Outdated
Accounts *CARMCache | ||
|
||
// Team-ID cache | ||
Teams *CARMCache |
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.
The separation of concerns implemented here is a good approach. However, I have a minor concern about spinning up two shared informers, watching the same exact kind (ConfigMap
).. This could result in redundant watch operations essentially retrieving the same information (data).
Additionally, I think that using two separate informers can potentially result in delays when updating the caches for teamID
and an ownerAccountID
. If one cache gets updated before the other, there's a risk that the logic for picking up either the teamID
or ownerAccountID
may get impacted until both caches are fully synced
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 your thoughts on using a single "cache" object (`CARMCache) to store both the teamIDs and accountIDs?
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.
I like the idea of a single map. We can separate that from this PR.
pkg/runtime/adoption_reconciler.go
Outdated
parsedARN, err := arn.Parse(string(roleARN)) | ||
if err != nil { | ||
return fmt.Errorf("failed to parsed role ARN %q from namespace annotation: %v", teamID, err) | ||
} |
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.
Should we move the AWS AccountID
and ARN
parsing logic to level closer to the CARMCache layer? the issue with handling errors here is that it's tricky properly patch the CRs conditions and trigger a proper requeue.
Second thoughts, i think this needs to be part of the refactor PR.
pkg/runtime/cache/account.go
Outdated
// ACKRoleTeamMap is the name of the configmap map object storing | ||
// all the AWS Team IDs associated with their AWS Role ARNs. | ||
ACKRoleTeamMap CARMName = "ack-role-team-map" |
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.
I just realized that we're adding a new map to watch here. It's a little different from what we've imagined initially but I like it... It's definitely better than combining accountIDs and teamIDs in the same ConfigMap
...
Issue #, if available: aws-controllers-k8s/community#2031
Description of changes:
Add support of
team-id
annotation in the namespace. Eachteam-id
can associate with a different AWS Role ARN. So that the controller can have different roles for different namespaces. It can help fine grained permission when different teams and users are using the same controller.Changes:
team-id
annotationteam-id
andowner-account-id
exist. It will take theteam-id
and ignoreowner-account-id
.Sample usage:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.