Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zero-to-jupyterhub-k8s
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RWTHjupyter
Upstream
zero-to-jupyterhub-k8s
Commits
9cf2fc1e
Commit
9cf2fc1e
authored
4 years ago
by
Steffen Vogel
Browse files
Options
Downloads
Patches
Plain Diff
support additional environment variables in hub deployment
parent
fbd7e4a2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
jupyterhub/schema.yaml
+32
-0
32 additions, 0 deletions
jupyterhub/schema.yaml
jupyterhub/templates/_helpers.tpl
+39
-0
39 additions, 0 deletions
jupyterhub/templates/_helpers.tpl
jupyterhub/templates/hub/deployment.yaml
+1
-13
1 addition, 13 deletions
jupyterhub/templates/hub/deployment.yaml
with
72 additions
and
13 deletions
jupyterhub/schema.yaml
+
32
−
0
View file @
9cf2fc1e
...
...
@@ -866,6 +866,38 @@ properties:
description
:
|
Deprecated and no longer does anything. Use the user-scheduler instead
in order to accomplish a good packing of the user pods.
extraEnv
:
type
:
object
description
:
|
Extra environment variables that should be set for the user pods.
String literals with `$(ENV_VAR_NAME)` will be expanded by Kubelet which
is a part of Kubernetes. Note that the user pods will already have
access to a set of environment variables that you can use, like
`JUPYTERHUB_USER` and `JUPYTERHUB_HOST`. For more information about these
inspect [this source
code](https://github.com/jupyterhub/jupyterhub/blob/cc8e7806530466dce8968567d1bbd2b39a7afa26/jupyterhub/spawner.py#L763).
```yaml
singleuser:
extraEnv:
# basic notation (for literal values only)
MY_ENV_VARS_NAME1: "my env var value 1"
# explicit notation (the "name" field takes precedence)
USER_NAMESPACE:
name: USER_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# implicit notation (the "name" field is implied)
PREFIXED_USER_NAMESPACE:
value: "my-prefix-$(USER_NAMESPACE)"
SECRET_VALUE:
valueFrom:
secretKeyRef:
name: my-k8s-secret
key: password
```
For more information, see the [Kubernetes EnvVar
specification](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#envvar-v1-core).
extraTolerations
:
type
:
list
description
:
|
...
...
This diff is collapsed.
Click to expand it.
jupyterhub/templates/_helpers.tpl
+
39
−
0
View file @
9cf2fc1e
...
...
@@ -267,3 +267,42 @@ limits:
{{- end }}
{{- end }}
{{- end }}
{{- /*
jupyterhub.extraEnv:
Output YAML formatted EnvVar entries for use in a containers env field.
*/}}
{{- define "jupyterhub.extraEnv" -}}
{{- include "jupyterhub.extraEnv.withTrailingNewLine" . | trimSuffix "\n" }}
{{- end }}
{{- define "jupyterhub.extraEnv.withTrailingNewLine" -}}
{{- if . }}
{{- /* If extraEnv is a list, we inject it as it is. */}}
{{- if eq (typeOf .) "[]interface {}" }}
{{- . | toYaml }}
{{- /* If extraEnv is a map, we differentiate two cases: */}}
{{- else if eq (typeOf .) "map[string]interface {}" }}
{{- range $key, $value := . }}
{{- /*
- If extraEnv.someKey has a map value, then we add the value as a YAML
parsed list element and use the key as the name value unless its
explicitly set.
*/}}
{{- if eq (typeOf $value) "map[string]interface {}" }}
{{- merge (dict) $value (dict "name" $key) | list | toYaml | println }}
{{- /*
- If extraEnv.someKey has a string value, then we use the key as the
environment variable name for the value.
*/}}
{{- else if eq (typeOf $value) "string" -}}
- name: {{ $key | quote }}
value: {{ $value | quote | println }}
{{- else }}
{{- printf "?.extraEnv.%s had an unexpected type (%s)" $key (typeOf $value) | fail }}
{{- end }}
{{- end }} {{- /* end of range */}}
{{- end }}
{{- end }} {{- /* end of: if . */}}
{{- end }} {{- /* end of definition */}}
This diff is collapsed.
Click to expand it.
jupyterhub/templates/hub/deployment.yaml
+
1
−
13
View file @
9cf2fc1e
...
...
@@ -202,19 +202,7 @@ spec:
key
:
hub.db.password
{{
- end
}}
{{
- end
}}
{{
- if .Values.hub.extraEnv
}}
{{
- $extraEnvType
:
= typeOf .Values.hub.extraEnv
}}
{{
- /* If we have a list
,
embed that here directly. This allows for complex configuration from configmap
,
downward API
,
etc. */
}}
{{
- if eq $extraEnvType "
[]
interface
{}
"
}}
{{-
.Values.hub.extraEnv
|
toYaml
|
trimSuffix
"
\n" | nindent 12
}}
{{
- else if eq $extraEnvType "map
[
string
]
interface
{}
"
}}
{{-
/*
If
we
have
a
map,
treat
those
as
key-value
pairs.
*/}}
{{-
range
$key,
$value
:=
.Values.hub.extraEnv
}}
-
name:
{{
$key
|
quote
}}
value:
{{
$value
|
quote
}}
{{-
end
}}
{{-
end
}}
{{-
end
}}
{{
- include "jupyterhub.extraEnv" .Values.hub.extraEnv | nindent 12
}}
ports
:
-
containerPort
:
8081
name
:
hub
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment