Skip to content

Commit

Permalink
Run containers as Non Privileged user (#168)
Browse files Browse the repository at this point in the history
This Commit,
- runs botkube containers as Non Privileged user
- adds `securityContext` filed to containers in all yaml files.
- adds `securityContext` fields to helm charts
  • Loading branch information
codenio authored and PrasadG193 committed Sep 1, 2019
1 parent 3fefcc2 commit 600ad6d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ RUN apk add --no-cache ca-certificates bash git \
# Production image
FROM alpine:3.10

# Create Non Privilaged user
RUN groupadd -g 101 botkube && \
useradd -r -u 101 -g botkube botkube

# Run as Non Privilaged user
USER botkube

COPY --from=BUILD-ENV /go/bin/botkube /go/bin/botkube
COPY --from=BUILD-ENV /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=BUILD-ENV /usr/local/bin/kubectl /usr/local/bin/kubectl
Expand Down
4 changes: 4 additions & 0 deletions deploy-all-in-one-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,7 @@ spec:
- name: certs
secret:
secretName: botkube-secret
# run as non privilaged user
securityContext:
runAsUser: 101
runAsGroup: 101
4 changes: 4 additions & 0 deletions deploy-all-in-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,7 @@ spec:
- name: config-volume
configMap:
name: botkube-configmap
# run as non privilaged user
securityContext:
runAsUser: 101
runAsGroup: 101
6 changes: 6 additions & 0 deletions helm/botkube/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ spec:
secret:
secretName: {{ include "botkube.fullname" . }}-secret
{{ end }}
{{- if .Values.securityContext }}
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
runAsGroup: {{ .Values.securityContext.runAsGroup }}
{{ end }}

6 changes: 6 additions & 0 deletions helm/botkube/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ image:
nameOverride: ""
fullnameOverride: ""

# Configure securityContext to manage user Privileges in pods
# set to run as a Non-Privileged user by default
securityContext:
runAsUser: 101
runAsGroup: 101

# set one of the log levels- info, warn, debug, error, fatal, panic
logLevel: info

Expand Down

0 comments on commit 600ad6d

Please sign in to comment.