Skip to content

Commit 2b5e54d

Browse files
adrianchirismarquiz
authored andcommitted
Add support running with OwnerReferencesPermissionEnforcement
when OwnerReferencesPermissionEnforcement validating webhook is enabled additional permissions are required to set/update owner ref field. NFD worker sets/updates NodeFeature owner ref field to the worker pod and owning daemonset. owner reference can only be updated if the worker has delete permissions for NodeFeatures. if owner reference has blockOwnerDeletion (as the case for the daemonset owner reference) then it requires update permissions to the finalizers of the owner, to avoid this, we set blockOwnerDeleteion to false for all owners referenced from NFD worker pod when setting/updating NodeFeature owner ref. Signed-off-by: adrianc <[email protected]> (cherry picked from commit 3f012c2)
1 parent 725c204 commit 2b5e54d

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

deployment/base/rbac/worker-role.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ rules:
1111
- create
1212
- get
1313
- update
14+
- delete
1415
- apiGroups:
1516
- ""
1617
resources:

deployment/helm/node-feature-discovery/templates/role.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ rules:
1515
- create
1616
- get
1717
- update
18+
- delete
1819
- apiGroups:
1920
- ""
2021
resources:

pkg/nfd-worker/nfd-worker.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"k8s.io/apimachinery/pkg/util/validation"
4242
k8sclient "k8s.io/client-go/kubernetes"
4343
"k8s.io/klog/v2"
44+
"k8s.io/utils/ptr"
4445
klogutils "sigs.k8s.io/node-feature-discovery/pkg/utils/klog"
4546
"sigs.k8s.io/yaml"
4647

@@ -325,7 +326,10 @@ func (w *nfdWorker) Run() error {
325326
klog.ErrorS(err, "failed to get self pod, cannot inherit ownerReference for NodeFeature")
326327
return err
327328
} else {
328-
ownerReference = append(ownerReference, selfPod.OwnerReferences...)
329+
for _, owner := range selfPod.OwnerReferences {
330+
owner.BlockOwnerDeletion = ptr.To(false)
331+
ownerReference = append(ownerReference, owner)
332+
}
329333
}
330334

331335
podUID := os.Getenv("POD_UID")

test/e2e/utils/rbac.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func createRoleWorker(ctx context.Context, cs clientset.Interface, ns string) (*
222222
{
223223
APIGroups: []string{"nfd.k8s-sigs.io"},
224224
Resources: []string{"nodefeatures"},
225-
Verbs: []string{"create", "get", "update"},
225+
Verbs: []string{"create", "get", "update", "delete"},
226226
},
227227
{
228228
APIGroups: []string{""},

0 commit comments

Comments
 (0)