diff --git a/controllers/numaresourcesoperator_controller.go b/controllers/numaresourcesoperator_controller.go index 345d4fe8d..4e06fc128 100644 --- a/controllers/numaresourcesoperator_controller.go +++ b/controllers/numaresourcesoperator_controller.go @@ -478,6 +478,7 @@ func (r *NUMAResourcesOperatorReconciler) syncNUMAResourcesOperatorResources(ctx } rteupdate.DaemonSetHashAnnotation(r.RTEManifests.DaemonSet, cmHash) } + rteupdate.SecurityContextConstraintSetSELinuxOption(r.RTEManifests.SecurityContextConstraint, instance.IsCustomPolicyEnabled()) existing := rtestate.FromClient(ctx, r.Client, r.Platform, r.RTEManifests, instance, trees, r.Namespace) for _, objState := range existing.State(r.RTEManifests, instance, daemonsetUpdater) { diff --git a/pkg/objectupdate/rte/rte.go b/pkg/objectupdate/rte/rte.go index 9d0d351e5..f5ad2c5d3 100644 --- a/pkg/objectupdate/rte/rte.go +++ b/pkg/objectupdate/rte/rte.go @@ -25,6 +25,9 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/klog/v2" + securityv1 "github.com/openshift/api/security/v1" + + "github.com/k8stopologyawareschedwg/deployer/pkg/assets/selinux" "github.com/k8stopologyawareschedwg/deployer/pkg/flagcodec" k8swgobjupdate "github.com/k8stopologyawareschedwg/deployer/pkg/objectupdate" k8swgrteupdate "github.com/k8stopologyawareschedwg/deployer/pkg/objectupdate/rte" @@ -219,6 +222,14 @@ func AddVolumeMountMemory(podSpec *corev1.PodSpec, cnt *corev1.Container, mountN ) } +func SecurityContextConstraintSetSELinuxOption(scc *securityv1.SecurityContextConstraints, legacyRTEContext bool) { + if legacyRTEContext { + scc.SELinuxContext.SELinuxOptions.Type = selinux.RTEContextTypeLegacy + return + } + scc.SELinuxContext.SELinuxOptions.Type = selinux.RTEContextType +} + func isPodFingerprintEnabled(conf *nropv1.NodeGroupConfig) (bool, string) { cfg := nropv1.DefaultNodeGroupConfig() if conf == nil || conf.PodsFingerprinting == nil {