Skip to content

Commit 7c9412e

Browse files
feat: Jupyterhub OIDC + Cleanup (#635)
* Jupyterhub OIDC + Cleanup This PR handles a number of fixups for jupyterhub * Move to jupyterhub's chart from bitnami's, which is quite limited in capability * properly configure OIDC * use postgres as backing datastore * bump release status
1 parent a7c495e commit 7c9412e

File tree

16 files changed

+108
-75
lines changed

16 files changed

+108
-75
lines changed
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
dependencies:
22
- name: jupyterhub
3-
repository: https://charts.bitnami.com/bitnami
4-
version: 3.0.12
5-
digest: sha256:7dbd4d47e44c4b1d35ad8ee1ccb3f52c3be682826399da28bffb98564b53938a
6-
generated: "2023-04-04T18:44:50.023965-10:00"
3+
repository: https://jupyterhub.github.io/helm-chart/
4+
version: 2.0.0
5+
- name: postgres
6+
repository: https://pluralsh.github.io/module-library
7+
version: 0.1.16
8+
digest: sha256:ffbd04f736eb925a2bad525b34393970e2915095021effc4155f31ee5adcc7fb
9+
generated: "2023-04-10T11:26:48.281791-04:00"

jupyterhub/helm/jupyterhub/Chart.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ apiVersion: v2
22
name: jupyterhub
33
description: helm chart for jupyterhub
44
type: application
5-
version: 0.1.2
5+
version: 0.1.3
66
appVersion: "3.1.1"
77
maintainers:
88
- name: Samuel Gordalina
99
1010
dependencies:
1111
- name: jupyterhub
12-
version: 3.0.12
13-
repository: https://charts.bitnami.com/bitnami
12+
version: 2.0.0
13+
repository: https://jupyterhub.github.io/helm-chart/
14+
- name: postgres
15+
version: 0.1.16
16+
repository: https://pluralsh.github.io/module-library
17+
condition: postgres.enabled
44.3 KB
Binary file not shown.
-105 KB
Binary file not shown.
5.38 KB
Binary file not shown.

jupyterhub/helm/jupyterhub/templates/_helpers.tpl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{/*
22
Expand the name of the chart.
33
*/}}
4-
{{- define "jupyterhub.name" -}}
4+
{{- define "jupyterhub-plural.name" -}}
55
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
66
{{- end }}
77

@@ -10,7 +10,7 @@ Create a default fully qualified app name.
1010
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
1111
If release name contains chart name it will be used as a full name.
1212
*/}}
13-
{{- define "jupyterhub.fullname" -}}
13+
{{- define "jupyterhub-plural.fullname" -}}
1414
{{- if .Values.fullnameOverride }}
1515
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
1616
{{- else }}
@@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
2626
{{/*
2727
Create chart name and version as used by the chart label.
2828
*/}}
29-
{{- define "jupyterhub.chart" -}}
29+
{{- define "jupyterhub-plural.chart" -}}
3030
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
3131
{{- end }}
3232

3333
{{/*
3434
Common labels
3535
*/}}
36-
{{- define "jupyterhub.labels" -}}
37-
helm.sh/chart: {{ include "jupyterhub.chart" . }}
38-
{{ include "jupyterhub.selectorLabels" . }}
36+
{{- define "jupyterhub-plural.labels" -}}
37+
helm.sh/chart: {{ include "jupyterhub-plural.chart" . }}
38+
{{ include "jupyterhub-plural.selectorLabels" . }}
3939
{{- if .Chart.AppVersion }}
4040
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4141
{{- end }}
@@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
4545
{{/*
4646
Selector labels
4747
*/}}
48-
{{- define "jupyterhub.selectorLabels" -}}
49-
app.kubernetes.io/name: {{ include "jupyterhub.name" . }}
48+
{{- define "jupyterhub-plural.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "jupyterhub-plural.name" . }}
5050
app.kubernetes.io/instance: {{ .Release.Name }}
5151
{{- end }}
5252

5353
{{/*
5454
Create the name of the service account to use
5555
*/}}
56-
{{- define "jupyterhub.serviceAccountName" -}}
56+
{{- define "jupyterhub-plural.serviceAccountName" -}}
5757
{{- if .Values.serviceAccount.create }}
58-
{{- default (include "jupyterhub.fullname" .) .Values.serviceAccount.name }}
58+
{{- default (include "jupyterhub-plural.fullname" .) .Values.serviceAccount.name }}
5959
{{- else }}
6060
{{- default "default" .Values.serviceAccount.name }}
6161
{{- end }}

jupyterhub/helm/jupyterhub/templates/runbooks.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: scaling-manual
55
labels:
66
platform.plural.sh/pinned: 'true'
7-
{{ include "jupyterhub.labels" . | indent 4 }}
7+
{{ include "jupyterhub-plural.labels" . | indent 4 }}
88
spec:
99
name: JupyterHub Scaling
1010
description: overview of how to optimally scale your JupyterHub deployment
@@ -16,18 +16,18 @@ spec:
1616
prometheus:
1717
format: cpu
1818
legend: $pod
19-
query: sum(rate(container_cpu_usage_seconds_total{namespace="{{ .Release.Namespace }}",pod=~"{{ include "jupyterhub.fullname" . }}.+"}[5m])) by (pod)
19+
query: sum(rate(container_cpu_usage_seconds_total{namespace="{{ .Release.Namespace }}",pod=~"{{ include "jupyterhub-plural.fullname" . }}.+"}[5m])) by (pod)
2020
- name: jupyterhub-memory
2121
type: prometheus
2222
prometheus:
2323
format: memory
2424
legend: $pod
25-
query: sum(container_memory_working_set_bytes{namespace="{{ .Release.Namespace }}",pod=~"{{ include "jupyterhub.fullname" . }}.+"}) by (pod)
25+
query: sum(container_memory_working_set_bytes{namespace="{{ .Release.Namespace }}",pod=~"{{ include "jupyterhub-plural.fullname" . }}.+"}) by (pod)
2626
- name: jupyterhub
2727
type: kubernetes
2828
kubernetes:
2929
resource: deployment
30-
name: {{ include "jupyterhub.fullname" . }}
30+
name: {{ include "jupyterhub-plural.fullname" . }}
3131
actions:
3232
- name: scale
3333
action: config
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: jupyter.plural-postgres-jupyter.credentials.postgresql.acid.zalan.do
5+
labels:
6+
{{ include "jupyterhub-plural.labels" . | indent 4 }}
7+
stringData:
8+
username: jupyter
9+
password: {{ .Values.postgres.password }}
Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,50 @@
1+
postgres:
2+
team: plural
3+
user: jupyter
4+
dbName: jupyter
5+
ownerChart: jupyterhub
6+
infix: '-postgres'
7+
password: REPLACE_ME
8+
19
jupyterhub:
210
hub:
3-
adminUser: admin
4-
password: password
511
# image:
612
# repository: dkr.plural.sh/jupyterhub/bitnami/jupyterhub
713
# tag: 3.1.1-debian-11-r20
8-
metrics:
9-
serviceMonitor:
10-
enabled: true
11-
14+
db:
15+
type: postgres
16+
initContainers:
17+
- name: wait-for-pg
18+
image: gcr.io/pluralsh/busybox:latest
19+
imagePullPolicy: IfNotPresent
20+
command: [ "/bin/sh", "-c", "until nc -zv plural-postgres-jupyter 5432 -w1; do echo 'waiting for db'; sleep 1; done" ]
21+
networkPolicy:
22+
egress:
23+
- to:
24+
- ipBlock:
25+
cidr: 0.0.0.0/0
26+
1227
proxy:
13-
# image:
14-
# registry: dkr.plural.sh/jupyterhub/bitnami/configurable-http-proxy
15-
# tag: 4.5.4-debian-11-r39
16-
ingress:
17-
enabled: true
18-
path: /.*
19-
ingressClassName: nginx
20-
annotations:
21-
kubernetes.io/tls-acme: "true"
22-
cert-manager.io/cluster-issuer: letsencrypt-prod
23-
nginx.ingress.kubernetes.io/force-ssl-redirect: 'true'
24-
nginx.ingress.kubernetes.io/use-regex: "true"
25-
hostname: chart-example.local
26-
extraTls: []
2728
service:
28-
public:
29-
type: ClusterIP
30-
metrics:
31-
serviceMonitor:
32-
enabled: true
33-
34-
singleuser:
35-
# image:
36-
# repository: dkr.plural.sh/jupyterhub/bitnami/jupyter-base-notebook
37-
# tag: 3.1.1-debian-11-r20
38-
notebookDir: /data
39-
extraEnvVars:
40-
HOME: /data
41-
JUPYTERHUB_ROOT_DIR: /data
42-
43-
# auxiliaryImage:
44-
# image:
45-
# repository: dkr.plural.sh/jupyterhub/bitnami/bitnami-shell
46-
# tag: 11-debian-11-r102
29+
type: ClusterIP
30+
chp:
31+
networkPolicy:
32+
ingress:
33+
- ports:
34+
- port: http
35+
from:
36+
- namespaceSelector:
37+
matchLabels:
38+
kubernetes.io/metadata.name: ingress-nginx
39+
ingress:
40+
enabled: true
41+
ingressClassName: nginx
42+
pathType: ImplementationSpecific
43+
pathSuffix: '.*'
44+
annotations:
45+
kubernetes.io/tls-acme: "true"
46+
cert-manager.io/cluster-issuer: letsencrypt-prod
47+
nginx.ingress.kubernetes.io/force-ssl-redirect: 'true'
48+
nginx.ingress.kubernetes.io/use-regex: "true"
49+
hosts:
50+
- example.com
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
{{ $hostname := default "example.com" .Values.hostname }}
2-
{{ $password := dedupe . "jupyterhub.jupyterhub.hub.password" (randAlphaNum 30) }}
2+
{{ $jupyterPassword := dedupe . "jupyterhub.postgres.password" (randAlphaNum 20) }}
3+
{{ $jupyterDsn := default (printf "postgresql://jupyter:%s@plural-postgres-jupyter:5432/jupyter" $jupyterPassword) .Values.jupyterDsn }}
34

45
global:
56
application:
67
links:
78
- description: jupyterhub instance
89
url: {{ $hostname }}
910

11+
postgres:
12+
password: {{ $jupyterPassword }}
13+
1014
jupyterhub:
1115
hub:
12-
password: {{ $password }}
16+
db:
17+
url: {{ $jupyterDsn }}
1318
{{ if .OIDC }}
1419
config:
1520
GenericOAuthenticator:
@@ -21,16 +26,19 @@ jupyterhub:
2126
userdata_url: {{ .OIDC.Configuration.UserinfoEndpoint }}
2227
scope:
2328
- openid
29+
- code
30+
- offline
31+
- offline_access
2432
- profile
2533
username_key: email
2634
JupyterHub:
2735
authenticator_class: generic-oauth
2836
{{ end }}
2937

30-
proxy:
31-
ingress:
32-
hostname: {{ $hostname }}
33-
extraTls:
34-
- hosts:
35-
- {{ $hostname }}
36-
secretName: jupyterhub-tls
38+
ingress:
39+
hosts:
40+
- {{ $hostname }}
41+
tls:
42+
- hosts:
43+
- {{ $hostname }}
44+
secretName: jupyter-tls

0 commit comments

Comments
 (0)