Skip to content
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

Add checks for annotation to opt out of cluster owner RBAC #511

Merged
merged 8 commits into from
Oct 4, 2024

Conversation

JonCrowther
Copy link
Contributor

@JonCrowther JonCrowther commented Sep 24, 2024

Issue: rancher/rancher#45591

Requires rancher/rancher changes: rancher/rancher#47259

Problem

When a service account creates a cluster, the project handler and cluster handler both attempt to create ClusterOwner and ProjectOwner roles and bind those roles to the service account. The problem is that we don't support those roles for service accounts, so the logs get flooded with errors as it keeps retrying to add those roles.

Solution

To avoid the errors and the re-queuing, we have added a new annotation field.cattle.io/no-creator-rbac. When it is set the webhook does not set the field.cattle.io/creatorId annotation to clusters because the controllers will no longer be creating RBAC for the creator of the cluster.

I moved some annotations to the common package as I felt it was more apt. I also cleaned up some functions in the common package to make them more consistent.

CheckList

  • Test
  • Docs

@JonCrowther JonCrowther self-assigned this Sep 24, 2024
@JonCrowther JonCrowther changed the title Creator opt out annotation Add checks for annotation to opt out of cluster owner RBAC Sep 25, 2024
@JonCrowther JonCrowther marked this pull request as ready for review September 25, 2024 19:14
@JonCrowther JonCrowther requested a review from a team as a code owner September 25, 2024 19:14
Copy link
Contributor

@pmatseykanets pmatseykanets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add checks for creatorId in the presence of no-creator-rbac in cluster and project validators. Unfortunately the common. CheckCreatorID() can't be used in those cases as it also checks if the creatorId matches request.UserInfo.Username which is not going to work (for projects for sure).

pkg/resources/common/validation.go Outdated Show resolved Hide resolved
@JonCrowther
Copy link
Contributor Author

I think we need to add checks for creatorId in the presence of no-creator-rbac in cluster and project validators. Unfortunately the common. CheckCreatorID() can't be used in those cases as it also checks if the creatorId matches request.UserInfo.Username which is not going to work (for projects for sure).

I've added a new function to common to check that only one of creatorId and no-creator-rbac is set for use by project and cluster validators.

@JonCrowther JonCrowther merged commit be481b7 into rancher:main Oct 4, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants