Skip to content

Commit 736495d

Browse files
authored
run image as non-root user & add securitycontext values (#138)
* run image as non-root user & add securitycontext values * rm redundant comments
1 parent a5bd376 commit 736495d

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,20 @@ labels: {}
9292

9393
# securityContext -- Container-level security context
9494
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
95-
securityContext: {}
96-
# allowPrivilegeEscalation: false
95+
securityContext:
96+
runAsNonRoot: true
97+
runAsUser: 65532
98+
runAsGroup: 65532
99+
allowPrivilegeEscalation: false
97100
# capabilities:
98101
# drop:
99102
# - ALL
100103
# readOnlyRootFilesystem: true
101104
# runAsNonRoot: true
102105
# seccompProfile:
103106
# type: RuntimeDefault
107+
108+
podSecurityContext: {}
109+
# Optional, only if your cluster requires group ownership for mounted volumes:
110+
# podSecurityContext:
111+
# 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)