Skip to content

switching to use non-root user and read-only file system #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ WORKDIR /go/src/github.com/deliveryhero/k8s-event-logger
COPY main.go .
RUN go get -d -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

RUN adduser --disabled-login --no-create-home --disabled-password --system --uid 101 non-root
FROM alpine:3.9.3
RUN apk --no-cache add ca-certificates
WORKDIR /root/
WORKDIR /
COPY --from=0 /go/src/github.com/deliveryhero/k8s-event-logger/main k8s-event-logger
CMD ["/root/k8s-event-logger"]
USER 101
ENV USER non-root
CMD ["/k8s-event-logger"]
3 changes: 3 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ spec:
- name: app
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
readOnlyRootFilesystem: true
runAsNonRoot: true
env:
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
image:
repository: tools4k8s/k8s-event-logger
tag: "1.2"
tag: "1.3"
pullPolicy: IfNotPresent

resources:
Expand Down