Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd: add privileged support (back) to blkdevmapper securityContext (work-around) #9191

Merged
merged 1 commit into from Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/operator/ceph/cluster/osd/spec.go
Expand Up @@ -777,12 +777,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 @@ -604,12 +604,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