Skip to content

Commit

Permalink
Reduce container privilege
Browse files Browse the repository at this point in the history
Many of the containers we run have to be run in privileged mode in order
to access a host volume - not only so they can write files as root, but
also to get an SELinux context that allows it.

However, some containers currently running as privileged do not require
this.
  • Loading branch information
zaneb committed Jan 15, 2024
1 parent a5c81df commit 1a9513a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion provisioning/baremetal_pod.go
Expand Up @@ -375,6 +375,7 @@ func createInitContainerStaticIpSet(images *Images, config *metal3iov1alpha1.Pro
Command: []string{"/set-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 Expand Up @@ -713,7 +714,9 @@ func createContainerMetal3StaticIpManager(images *Images, config *metal3iov1alph
Command: []string{"/refresh-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
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

0 comments on commit 1a9513a

Please sign in to comment.