Skip to content

Commit 7b04b44

Browse files
Paulo GomesSanskar Jaiswal
andcommitted
security: Drop capabilities and enable seccomp
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. BREAKING CHANGE: The use of new seccomp API requires Kubernetes 1.19. Co-authored-by: Sanskar Jaiswal <[email protected]> Signed-off-by: Paulo Gomes <[email protected]>
1 parent 3ca05e1 commit 7b04b44

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ FROM debian:bookworm-slim as controller
9191
LABEL org.opencontainers.image.source="https://github.com/fluxcd/source-controller"
9292

9393
# Configure user
94-
RUN groupadd controller && \
95-
useradd --gid controller --shell /bin/sh --create-home controller
94+
RUN addgroup --gid 65532 controller && \
95+
useradd -u 65532 -s /sbin/nologin -g controller controller
9696

9797
ARG TARGETPLATFORM
9898
RUN apt update && apt install -y ca-certificates

config/manager/deployment.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ spec:
2020
prometheus.io/port: "8080"
2121
spec:
2222
terminationGracePeriodSeconds: 10
23-
# Required for AWS IAM Role bindings
24-
# https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html
2523
securityContext:
24+
# Required for AWS IAM Role bindings
25+
# https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html
2626
fsGroup: 1337
2727
containers:
2828
- name: manager
@@ -31,6 +31,10 @@ spec:
3131
securityContext:
3232
allowPrivilegeEscalation: false
3333
readOnlyRootFilesystem: true
34+
capabilities:
35+
drop: [ "ALL" ]
36+
seccompProfile:
37+
type: RuntimeDefault
3438
ports:
3539
- containerPort: 9090
3640
name: http

0 commit comments

Comments
 (0)