Skip to content

Commit

Permalink
makes securityContext.Privileged configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
KapilSareen committed Dec 2, 2024
1 parent 5717d19 commit 4809dca
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config/core/300-resources/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ spec:
automountServiceAccountToken:
description: AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.
type: boolean
Privileged:
description: Indicates whether to run container in privileged mode.
type: boolean
containerConcurrency:
description: |-
ContainerConcurrency specifies the maximum allowed in-flight (concurrent)
Expand Down
3 changes: 3 additions & 0 deletions config/core/300-resources/revision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ spec:
automountServiceAccountToken:
description: AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.
type: boolean
Privileged:
description: Indicates whether to run container in privileged mode.
type: boolean
containerConcurrency:
description: |-
ContainerConcurrency specifies the maximum allowed in-flight (concurrent)
Expand Down
3 changes: 3 additions & 0 deletions config/core/300-resources/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ spec:
automountServiceAccountToken:
description: AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.
type: boolean
Privileged:
description: Indicates whether to run container in privileged mode.
type: boolean
containerConcurrency:
description: |-
ContainerConcurrency specifies the maximum allowed in-flight (concurrent)
Expand Down
1 change: 1 addition & 0 deletions hack/schemapatch-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ k8s.io/api/core/v1.PodSpec:
- ImagePullSecrets
- EnableServiceLinks
- AutomountServiceAccountToken
- Privileged
# Properties behind feature flags
- Affinity
- DNSConfig
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/serving/fieldmask.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,12 @@ func SecurityContextMask(ctx context.Context, in *corev1.SecurityContext) *corev
// SeccompProfile defaults to "unconstrained", but the safe values are
// "RuntimeDefault" or "Localhost" (with localhost path set)
out.SeccompProfile = in.SeccompProfile

// Allow setting Privileged to only false
if in.Privileged != nil && !*in.Privileged {
out.Privileged = in.Privileged
}
// Disallowed
// This list is unnecessary, but added here for clarity
out.Privileged = nil
out.SELinuxOptions = nil
out.ProcMount = nil

Expand Down

0 comments on commit 4809dca

Please sign in to comment.