This repository was archived by the owner on Apr 17, 2025. It is now read-only.
generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 114
Add permissions on hnc CRDs to default clusterRoles: cluster-reader, view, edit, admin #318
Merged
k8s-ci-robot
merged 1 commit into
kubernetes-retired:master
from
zfrhv:add-cluster-roles
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Automatically aggregated to clusterRoles: admin | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: admin | ||
labels: | ||
rbac.authorization.k8s.io/aggregate-to-admin: "true" | ||
rules: | ||
- apiGroups: | ||
- hnc.x-k8s.io | ||
resources: | ||
- hierarchicalresourcequotas | ||
- subnamespaceanchors | ||
- hierarchyconfigurations | ||
verbs: | ||
- '*' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Automatically aggregated to clusterRoles: edit -> admin | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: edit | ||
labels: | ||
rbac.authorization.k8s.io/aggregate-to-edit: "true" | ||
rules: | ||
- apiGroups: | ||
- hnc.x-k8s.io | ||
resources: | ||
- hierarchicalresourcequotas | ||
- subnamespaceanchors | ||
verbs: | ||
- '*' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Automatically aggregated to clusterRoles: cluster-reader, view -> edit -> admin | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: view | ||
labels: | ||
rbac.authorization.k8s.io/aggregate-to-view: "true" | ||
rules: | ||
- apiGroups: | ||
- hnc.x-k8s.io | ||
resources: | ||
- '*' | ||
verbs: | ||
- get | ||
- list | ||
- watch |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
resources: | ||
- role.yaml | ||
- role_binding.yaml | ||
- hnc_admin.yaml | ||
- aggregate_to_view.yaml | ||
- aggregate_to_edit.yaml | ||
- aggregate_to_admin.yaml | ||
- leader_election_role.yaml | ||
- leader_election_role_binding.yaml |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
current admin-role has
*
sohncconfigurations
tooThere 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.
why hncconfigurations too?
isnt its clusterWide object?
you mean
hierarchyconfigurations
?Uh oh!
There was an error while loading. Please reload this page.
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.
indeed :)
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 dont have practice with
hierarchyconfigurations
so I dont know the consequences, a bit afraid to add something I dont knowThere 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.
Ok from what I see this CR allows to add annotations/labels to current namespace and his children.
This roleBinding is aggregated to edit/admin permission, user that has edit/admin shouldn't be able to modify the namespace including annotations/labels.
If
hierarchyconfigurations
would influence only the children namespaces then yes I would add it, but because it effects the parent namespace as well, I consider it as a security breach because edit/admin on the namespace shouldnt have permissions to modify the parent namespace.Sorry I wont add it to the list, if there will be a way to configure
hierarchyconfigurations
only to effect the children (maybe fromhncConfiguration
or something) then yes we can add it as default edit permission.But thank you for the feedback!
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.
It might make sense to distinguish between
hnc-edit
, which gives permission to the namespaced objects (SubnamespaceAnchor
,HierarchyConfiguration
,HierarchicalResourceQuota
) andhnc-admin
, which would add permission to administer HNC itself (HNCConfiguration
). That is,hnc-edit
would let users modify any part of the namespace hierarchy, whilehnc-admin
would let users change the way HNC works.Being able to edit
HierarchyConfiguration
looks like it lets you change the parent of a namespace, but in reality HNC itself imposes limitations on this:This is implemented here.
Uh oh!
There was an error while loading. Please reload this page.
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.
for clarification, admin is supposed to be used with a RoleBinding ref, so a user would not be able to use HNCConfiguration which is ClusterScoped anyway:
*
verbs:*
) ref , with clusterrolebindingas a matter of preference, I prefer explicit declarations instead of
*
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.
Sounds great, but my point was that without HNC, when giving someone admin on namespace A, he cannot change the labels nor annotations of that namespace.
But with the help of HNC, the admin user can configure hiearchyConfiguration to add annotations including on self namespace A.
So its kind of a workaround to be able to manage the namesoace labels+annotations without actually having the permissions.
But now as I think, why not to actually give the ability for the user to label or annotate his namespace even if he cant modify the object? (as long as he is admin)
I bet its not allowed as default only because labels+annotations are part of the object, and its impossible to give permissions only on a specific fields in the object.
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.
Ah, thanks @jouve , yes, if these are all supposed to be used by
RoleBindings
and notClusterRoleBindings
, then there's no point to addHNCConfiguration
.There's no general concept of "admin" on a namespace without HNC AFAIK - either you can edit the
namespace
object, in which case you can modify the labels/annotations, or you can't. As you say, there's no way to grant permissions to only specific fields.With HNC, if you are allowed to modify the
HierarchyConfiguration
in namespace A, then you can also edit the specific labels and annotations managed by HNC. It's not a general-purpose way to modify any label/annotation. But yes, granting someonehnc-admin
at the cluster level would allow them to modify any managed label/annotation on any namespace; that's by design.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.
Thats the point, if someone is granted at not cluster level (only namespaced) he can still modify the annotations of his namespace.
Simple user has only roleBinding and can create hierarchyConfiguration, HNC will create the annotation for him even if he doesn't has permissions.
Anyways I think if someone has admin on the namespace it makes sense that he could add labels to the namespace.
Give me 30 min I will update the PR