Skip to content

Commit

Permalink
Merge pull request #9193 from rook/mergify/bp/release-1.7/pr-9191
Browse files Browse the repository at this point in the history
osd: add privileged support (back) to blkdevmapper securityContext (work-around) (backport #9191)
  • Loading branch information
mergify[bot] committed Nov 17, 2021
2 parents 20b74f0 + c35c007 commit e43878d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/operator/ceph/cluster/osd/spec.go
Expand Up @@ -860,12 +860,15 @@ func (c *Cluster) getActivateOSDInitContainer(configDir, namespace, osdID string
// To be able to perform this action, the CAP_MKNOD capability is required.
// Provide a securityContext which requests the MKNOD capability for the container to function properly.
func getBlockDevMapperContext() *v1.SecurityContext {
privileged := controller.HostPathRequiresPrivileged()

return &v1.SecurityContext{
Capabilities: &v1.Capabilities{
Add: []v1.Capability{
"MKNOD",
},
},
Privileged: &privileged,
}
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/operator/ceph/controller/spec.go
Expand Up @@ -605,12 +605,13 @@ func (c *daemonConfig) buildAdminSocketCommand() string {
return command
}

func HostPathRequiresPrivileged() bool {
return os.Getenv("ROOK_HOSTPATH_REQUIRES_PRIVILEGED") == "true"
}

// PodSecurityContext detects if the pod needs privileges to run
func PodSecurityContext() *v1.SecurityContext {
privileged := false
if os.Getenv("ROOK_HOSTPATH_REQUIRES_PRIVILEGED") == "true" {
privileged = true
}
privileged := HostPathRequiresPrivileged()

return &v1.SecurityContext{
Privileged: &privileged,
Expand Down

0 comments on commit e43878d

Please sign in to comment.