Skip to content

Commit

Permalink
Apply UID/GID defaults from image
Browse files Browse the repository at this point in the history
`build/Dockerfile` specifies `USER 101` for `common` target,
which is re-applied into the final images. Helm Chart/Manifests
do not need to specify UID explicitly, and can instead use
the image's UID. (PodSecurityContext v1 core specifies `runAsUser`
defaults to user specified in image metadata if unspecified.)

The existing `runAsNonRoot: true` flag (already in place) will ensure
during runtime that the image is configured with a custom user ID.

This is notably helpful for users running OpenShift, because OpenShift
attempts to enforce custom UID/GID ranges for individual namespaces
as part of `restricted-v2` Security Context Constraint. When removing
hard-coded values from manifests, OpenShift will be able to assign its
own UID/GID.

In practice, this means a different model of configuring file system
permissions. OpenShift assigns the container process GID 0 as
supplemental to assist with that. Locations that are expected to be
written to must be owned by GID 0, with group write permissions.
Previous changes to `main` have ensured that is the case.

Init container copying files is not a concern, as we will
have the same UID as owner there as the main NIC container.

Reference: https://cloud.redhat.com/blog/a-guide-to-openshift-and-uids
  • Loading branch information
sigv committed May 8, 2024
1 parent 1593812 commit ee75176
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 13 deletions.
2 changes: 0 additions & 2 deletions charts/nginx-ingress/templates/controller-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ spec:
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: {{ .Values.controller.readOnlyRootFilesystem }}
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
Expand Down Expand Up @@ -153,7 +152,6 @@ spec:
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
Expand Down
2 changes: 0 additions & 2 deletions charts/nginx-ingress/templates/controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ spec:
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: {{ .Values.controller.readOnlyRootFilesystem }}
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
Expand Down Expand Up @@ -160,7 +159,6 @@ spec:
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
Expand Down
1 change: 0 additions & 1 deletion charts/nginx-ingress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ controller:
securityContext: {} # Remove curly brackets before adding values
# allowPrivilegeEscalation: true
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
Expand Down
2 changes: 0 additions & 2 deletions deployments/daemon-set/nginx-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ spec:
securityContext:
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
Expand Down Expand Up @@ -103,7 +102,6 @@ spec:
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
Expand Down
2 changes: 0 additions & 2 deletions deployments/daemon-set/nginx-plus-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ spec:
securityContext:
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
Expand Down Expand Up @@ -106,7 +105,6 @@ spec:
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
Expand Down
2 changes: 0 additions & 2 deletions deployments/deployment/nginx-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ spec:
securityContext:
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
Expand Down Expand Up @@ -104,7 +103,6 @@ spec:
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
Expand Down
2 changes: 0 additions & 2 deletions deployments/deployment/nginx-plus-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ spec:
securityContext:
allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
runAsUser: 101 #nginx
runAsNonRoot: true
capabilities:
drop:
Expand Down Expand Up @@ -110,7 +109,6 @@ spec:
# securityContext:
# allowPrivilegeEscalation: false
# readOnlyRootFilesystem: true
# runAsUser: 101 #nginx
# runAsNonRoot: true
# capabilities:
# drop:
Expand Down

0 comments on commit ee75176

Please sign in to comment.