Skip to content

Commit 4250c23

Browse files
committed
run image as non-root user & add securitycontext values
1 parent a5bd376 commit 4250c23

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

helm/templates/service.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ spec:
9898
nodeSelector:
9999
{{- toYaml . | nindent 8 }}
100100
{{- end }}
101+
{{- with .Values.podSecurityContext }}
102+
podSecurityContext:
103+
{{- toYaml . | nindent 8 }}
104+
{{- end }}
101105
containers:
102106
- name: coder-logstream-kube
103107
image: "{{ .Values.image.repo }}:{{ .Values.image.tag | default .Chart.AppVersion }}"

helm/values.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ labels: {}
9292

9393
# securityContext -- Container-level security context
9494
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
95-
securityContext: {}
95+
securityContext:
96+
runAsNonRoot: true
97+
runAsUser: 65532
98+
runAsGroup: 65532
99+
allowPrivilegeEscalation: false
100+
# Optional; enable after validation if the app never writes to disk:
101+
# readOnlyRootFilesystem: true
102+
#
96103
# allowPrivilegeEscalation: false
97104
# capabilities:
98105
# drop:
@@ -101,3 +108,8 @@ securityContext: {}
101108
# runAsNonRoot: true
102109
# seccompProfile:
103110
# type: RuntimeDefault
111+
112+
podSecurityContext: {}
113+
# Optional, only if your cluster requires group ownership for mounted volumes:
114+
# podSecurityContext:
115+
# fsGroup: 65532

scripts/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM --platform=$BUILDPLATFORM scratch AS base
22
ARG TARGETARCH
3-
COPY ./coder-logstream-kube-${TARGETARCH} /coder-logstream-kube
3+
COPY --chmod=0555 ./coder-logstream-kube-${TARGETARCH} /coder-logstream-kube
4+
USER 65532:65532
45
ENTRYPOINT ["/coder-logstream-kube"]

0 commit comments

Comments
 (0)