From 723671f58c2a7fdd1682006dd993c2272200ce9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 10 Mar 2020 19:11:53 +0100 Subject: [PATCH] ceph: run osd initContainer in priv mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To access a special block device the container must run privileged. Signed-off-by: Sébastien Han --- pkg/operator/ceph/cluster/osd/spec.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkg/operator/ceph/cluster/osd/spec.go b/pkg/operator/ceph/cluster/osd/spec.go index 12257d1ae..6a06b7fb2 100644 --- a/pkg/operator/ceph/cluster/osd/spec.go +++ b/pkg/operator/ceph/cluster/osd/spec.go @@ -534,11 +534,6 @@ func (c *Cluster) getActivateOSDInitContainer(osdID string, osdInfo OSDInfo, osd volMounts = append(volMounts, getPvcOSDBridgeMount(osdProps.pvc.ClaimName)) } - privileged := true - securityContext := &v1.SecurityContext{ - Privileged: &privileged, - } - container := &v1.Container{ Command: []string{ "/bin/bash", @@ -548,7 +543,7 @@ func (c *Cluster) getActivateOSDInitContainer(osdID string, osdInfo OSDInfo, osd Name: "activate", Image: c.cephVersion.Image, VolumeMounts: volMounts, - SecurityContext: securityContext, + SecurityContext: privilegedContext(), Env: envVars, Resources: osdProps.resources, } @@ -747,7 +742,7 @@ func (c *Cluster) getActivatePVCInitContainer(osdProps osdProperties, osdID stri }, }, VolumeMounts: []v1.VolumeMount{getPvcOSDBridgeMountActivate(osdDataPath, osdProps.pvc.ClaimName)}, - SecurityContext: opmon.PodSecurityContext(), + SecurityContext: privilegedContext(), Resources: osdProps.resources, } @@ -765,7 +760,7 @@ func (c *Cluster) getExpandPVCInitContainer(osdProps osdProperties, osdID string }, Args: []string{"bluefs-bdev-expand", "--path", osdDataPath}, VolumeMounts: []v1.VolumeMount{getPvcOSDBridgeMountActivate(osdDataPath, osdProps.pvc.ClaimName)}, - SecurityContext: opmon.PodSecurityContext(), + SecurityContext: privilegedContext(), Resources: osdProps.resources, } @@ -1133,3 +1128,11 @@ func getUdevVolume() (v1.Volume, v1.VolumeMount) { return volume, volumeMounts } + +func privilegedContext() *v1.SecurityContext { + privileged := true + + return &v1.SecurityContext{ + Privileged: &privileged, + } +}