Skip to content

Commit

Permalink
resources: set SecurityContext for privileged containers
Browse files Browse the repository at this point in the history
Define explicit SecurityContext entry for containers which require
privileged capabilities. Required when running over OpenShift cluster.

Signed-off-by: Shachar Sharon <[email protected]>
  • Loading branch information
synarete authored and mergify[bot] committed Mar 23, 2023
1 parent 2c5a5ba commit 6be54e3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/resources/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ func buildSmbdCtr(
},
},
},
SecurityContext: ctrPrivSecurityContext(),
}
}

Expand Down Expand Up @@ -589,6 +590,7 @@ func buildSvcWatchCtr(
Name: "svc-watch",
Env: env,
VolumeMounts: mounts,
SecurityContext: ctrPrivSecurityContext(),
}
}

Expand Down Expand Up @@ -621,6 +623,7 @@ func buildEnsureShareCtr(
Args: planner.Args().EnsureSharePaths(),
Env: env,
VolumeMounts: mounts,
SecurityContext: ctrPrivSecurityContext(),
}
}

Expand Down Expand Up @@ -838,3 +841,10 @@ func imagePullPolicy(pl *pln.Planner) corev1.PullPolicy {
}
return pullPolicy
}

func ctrPrivSecurityContext() *corev1.SecurityContext {
return &corev1.SecurityContext{
Privileged: &[]bool{true}[0],
RunAsNonRoot: &[]bool{false}[0],
}
}

0 comments on commit 6be54e3

Please sign in to comment.