Skip to content

Commit

Permalink
pod.Spec.SecurityContext.RunAsNonRoot should be nil if --as-root sp…
Browse files Browse the repository at this point in the history
…ecifiled
  • Loading branch information
orimanabu committed Oct 6, 2021
1 parent a50423c commit 49e93d1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cli/debug/debug.go
Expand Up @@ -799,6 +799,13 @@ func (o *DebugOptions) transformPodForDebug(annotations map[string]string) (*cor
container.SecurityContext.RunAsNonRoot = nil
}

// if DebugOptions set container.SecurityContext.RunAsNonRoot to nil,
// pod.Spec.SecurityContext.runAsNonRoot should be nil also.
if container.SecurityContext.RunAsNonRoot == nil &&
pod.Spec.SecurityContext != nil {
pod.Spec.SecurityContext.RunAsNonRoot = nil
}

switch {
case o.OneContainer:
pod.Spec.InitContainers = nil
Expand Down

0 comments on commit 49e93d1

Please sign in to comment.