mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Set runAsNonRoot=true in gen kube
If the image being used has a user set that is a positive integer greater than 0, then set the securityContext.runAsNonRoot to true for the container in the generated kube yaml. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
This commit is contained in:
@ -686,6 +686,13 @@ func containerToV1Container(ctx context.Context, c *Container) (v1.Container, []
|
||||
if imgData.User == c.User() && hasSecData {
|
||||
kubeSec.RunAsGroup, kubeSec.RunAsUser = nil, nil
|
||||
}
|
||||
// If the image has user set as a positive integer value, then set runAsNonRoot to true
|
||||
// in the kube yaml
|
||||
imgUserID, err := strconv.Atoi(imgData.User)
|
||||
if err == nil && imgUserID > 0 {
|
||||
trueBool := true
|
||||
kubeSec.RunAsNonRoot = &trueBool
|
||||
}
|
||||
|
||||
envVariables, err := libpodEnvVarsToKubeEnvVars(c.config.Spec.Process.Env, imgData.Config.Env)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user