diff --git a/deployments/operator/rbac/role.yaml b/deployments/operator/rbac/role.yaml index e2cfc377..96090f36 100644 --- a/deployments/operator/rbac/role.yaml +++ b/deployments/operator/rbac/role.yaml @@ -245,3 +245,11 @@ rules: - get - list - watch +- apiGroups: + - security.openshift.io + resources: + - securitycontextconstraints + resourceNames: + - privileged + verbs: + - use diff --git a/deployments/sgx_plugin/base/intel-sgx-plugin.yaml b/deployments/sgx_plugin/base/intel-sgx-plugin.yaml index 1429c04f..2a81e8d0 100644 --- a/deployments/sgx_plugin/base/intel-sgx-plugin.yaml +++ b/deployments/sgx_plugin/base/intel-sgx-plugin.yaml @@ -17,6 +17,8 @@ spec: - name: intel-sgx-plugin image: intel/intel-sgx-plugin:devel securityContext: + seLinuxOptions: + type: "container_device_plugin_t" readOnlyRootFilesystem: true allowPrivilegeEscalation: false imagePullPolicy: IfNotPresent diff --git a/pkg/controllers/sgx/controller.go b/pkg/controllers/sgx/controller.go index a783ae75..369da3a9 100644 --- a/pkg/controllers/sgx/controller.go +++ b/pkg/controllers/sgx/controller.go @@ -106,6 +106,9 @@ func setInitContainer(spec *v1.PodSpec, imageName string) { ImagePullPolicy: "IfNotPresent", Name: "intel-sgx-initcontainer", SecurityContext: &v1.SecurityContext{ + SELinuxOptions: &v1.SELinuxOptions{ + Type: "container_device_plugin_init_t", + }, ReadOnlyRootFilesystem: &yes, }, VolumeMounts: []v1.VolumeMount{ diff --git a/pkg/controllers/sgx/controller_test.go b/pkg/controllers/sgx/controller_test.go index 8b381fd2..f85cd221 100644 --- a/pkg/controllers/sgx/controller_test.go +++ b/pkg/controllers/sgx/controller_test.go @@ -71,6 +71,9 @@ func (c *controller) newDaemonSetExpected(rawObj client.Object) *apps.DaemonSet Image: devicePlugin.Spec.Image, ImagePullPolicy: "IfNotPresent", SecurityContext: &v1.SecurityContext{ + SELinuxOptions: &v1.SELinuxOptions{ + Type: "container_device_plugin_t", + }, ReadOnlyRootFilesystem: &yes, AllowPrivilegeEscalation: &no, },