-
Notifications
You must be signed in to change notification settings - Fork 929
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
minimize the rbac permissions for karmada-agent #5629
Conversation
/cc @zhzhuang-zju |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5629 +/- ##
==========================================
- Coverage 41.85% 41.85% -0.01%
==========================================
Files 655 655
Lines 55756 55756
==========================================
- Hits 23338 23335 -3
- Misses 30907 30910 +3
Partials 1511 1511
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/hold |
864eb15
to
2a4567c
Compare
2a4567c
to
5abef7a
Compare
/unhold |
/cc @zhzhuang-zju |
Hi @B1F030 Please quash commits and get this PR ready. |
@B1F030 The review is ongoing, and I will check whether your RBAC configuration ensures the normal operation of the agent and whether there are any redundant permissions. |
e6fbd93
to
b3c3ad5
Compare
# apiVersion: rbac.authorization.k8s.io/v1 | ||
# kind: Role | ||
# metadata: | ||
# name: system:karmada:agent-secret | ||
# namespace: "{{cluster_namespace}}" # default to karmada-cluster | ||
# rules: | ||
# - apiGroups: | ||
# - "" |
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.
@B1F030 Can you explain what these roles are and why they are commented out?
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.
To minimize the rbac permissions for karmada-agent, we can limit some sensitive permissions to minimum.
Sensitive permissions including:
- clusters: [create, get]
- clusters/status: [update]
- secrets: [get, list, watch, create, patch]
- works: [create, get, list, watch, update, delete]
- works/status: [patch, delete]
Because clusters
and clusters/status
are not namespace-scoped, we can limit the specific resourceNames
as {{clustername}}
.
And because secrets
and works
, works/status
are namespace-scoped, we can collect them into specific roles, as:
system:karmada:agent-secret
(in namespace {{cluster_namespace}}, default to karmada-cluster) for secrets
,
system:karmada:agent-work
(in namespace karmada-es-{{clustername}}) for works
, works/status
.
But for now we cannot use them without codechange, for example, It will come to Error when setting up basic environment:
Error from server (NotFound):
error when creating "artifacts/deploy/bootstrap-token-configuration.yaml":
namespaces "karmada-es-{{clustername}}" not found
So we plan to comment out these roles for now, and after when we can create ns during the register.go, we can cancel the comments.
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 un-commented parts represent the minimal RBAC permissions that can be achieved without modifying the code and the existing karmadactl register
workflow.
The commented parts represent the desired minimal RBAC permissions
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.
Can we move the commented part into the documentation to demonstrate the agent's minimal permission set, and then later modify the code to align the agent's RBAC permissions with the desired minimal RBAC?
b3c3ad5
to
c1bef1b
Compare
? |
c1bef1b
to
05e04c3
Compare
8df1a25
to
57134ad
Compare
57134ad
to
1720ca9
Compare
thanks~ |
1720ca9
to
cb11c22
Compare
cb11c22
to
3ed107f
Compare
Signed-off-by: B1F030 <[email protected]>
3ed107f
to
976e62f
Compare
/lgtm |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
Part of #5182
Special notes for your reviewer:
Does this PR introduce a user-facing change?: