From 34700d66059bf84ae686b2738724e5d5401ee844 Mon Sep 17 00:00:00 2001 From: carlory Date: Mon, 24 Nov 2025 16:33:58 +0800 Subject: [PATCH] add Workload permissions to view, edit and admin clusterroles Signed-off-by: carlory --- .../authorizer/rbac/bootstrappolicy/policy.go | 6 ++++++ .../testdata/cluster-roles-featuregates.yaml | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go index 79e643257a9..1e3b75cd68b 100644 --- a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go +++ b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go @@ -146,6 +146,9 @@ func viewRules() []rbacv1.PolicyRule { if utilfeature.DefaultFeatureGate.Enabled(features.DynamicResourceAllocation) { rules = append(rules, rbacv1helpers.NewRule(Read...).Groups(resourceGroup).Resources("resourceclaims", "resourceclaims/status", "resourceclaimtemplates").RuleOrDie()) } + if utilfeature.DefaultFeatureGate.Enabled(features.GenericWorkload) { + rules = append(rules, rbacv1helpers.NewRule(Read...).Groups(schedulingGroup).Resources("workloads").RuleOrDie()) + } return rules } @@ -187,6 +190,9 @@ func editRules() []rbacv1.PolicyRule { if utilfeature.DefaultFeatureGate.Enabled(features.DynamicResourceAllocation) { rules = append(rules, rbacv1helpers.NewRule(Write...).Groups(resourceGroup).Resources("resourceclaims", "resourceclaimtemplates").RuleOrDie()) } + if utilfeature.DefaultFeatureGate.Enabled(features.GenericWorkload) { + rules = append(rules, rbacv1helpers.NewRule(Write...).Groups(schedulingGroup).Resources("workloads").RuleOrDie()) + } return rules } diff --git a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles-featuregates.yaml b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles-featuregates.yaml index 3365e89836e..31d6a31bc30 100644 --- a/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles-featuregates.yaml +++ b/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles-featuregates.yaml @@ -260,6 +260,16 @@ items: - deletecollection - patch - update + - apiGroups: + - scheduling.k8s.io + resources: + - workloads + verbs: + - create + - delete + - deletecollection + - patch + - update - apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -414,6 +424,14 @@ items: - get - list - watch + - apiGroups: + - scheduling.k8s.io + resources: + - workloads + verbs: + - get + - list + - watch - apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: