Skip to content

Commit 8d7cc39

Browse files
committed
Remove self-deletion permissions from kubelets
1 parent d00cb23 commit 8d7cc39

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func NodeRules() []rbacv1.PolicyRule {
107107
// Use the NodeRestriction admission plugin to limit a node to creating/updating its own API object.
108108
rbacv1helpers.NewRule("create", "get", "list", "watch").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
109109
rbacv1helpers.NewRule("update", "patch").Groups(legacyGroup).Resources("nodes/status").RuleOrDie(),
110-
rbacv1helpers.NewRule("update", "patch", "delete").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
110+
rbacv1helpers.NewRule("update", "patch").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
111111

112112
// TODO: restrict to the bound node as creator in the NodeRestrictions admission plugin
113113
rbacv1helpers.NewRule("create", "update", "patch").Groups(legacyGroup).Resources("events").RuleOrDie(),

plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,6 @@ items:
882882
resources:
883883
- nodes
884884
verbs:
885-
- delete
886885
- patch
887886
- update
888887
- apiGroups:

test/integration/auth/node_test.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,10 @@ func TestNodeAuthorizer(t *testing.T) {
530530
expectAllowed(t, createNode2MirrorPodEviction(node2Client))
531531
expectAllowed(t, createNode2(node2Client))
532532
expectAllowed(t, updateNode2Status(node2Client))
533-
expectAllowed(t, deleteNode2(node2Client))
533+
// self deletion is not allowed
534+
expectForbidden(t, deleteNode2(node2Client))
535+
// clean up node2
536+
expectAllowed(t, deleteNode2(superuserClient))
534537

535538
// create a pod as an admin to add object references
536539
expectAllowed(t, createNode2NormalPod(superuserClient))
@@ -621,7 +624,7 @@ func TestNodeAuthorizer(t *testing.T) {
621624
// node2 can no longer get the configmap after it is unassigned as its config source
622625
expectForbidden(t, getConfigMapConfigSource(node2Client))
623626
// clean up node2
624-
expectAllowed(t, deleteNode2(node2Client))
627+
expectAllowed(t, deleteNode2(superuserClient))
625628

626629
//TODO(mikedanese): integration test node restriction of TokenRequest
627630

0 commit comments

Comments
 (0)