diff --git a/pkg/apis/serving/v1/revision_defaults.go b/pkg/apis/serving/v1/revision_defaults.go index 8acbf3446fd1..4805f5b1fe35 100644 --- a/pkg/apis/serving/v1/revision_defaults.go +++ b/pkg/apis/serving/v1/revision_defaults.go @@ -208,6 +208,10 @@ func (rs *RevisionSpec) defaultSecurityContext(psc *corev1.PodSecurityContext, c } } + if psc.RunAsNonRoot == nil { + updatedSC.RunAsNonRoot = ptr.Bool(true) + } + if *updatedSC != (corev1.SecurityContext{}) { container.SecurityContext = updatedSC }