Skip to content

Consolidate RBAC for Guardian to handle backend component requests from the management cluster#3969

Merged
caseydavenport merged 2 commits intotigera:masterfrom
vara2504:mf_con_guardian_rbac
Jun 14, 2025
Merged

Consolidate RBAC for Guardian to handle backend component requests from the management cluster#3969
caseydavenport merged 2 commits intotigera:masterfrom
vara2504:mf_con_guardian_rbac

Conversation

@vara2504
Copy link
Contributor

@vara2504 vara2504 commented Jun 6, 2025

Consolidates the necessary RBAC in the managed cluster into a single Guardian identity to handle all backend requests from the management cluster.

Guardian will handle the request made behalf of the following service accounts form management cluster for enterprise.
system:serviceaccount:calico-system:calico-kube-controllers
system:serviceaccount:tigera-elasticsearch:tigera-linseed
system:serviceaccount:tigera-intrusion-detection:intrusion-detection-controller
system:serviceaccount:tigera-manager:tigera-manager
system:serviceaccount:tigera-policy-recommendation:tigera-policy-recommendation

Description

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@marvin-tigera marvin-tigera added this to the v1.39.0 milestone Jun 6, 2025
@vara2504 vara2504 force-pushed the mf_con_guardian_rbac branch from 880721b to 0c20677 Compare June 6, 2025 20:52
@vara2504 vara2504 marked this pull request as ready for review June 6, 2025 21:23
@vara2504 vara2504 requested a review from a team as a code owner June 6, 2025 21:23

// CalicoKubeControllersClusterRoleRules defines RBAC rules for calico-kube-controller pods
// and for guardian to handle kube-controller requests from the management cluster.
func CalicoKubeControllersClusterRoleRules(isEnterpriseCluster bool, isOpenShift bool, isManagedCluster bool) []rbacv1.PolicyRule {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In our existing code, we have some common functions within kubecontroller for building the ClusterRole rules used by both calico-kube-controllers and es-calico-kube-controllers, which are passed into the renderer via cfg.
To enable reuse between kube-controllers and Guardian, I’ve moved these functions to a common file under render.

Copy link
Member

Choose a reason for hiding this comment

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

Could guardian not just import these from pkg/render/kubecontrollers?

Guessing there was an import cycle? Best way to fix it would likely be to have pkg/render/guardian/guardian.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it’s to avoid an import cycle.
I moved it into a common function to prevent duplicating the same code in both Guardian and KubeController, which would otherwise require updates in two separate places in the future.

Copy link
Member

Choose a reason for hiding this comment

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

I think these should still be in the kubecontrollers package, and guardian should be a new guardian package in order to fix this - otherwise these are outliers compared to how we do permissions for everything else.

Happy for that to be another PR though.

Copy link
Member

@caseydavenport caseydavenport left a comment

Choose a reason for hiding this comment

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

Thanks @vara2504 - added some thoughts


// CalicoKubeControllersClusterRoleRules defines RBAC rules for calico-kube-controller pods
// and for guardian to handle kube-controller requests from the management cluster.
func CalicoKubeControllersClusterRoleRules(isEnterpriseCluster bool, isOpenShift bool, isManagedCluster bool) []rbacv1.PolicyRule {
Copy link
Member

Choose a reason for hiding this comment

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

Could guardian not just import these from pkg/render/kubecontrollers?

Guessing there was an import cycle? Best way to fix it would likely be to have pkg/render/guardian/guardian.go?

@vara2504 vara2504 changed the title Consolidate RBAC for Guardian to handle backend component requests from the management cluster [Do not merge] Consolidate RBAC for Guardian to handle backend component requests from the management cluster Jun 10, 2025
@vara2504 vara2504 force-pushed the mf_con_guardian_rbac branch from 268653d to 2f74da1 Compare June 10, 2025 23:29
@vara2504 vara2504 force-pushed the mf_con_guardian_rbac branch from 2f74da1 to e210655 Compare June 11, 2025 23:32
@caseydavenport caseydavenport changed the title [Do not merge] Consolidate RBAC for Guardian to handle backend component requests from the management cluster Consolidate RBAC for Guardian to handle backend component requests from the management cluster Jun 13, 2025
@vara2504 vara2504 force-pushed the mf_con_guardian_rbac branch from ef2773a to d41d6bb Compare June 13, 2025 21:50
@vara2504
Copy link
Contributor Author

@caseydavenport Since these changes affect only the backend components of the management cluster, no documentation or release notes are required

@caseydavenport caseydavenport merged commit 6190905 into tigera:master Jun 14, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants