Skip to content

Commit f469418

Browse files
authored
Merge pull request #38 from fluxcd/nonroot
build: run controller as a non-root user
2 parents 1a1b288 + a6a41ee commit f469418

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ RUN apk add --no-cache openssh-client ca-certificates tini 'git>=2.12.0' socat c
2424

2525
COPY --from=builder /workspace/source-controller /usr/local/bin/
2626

27+
RUN addgroup -S controller && adduser -S -g controller controller
28+
29+
USER controller
30+
2731
ENTRYPOINT [ "/sbin/tini", "--", "source-controller" ]

config/manager/deployment.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ spec:
2323
- name: manager
2424
image: fluxcd/source-controller
2525
imagePullPolicy: IfNotPresent
26+
securityContext:
27+
allowPrivilegeEscalation: false
28+
readOnlyRootFilesystem: true
2629
ports:
2730
- containerPort: 8080
2831
name: http
@@ -37,6 +40,14 @@ spec:
3740
valueFrom:
3841
fieldRef:
3942
fieldPath: metadata.namespace
43+
livenessProbe:
44+
httpGet:
45+
port: http
46+
path: /
47+
readinessProbe:
48+
httpGet:
49+
port: http
50+
path: /
4051
resources:
4152
limits:
4253
cpu: 1000m
@@ -47,6 +58,10 @@ spec:
4758
volumeMounts:
4859
- name: data
4960
mountPath: /data
61+
- name: tmp
62+
mountPath: /tmp
5063
volumes:
5164
- name: data
5265
emptyDir: {}
66+
- name: tmp
67+
emptyDir: {}

0 commit comments

Comments
 (0)