diff --git a/deployment/base/rbac/worker-role.yaml b/deployment/base/rbac/worker-role.yaml index 2b299c7973..70ee649ab4 100644 --- a/deployment/base/rbac/worker-role.yaml +++ b/deployment/base/rbac/worker-role.yaml @@ -11,6 +11,7 @@ rules: - create - get - update + - delete - apiGroups: - "" resources: diff --git a/deployment/helm/node-feature-discovery/templates/role.yaml b/deployment/helm/node-feature-discovery/templates/role.yaml index 52c69eb197..ed12ef2c03 100644 --- a/deployment/helm/node-feature-discovery/templates/role.yaml +++ b/deployment/helm/node-feature-discovery/templates/role.yaml @@ -15,6 +15,7 @@ rules: - create - get - update + - delete - apiGroups: - "" resources: diff --git a/pkg/nfd-worker/nfd-worker.go b/pkg/nfd-worker/nfd-worker.go index 21ececf152..e709c6d6e4 100644 --- a/pkg/nfd-worker/nfd-worker.go +++ b/pkg/nfd-worker/nfd-worker.go @@ -37,6 +37,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" k8sclient "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" + "k8s.io/utils/ptr" klogutils "sigs.k8s.io/node-feature-discovery/pkg/utils/klog" "sigs.k8s.io/yaml" @@ -280,7 +281,10 @@ func (w *nfdWorker) setOwnerReference() error { klog.ErrorS(err, "failed to get self pod, cannot inherit ownerReference for NodeFeature") return err } else { - ownerReference = append(ownerReference, selfPod.OwnerReferences...) + for _, owner := range selfPod.OwnerReferences { + owner.BlockOwnerDeletion = ptr.To(false) + ownerReference = append(ownerReference, owner) + } } podUID := os.Getenv("POD_UID") diff --git a/test/e2e/utils/rbac.go b/test/e2e/utils/rbac.go index 561cbf353e..49c9b34366 100644 --- a/test/e2e/utils/rbac.go +++ b/test/e2e/utils/rbac.go @@ -227,7 +227,7 @@ func createRoleWorker(ctx context.Context, cs clientset.Interface, ns string) (* { APIGroups: []string{"nfd.k8s-sigs.io"}, Resources: []string{"nodefeatures"}, - Verbs: []string{"create", "get", "update"}, + Verbs: []string{"create", "get", "update", "delete"}, }, { APIGroups: []string{""},