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: set blkdevmapper capabilities #9158

Merged
merged 1 commit into from Nov 15, 2021
Merged
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
27 changes: 20 additions & 7 deletions pkg/operator/ceph/cluster/osd/spec.go
Expand Up @@ -773,6 +773,19 @@ func (c *Cluster) getActivateOSDInitContainer(configDir, namespace, osdID string
return volume, container
}

// The blockdevmapper container copies the device node file, which is regarded as a device special file.
// 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 {
return &v1.SecurityContext{
Capabilities: &v1.Capabilities{
Add: []v1.Capability{
"MKNOD",
leseb marked this conversation as resolved.
Show resolved Hide resolved
},
},
}
}

// Currently we can't mount a block mode pv directly to a privileged container
// So we mount it to a non privileged init container and then copy it to a common directory mounted inside init container
// and the privileged provision container.
Expand All @@ -792,7 +805,7 @@ func (c *Cluster) getPVCInitContainer(osdProps osdProperties) v1.Container {
},
},
VolumeMounts: []v1.VolumeMount{getPvcOSDBridgeMount(osdProps.pvc.ClaimName)},
SecurityContext: controller.PodSecurityContext(),
SecurityContext: getBlockDevMapperContext(),
Resources: osdProps.resources,
}
}
Expand Down Expand Up @@ -824,7 +837,7 @@ func (c *Cluster) getPVCInitContainerActivate(mountPath string, osdProps osdProp
},
},
VolumeMounts: []v1.VolumeMount{getPvcOSDBridgeMountActivate(mountPath, osdProps.pvc.ClaimName)},
SecurityContext: controller.PodSecurityContext(),
SecurityContext: getBlockDevMapperContext(),
Resources: osdProps.resources,
}
}
Expand Down Expand Up @@ -931,7 +944,7 @@ func (c *Cluster) generateEncryptionCopyBlockContainer(resources v1.ResourceRequ
// volumeMountPVCName is crucial, especially when the block we copy is the metadata block
// its value must be the name of the block PV so that all init containers use the same bridge (the emptyDir shared by all the init containers)
VolumeMounts: []v1.VolumeMount{getPvcOSDBridgeMountActivate(mountPath, volumeMountPVCName), getDeviceMapperMount()},
SecurityContext: controller.PodSecurityContext(),
SecurityContext: getBlockDevMapperContext(),
Resources: resources,
}
}
Expand Down Expand Up @@ -978,7 +991,7 @@ func (c *Cluster) getPVCMetadataInitContainer(mountPath string, osdProps osdProp
Name: fmt.Sprintf("%s-bridge", osdProps.metadataPVC.ClaimName),
},
},
SecurityContext: controller.PodSecurityContext(),
SecurityContext: getBlockDevMapperContext(),
Resources: osdProps.resources,
}
}
Expand Down Expand Up @@ -1012,7 +1025,7 @@ func (c *Cluster) getPVCMetadataInitContainerActivate(mountPath string, osdProps
// We need to call getPvcOSDBridgeMountActivate() so that we can copy the metadata block into the "main" empty dir
// This empty dir is passed along every init container
VolumeMounts: []v1.VolumeMount{getPvcOSDBridgeMountActivate(mountPath, osdProps.pvc.ClaimName)},
SecurityContext: controller.PodSecurityContext(),
SecurityContext: getBlockDevMapperContext(),
Resources: osdProps.resources,
}
}
Expand All @@ -1038,7 +1051,7 @@ func (c *Cluster) getPVCWalInitContainer(mountPath string, osdProps osdPropertie
Name: fmt.Sprintf("%s-bridge", osdProps.walPVC.ClaimName),
},
},
SecurityContext: controller.PodSecurityContext(),
SecurityContext: getBlockDevMapperContext(),
Resources: osdProps.resources,
}
}
Expand Down Expand Up @@ -1072,7 +1085,7 @@ func (c *Cluster) getPVCWalInitContainerActivate(mountPath string, osdProps osdP
// We need to call getPvcOSDBridgeMountActivate() so that we can copy the wal block into the "main" empty dir
// This empty dir is passed along every init container
VolumeMounts: []v1.VolumeMount{getPvcOSDBridgeMountActivate(mountPath, osdProps.pvc.ClaimName)},
SecurityContext: controller.PodSecurityContext(),
SecurityContext: getBlockDevMapperContext(),
Resources: osdProps.resources,
}
}
Expand Down