Skip to content

Commit 1f5070e

Browse files
committed
Adding EndpointSlice RBAC for node-proxier/kube-proxy
1 parent 47214d6 commit 1f5070e

File tree

1 file changed

+15
-11
lines changed
  • plugin/pkg/auth/authorizer/rbac/bootstrappolicy

1 file changed

+15
-11
lines changed

plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,6 @@ func ClusterRoles() []rbacv1.ClusterRole {
351351
eventsRule(),
352352
},
353353
},
354-
{
355-
// a role to use for setting up a proxy
356-
ObjectMeta: metav1.ObjectMeta{Name: "system:node-proxier"},
357-
Rules: []rbacv1.PolicyRule{
358-
// Used to build serviceLister
359-
rbacv1helpers.NewRule("list", "watch").Groups(legacyGroup).Resources("services", "endpoints").RuleOrDie(),
360-
rbacv1helpers.NewRule("get").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
361-
362-
eventsRule(),
363-
},
364-
},
365354
{
366355
// a role to use for full access to the kubelet API
367356
ObjectMeta: metav1.ObjectMeta{Name: "system:kubelet-api-admin"},
@@ -472,6 +461,21 @@ func ClusterRoles() []rbacv1.ClusterRole {
472461
},
473462
}
474463

464+
// node-proxier role is used by kube-proxy.
465+
nodeProxierRules := []rbacv1.PolicyRule{
466+
rbacv1helpers.NewRule("list", "watch").Groups(legacyGroup).Resources("services", "endpoints").RuleOrDie(),
467+
rbacv1helpers.NewRule("get").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
468+
469+
eventsRule(),
470+
}
471+
if utilfeature.DefaultFeatureGate.Enabled(features.EndpointSlice) {
472+
nodeProxierRules = append(nodeProxierRules, rbacv1helpers.NewRule("list", "watch").Groups(discoveryGroup).Resources("endpointslices").RuleOrDie())
473+
}
474+
roles = append(roles, rbacv1.ClusterRole{
475+
ObjectMeta: metav1.ObjectMeta{Name: "system:node-proxier"},
476+
Rules: nodeProxierRules,
477+
})
478+
475479
kubeSchedulerRules := []rbacv1.PolicyRule{
476480
eventsRule(),
477481
// This is for leaderlease access

0 commit comments

Comments
 (0)