Skip to content

Commit 0ff92e3

Browse files
authored
Merge pull request kubernetes#82153 from robscott/endpointslice-rbac
Adding EndpointSlice RBAC for node-proxier/kube-proxy
2 parents 0466cb6 + 1f5070e commit 0ff92e3

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
@@ -352,17 +352,6 @@ func ClusterRoles() []rbacv1.ClusterRole {
352352
eventsRule(),
353353
},
354354
},
355-
{
356-
// a role to use for setting up a proxy
357-
ObjectMeta: metav1.ObjectMeta{Name: "system:node-proxier"},
358-
Rules: []rbacv1.PolicyRule{
359-
// Used to build serviceLister
360-
rbacv1helpers.NewRule("list", "watch").Groups(legacyGroup).Resources("services", "endpoints").RuleOrDie(),
361-
rbacv1helpers.NewRule("get").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
362-
363-
eventsRule(),
364-
},
365-
},
366355
{
367356
// a role to use for full access to the kubelet API
368357
ObjectMeta: metav1.ObjectMeta{Name: "system:kubelet-api-admin"},
@@ -473,6 +462,21 @@ func ClusterRoles() []rbacv1.ClusterRole {
473462
},
474463
}
475464

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

0 commit comments

Comments
 (0)