Skip to content

Commit

Permalink
drop capabilities, enable seccomp and enforce runAsNonRoot
Browse files Browse the repository at this point in the history
Further restricts the SecurityContext that the controller runs under, by enabling the default seccomp profile and dropping all linux capabilities.
This was set at container-level to ensure backwards compatibility with use cases in which sidecars are injected into the source-controller pod
without setting less restrictive settings.
Add a uid and gid for the container to enforce runAsNonRoot and ensure
the use of non root users.

BREAKING CHANGES:
1) The use of new seccomp API requires Kubernetes 1.19.
2) the controller container is now executed under 65534:65534 (userid:groupid).
   This change may break deployments that hard-coded the user name 'controller' in their PodSecurityPolicy.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
Co-authored-by: Paulo Gomes <paulo.gomes@weave.works>
  • Loading branch information
aryan9600 and Paulo Gomes committed Jan 20, 2022
1 parent 0c10cf0 commit d454180
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ RUN apk add --no-cache ca-certificates tini

COPY --from=builder /workspace/image-reflector-controller /usr/local/bin/

RUN addgroup -S controller && adduser -S controller -G controller

USER controller
USER 65534:65534

ENTRYPOINT [ "/sbin/tini", "--", "image-reflector-controller" ]
5 changes: 5 additions & 0 deletions config/manager/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ spec:
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop: [ "ALL" ]
seccompProfile:
type: RuntimeDefault
ports:
- containerPort: 8080
name: http-prom
Expand Down

0 comments on commit d454180

Please sign in to comment.