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

Add config for hub/proxy/autohttps container's securityContext #1708

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
7 changes: 7 additions & 0 deletions jupyterhub/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ custom:
WARNING: You are using user placeholders without pod priority enabled, either
enable pod priority or stop using the user placeholders to avoid wasting cloud
resources.
{{- end }}

{{- if hasKey .Values.hub "uid" }}

DEPRECATION: hub.uid is deprecated in jupyterhub chart 0.9. Set the hub.containerSecurityContext.runAsUser value
directly instead.

mriedem marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
12 changes: 9 additions & 3 deletions jupyterhub/templates/hub/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,16 @@ spec:
{{- with .Values.hub.image.pullPolicy }}
imagePullPolicy: {{ . }}
{{- end }}
{{- /* Below is deprecation logic of .Values.hub.uid */}}
{{- if .Values.hub.containerSecurityContext }}
{{- $securityContext := dict }}
{{- if hasKey .Values.hub "uid" }}
{{- $_ := merge $securityContext (dict "runAsUser" .Values.hub.uid) }}
{{- end }}
{{- $_ := merge $securityContext .Values.hub.containerSecurityContext }}
securityContext:
runAsUser: {{ .Values.hub.uid }}
# Don't allow any process to execute as root inside the container
allowPrivilegeEscalation: false
{{- $securityContext | toYaml | trimSuffix "\n" | nindent 12 }}
{{- end }}
env:
- name: PYTHONUNBUFFERED
value: "1"
Expand Down
4 changes: 4 additions & 0 deletions jupyterhub/templates/proxy/autohttps/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ spec:
env:
{{- . | toYaml | trimSuffix "\n" | nindent 12 }}
{{- end }}
{{- with .Values.proxy.traefik.containerSecurityContext }}
securityContext:
{{- . | toYaml | trimSuffix "\n" | nindent 12 }}
{{- end }}
readinessProbe:
tcpSocket:
port: http
Expand Down
5 changes: 3 additions & 2 deletions jupyterhub/templates/proxy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ spec:
{{- end }}
resources:
{{- .Values.proxy.chp.resources | toYaml | trimSuffix "\n" | nindent 12 }}
{{- with .Values.proxy.containerSecurityContext }}
securityContext:
# Don't allow any process to execute as root inside the container
allowPrivilegeEscalation: false
{{- . | toYaml | trimSuffix "\n" | nindent 12 }}
{{- end }}
env:
- name: CONFIGPROXY_AUTH_TOKEN
valueFrom:
Expand Down
8 changes: 7 additions & 1 deletion jupyterhub/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ hub:
cookieSecret:
publicURL:
initContainers: []
uid: 1000
fsGid: 1000
nodeSelector: {}
concurrentSpawnLimit: 64
Expand Down Expand Up @@ -55,6 +54,9 @@ hub:
requests:
cpu: 200m
memory: 512Mi
containerSecurityContext:
runAsUser: 1000
allowPrivilegeEscalation: false
consideRatio marked this conversation as resolved.
Show resolved Hide resolved
services: {}
imagePullSecret:
enabled: false
Expand Down Expand Up @@ -127,6 +129,8 @@ proxy:
## Error: Deployment.apps "proxy" is invalid: spec.strategy.rollingUpdate: Forbidden: may not be specified when strategy `type` is 'Recreate'
## Error: UPGRADE FAILED: Deployment.apps "proxy" is invalid: spec.strategy.rollingUpdate: Forbidden: may not be specified when strategy `type` is 'Recreate'
rollingUpdate:
containerSecurityContext:
allowPrivilegeEscalation: false
service:
type: LoadBalancer
labels: {}
Expand Down Expand Up @@ -166,6 +170,8 @@ proxy:
extraVolumeMounts: []
extraStaticConfig: {}
extraDynamicConfig: {}
containerSecurityContext:
allowPrivilegeEscalation: false
Comment on lines +173 to +174
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically new since it wasn't defined before for traefik correct? Maybe that's fine?

Copy link
Member

@consideRatio consideRatio Jul 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, since it passes the tests it should be fine though. It depends on whats going on inside the traefik container though I think. Hmmm, not too confident about this actually but this is the common good practice and the traefik docker image is a well used and docker-hub official image.

secretSync:
image:
name: jupyterhub/k8s-secret-sync
Expand Down