Skip to content
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

fix: do not run containers as root by default in Helm chart #13917

Merged
merged 2 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 0 additions & 13 deletions helm/superset/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,6 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "superset-bootstrap" -}}
#!/bin/sh
{{ if .Values.additionalAptPackages }}
apt-get update -y \
&& apt-get install -y --no-install-recommends \
{{ range .Values.additionalAptPackages }}{{ . }} {{ end }}\
&& rm -rf /var/lib/apt/lists/*
{{ end -}}
{{ if .Values.additionalRequirements }}
pip install {{ range .Values.additionalRequirements }}{{ . }} {{ end }}
{{ end -}}
{{ end -}}

{{- define "superset-config" }}
import os
from cachelib.redis import RedisCache
Expand Down
2 changes: 1 addition & 1 deletion helm/superset/templates/deployment-beat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
release: {{ .Release.Name }}
spec:
securityContext:
runAsUser: 0 # Needed in order to allow pip install to work in bootstrap
runAsUser: {{ .Values.runAsUser }}
{{- if .Values.supersetCeleryBeat.initContainers }}
initContainers:
{{- tpl (toYaml .Values.supersetCeleryBeat.initContainers) . | nindent 6 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/superset/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ spec:
release: {{ .Release.Name }}
spec:
securityContext:
runAsUser: 0 # Needed in order to allow pip install to work in bootstrap
runAsUser: {{ .Values.runAsUser }}
{{- if .Values.supersetWorker.initContainers }}
initContainers:
{{- tpl (toYaml .Values.supersetWorker.initContainers) . | nindent 6 }}
Expand Down
4 changes: 2 additions & 2 deletions helm/superset/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
# Force reload on config changes
checksum/superset_config.py: {{ include "superset-config" . | sha256sum }}
checksum/superset_init.sh: {{ tpl .Values.init.initscript . | sha256sum }}
checksum/superset_bootstrap.sh: {{ include "superset-bootstrap" . | sha256sum }}
checksum/superset_bootstrap.sh: {{ tpl .Values.bootstrapScript . | sha256sum }}
checksum/connections: {{ .Values.supersetNode.connections | toYaml | sha256sum }}
checksum/extraConfigs: {{ .Values.extraConfigs | toYaml | sha256sum }}
checksum/extraSecrets: {{ .Values.extraSecrets | toYaml | sha256sum }}
Expand All @@ -50,7 +50,7 @@ spec:
release: {{ .Release.Name }}
spec:
securityContext:
runAsUser: 0 # Needed in order to allow pip install to work in bootstrap
runAsUser: {{ .Values.runAsUser }}
{{- if .Values.supersetNode.initContainers }}
initContainers:
{{- tpl (toYaml .Values.supersetNode.initContainers) . | nindent 6 }}
Expand Down
4 changes: 3 additions & 1 deletion helm/superset/templates/init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
name: {{ template "superset.name" . }}-init-db
spec:
securityContext:
runAsUser: 0 # Needed in order to allow pip install to work in bootstrap
runAsUser: {{ .Values.runAsUser }}
{{- if .Values.init.initContainers }}
initContainers:
{{- tpl (toYaml .Values.init.initContainers) . | nindent 6 }}
Expand Down Expand Up @@ -57,6 +57,8 @@ spec:
readOnly: true
{{- end }}
command: {{ tpl (toJson .Values.init.command) . }}
resources:
{{ toYaml .Values.init.resources | indent 10 }}
volumes:
- name: superset-config
secret:
Expand Down
2 changes: 1 addition & 1 deletion helm/superset/templates/secret-superset-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ stringData:
superset_init.sh: |
{{- tpl .Values.init.initscript . | nindent 4 }}
superset_bootstrap.sh: |
{{- include "superset-bootstrap" . | nindent 4 }}
{{- tpl .Values.bootstrapScript . | nindent 4 }}

{{- if .Values.extraSecrets }}
{{- range $path, $config := .Values.extraSecrets }}
Expand Down
32 changes: 23 additions & 9 deletions helm/superset/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@

replicaCount: 1

## These requirements are used to build a requirements file which is then applied on init
## of superset containers
additionalRequirements:
- "psycopg2==2.8.5"
- "redis==3.2.1"

## These apt packages are applied on init of superset containers
additionalAptPackages: {}
# - nano
# User ID directive
# Note that this user must have appropriate permissions to run the bootstrap script
runAsUser: 1000

# Install additional packages and do any other bootstrap configuration in this script
# For production clusters it's recommended to build own image with this step done in CI
bootstrapScript: |
#!/bin/bash
megakoresh marked this conversation as resolved.
Show resolved Hide resolved
# apt-get update -y &&\
# apt-get install -y --no-install-recommends nano &&\
# rm -rf /var/lib/apt/lists/*
# pip install psycopg2==2.8.5 redis==3.2.1
if [ ! -f ~/bootstrap ]; then echo "Running Superset with uid {{ .Values.runAsUser }}" > ~/bootstrap; fi

## The name of the secret which we will use to generate a superset_config.py file
## Note: this secret must have the key superset_config.py in it and can include other files as well
Expand Down Expand Up @@ -198,6 +202,16 @@ supersetCeleryBeat:
##
## Init job configuration
init:
# Configure resources
# Warning: fab commant consumes a lot of ram and can
# cause the process to be killed due to OOM if it exceeds limit
resources: {}
# limits:
# cpu:
# memory:
# requests:
# cpu:
# memory:
command:
- "/bin/sh"
- "-c"
Expand Down