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

OCPBUGS-27145: Reduce container privileges #396

Merged
merged 2 commits into from Feb 1, 2024
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
21 changes: 11 additions & 10 deletions provisioning/baremetal_pod.go
Expand Up @@ -354,6 +354,7 @@ func createInitContainerMachineOsDownloader(info *ProvisioningInfo, imageURLs st
Command: []string{command},
ImagePullPolicy: "IfNotPresent",
SecurityContext: &corev1.SecurityContext{
// Needed for hostPath image volume mount
Privileged: pointer.BoolPtr(true),
},
VolumeMounts: []corev1.VolumeMount{imageVolumeMount},
Expand All @@ -375,7 +376,9 @@ func createInitContainerStaticIpSet(images *Images, config *metal3iov1alpha1.Pro
Command: []string{"/set-static-ip"},
ImagePullPolicy: "IfNotPresent",
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.BoolPtr(true),
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{"NET_ADMIN"},
},
},
Env: []corev1.EnvVar{
buildEnvVar(provisioningIP, config),
Expand Down Expand Up @@ -455,6 +458,7 @@ func createContainerMetal3Dnsmasq(images *Images, config *metal3iov1alpha1.Provi
Image: images.Ironic,
ImagePullPolicy: "IfNotPresent",
SecurityContext: &corev1.SecurityContext{
// Needed for hostPath image volume mount
Privileged: pointer.BoolPtr(true),
},
Command: []string{"/bin/rundnsmasq"},
Expand Down Expand Up @@ -528,6 +532,7 @@ func createContainerMetal3Httpd(images *Images, config *metal3iov1alpha1.Provisi
Image: images.Ironic,
ImagePullPolicy: "IfNotPresent",
SecurityContext: &corev1.SecurityContext{
// Needed for hostPath image volume mount
Privileged: pointer.BoolPtr(true),
},
Command: []string{"/bin/runhttpd"},
Expand Down Expand Up @@ -595,6 +600,7 @@ func createContainerMetal3Ironic(images *Images, info *ProvisioningInfo, config
Image: images.Ironic,
ImagePullPolicy: "IfNotPresent",
SecurityContext: &corev1.SecurityContext{
// Needed for hostPath image volume mount
Privileged: pointer.BoolPtr(true),
},
Command: []string{"/bin/runironic"},
Expand Down Expand Up @@ -644,11 +650,8 @@ func createContainerMetal3RamdiskLogs(images *Images) corev1.Container {
Name: "metal3-ramdisk-logs",
Image: images.Ironic,
ImagePullPolicy: "IfNotPresent",
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.BoolPtr(true),
},
Command: []string{"/bin/runlogwatch.sh"},
VolumeMounts: []corev1.VolumeMount{sharedVolumeMount},
Command: []string{"/bin/runlogwatch.sh"},
VolumeMounts: []corev1.VolumeMount{sharedVolumeMount},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("10m"),
Expand All @@ -664,10 +667,7 @@ func createContainerMetal3IronicInspector(images *Images, info *ProvisioningInfo
Name: "metal3-ironic-inspector",
Image: images.Ironic,
ImagePullPolicy: "IfNotPresent",
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.BoolPtr(true),
},
Command: []string{"/bin/runironic-inspector"},
Command: []string{"/bin/runironic-inspector"},
VolumeMounts: []corev1.VolumeMount{
sharedVolumeMount,
ironicCredentialsMount,
Expand Down Expand Up @@ -713,6 +713,7 @@ func createContainerMetal3StaticIpManager(images *Images, config *metal3iov1alph
Command: []string{"/refresh-static-ip"},
ImagePullPolicy: "IfNotPresent",
SecurityContext: &corev1.SecurityContext{
// Needed for mounting /proc to set the addr_gen_mode
Privileged: pointer.BoolPtr(true),
},
Env: []corev1.EnvVar{
Expand Down
1 change: 1 addition & 0 deletions provisioning/image_cache.go
Expand Up @@ -93,6 +93,7 @@ func createContainerImageCache(images *Images) corev1.Container {
Image: images.Ironic,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
// Needed for hostPath image volume mount
Privileged: pointer.BoolPtr(true),
},
Command: []string{"/bin/runhttpd"},
Expand Down
1 change: 1 addition & 0 deletions provisioning/image_customization.go
Expand Up @@ -98,6 +98,7 @@ func createImageCustomizationContainer(images *Images, info *ProvisioningInfo, i
// TODO: This container does not have to run in privileged mode when the i-c-c has
// its own volume and does not have to use the imageCacheSharedVolume
SecurityContext: &corev1.SecurityContext{
// Needed for hostPath image volume mount
Privileged: pointer.BoolPtr(true),
},
VolumeMounts: []corev1.VolumeMount{
Expand Down
4 changes: 3 additions & 1 deletion provisioning/ironic_proxy.go
Expand Up @@ -41,7 +41,9 @@ func createContainerIronicProxy(ironicIP string, images *Images) corev1.Containe
Image: images.Ironic,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.BoolPtr(true),
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{"FOWNER"},
},
},
Command: []string{"/bin/runironic-proxy"},
VolumeMounts: []corev1.VolumeMount{
Expand Down
1 change: 1 addition & 0 deletions provisioning/machine_os_images.go
Expand Up @@ -33,6 +33,7 @@ func createInitContainerMachineOSImages(info *ProvisioningInfo, whichImages stri
},
},
SecurityContext: &corev1.SecurityContext{
// Needed for hostPath image volume mount
Privileged: pointer.BoolPtr(true),
},
}
Expand Down