Skip to content

Commit

Permalink
ssc: update correct SELinux option
Browse files Browse the repository at this point in the history
set the SSC with the correct SELinux option,
given we use custom policy or not.

Signed-off-by: Talor Itzhak <[email protected]>
  • Loading branch information
Tal-or committed Oct 1, 2024
1 parent ee154e5 commit 26b08af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions controllers/numaresourcesoperator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions pkg/objectupdate/rte/rte.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 26b08af

Please sign in to comment.