mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-28 21:13:35 +00:00
authz: nodes should not be able to delete themselves
This commit is contained in:
parent
9c60fd5242
commit
35de82094a
@ -105,7 +105,7 @@ func NodeRules() []rbac.PolicyRule {
|
|||||||
// Use the NodeRestriction admission plugin to limit a node to creating/updating its own API object.
|
// Use the NodeRestriction admission plugin to limit a node to creating/updating its own API object.
|
||||||
rbac.NewRule("create", "get", "list", "watch").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
|
rbac.NewRule("create", "get", "list", "watch").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
|
||||||
rbac.NewRule("update", "patch").Groups(legacyGroup).Resources("nodes/status").RuleOrDie(),
|
rbac.NewRule("update", "patch").Groups(legacyGroup).Resources("nodes/status").RuleOrDie(),
|
||||||
rbac.NewRule("update", "patch", "delete").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
|
rbac.NewRule("update", "patch").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
|
||||||
|
|
||||||
// TODO: restrict to the bound node as creator in the NodeRestrictions admission plugin
|
// TODO: restrict to the bound node as creator in the NodeRestrictions admission plugin
|
||||||
rbac.NewRule("create", "update", "patch").Groups(legacyGroup).Resources("events").RuleOrDie(),
|
rbac.NewRule("create", "update", "patch").Groups(legacyGroup).Resources("events").RuleOrDie(),
|
||||||
|
@ -1067,7 +1067,6 @@ items:
|
|||||||
resources:
|
resources:
|
||||||
- nodes
|
- nodes
|
||||||
verbs:
|
verbs:
|
||||||
- delete
|
|
||||||
- patch
|
- patch
|
||||||
- update
|
- update
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
|
@ -418,7 +418,8 @@ func TestNodeAuthorizer(t *testing.T) {
|
|||||||
expectAllowed(t, createNode2MirrorPodEviction(node2Client))
|
expectAllowed(t, createNode2MirrorPodEviction(node2Client))
|
||||||
expectAllowed(t, createNode2(node2Client))
|
expectAllowed(t, createNode2(node2Client))
|
||||||
expectAllowed(t, updateNode2Status(node2Client))
|
expectAllowed(t, updateNode2Status(node2Client))
|
||||||
expectAllowed(t, deleteNode2(node2Client))
|
// cleanup node
|
||||||
|
expectAllowed(t, deleteNode2(superuserClient))
|
||||||
|
|
||||||
// create a pod as an admin to add object references
|
// create a pod as an admin to add object references
|
||||||
expectAllowed(t, createNode2NormalPod(superuserClient))
|
expectAllowed(t, createNode2NormalPod(superuserClient))
|
||||||
@ -508,8 +509,10 @@ func TestNodeAuthorizer(t *testing.T) {
|
|||||||
expectAllowed(t, unsetNode2ConfigSource(superuserClient))
|
expectAllowed(t, unsetNode2ConfigSource(superuserClient))
|
||||||
// node2 can no longer get the configmap after it is unassigned as its config source
|
// node2 can no longer get the configmap after it is unassigned as its config source
|
||||||
expectForbidden(t, getConfigMapConfigSource(node2Client))
|
expectForbidden(t, getConfigMapConfigSource(node2Client))
|
||||||
|
// node should not be able to delete itself
|
||||||
|
expectForbidden(t, deleteNode2(node2Client))
|
||||||
// clean up node2
|
// clean up node2
|
||||||
expectAllowed(t, deleteNode2(node2Client))
|
expectAllowed(t, deleteNode2(superuserClient))
|
||||||
|
|
||||||
//TODO(mikedanese): integration test node restriction of TokenRequest
|
//TODO(mikedanese): integration test node restriction of TokenRequest
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user