Skip to content

Commit b923f2b

Browse files
authored
Merge pull request #51 from Gradiant/jupyter-refactor
Use bitnami common template helpers
2 parents 6a9c099 + c1e4918 commit b923f2b

File tree

11 files changed

+550
-301
lines changed

11 files changed

+550
-301
lines changed

charts/jupyter/Chart.yaml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
name: "jupyter"
2-
version: "0.1.6"
3-
description: "Helm for jupyter single server with pyspark support"
1+
annotations:
2+
category: bigdata
3+
apiVersion: v2
4+
appVersion: 6.0.3
5+
dependencies:
6+
- name: common
7+
repository: https://charts.bitnami.com/bitnami
8+
tags:
9+
- bitnami-common
10+
version: 1.x.x
11+
description: Helm for jupyter single server with pyspark support
12+
engine: gotpl
13+
home: "https://jupyter.org"
14+
icon: https://jupyter.org/assets/main-logo.svg
415
keywords:
5-
- jupyter
16+
- juypter
617
- notebook
718
- spark
8-
home: "https://jupyter.org"
9-
icon: https://jupyter.org/assets/main-logo.svg
19+
maintainers:
20+
21+
name: cgiraldo
22+
name: jupyter
1023
sources:
11-
- "https://github.com/gradiant/charts"
24+
- https://github.com/gradiant/charts
1225
- "https://github.com/astrobounce/helm-jupyter"
13-
maintainers:
14-
- name: "cgiraldo"
15-
16-
apiVersion: v1
17-
appVersion: "6.0.3"
26+
version: 0.1.7
27+

charts/jupyter/README.md

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
set -x
3+
cd /home/jovyan
4+
{{- if .Values.gitNotebooks.secretName }}
5+
cp -r /tmp/.ssh /root/
6+
chmod 600 /root/.ssh/*
7+
{{- else }}
8+
mkdir /root/.ssh
9+
{{- end }}
10+
echo "Loading notebooks from git repo"
11+
{{- range .Values.gitNotebooks.repos }}
12+
if [ ! -d "/home/jovyan/{{ .name }}" ]
13+
then
14+
echo "Cloning {{ .name }} notebook repository"
15+
{{- if or (hasPrefix "git" .repo) (hasPrefix "ssh" .repo) }}
16+
ssh-keyscan {{ .repo | regexFind "@([a-zA-Z0-9.]*)" | replace "@" "" }} >> ~/.ssh/known_hosts
17+
{{- end }}
18+
git clone {{ .repo }} {{ .name }}
19+
else
20+
echo "{{ .name }} notebook repository already cloned"
21+
fi
22+
{{- end }}
23+
# exit code 0 to continue deployment even if git clone fails
24+
exit 0

charts/jupyter/templates/NOTES.txt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
1. Get access token from jupyter server log:
2-
kubectl logs -f -n {{ .Release.Namespace }} svc/{{ include "jupyter.fullname" . }}
2+
kubectl logs -f -n {{ .Release.Namespace }} svc/{{ include "common.names.fullname" . }}
33

44
1. Create a port-forward to the jupyter:
5-
kubectl port-forward -n {{ .Release.Namespace }} svc/{{ include "jupyter.fullname" . }} 8888:{{ .Values.service.externalPort }}
5+
kubectl port-forward -n {{ .Release.Namespace }} svc/{{ include "common.names.fullname" . }} 8888:{{ .Values.service.port }}
66

77
Then open the ui in your browser and use the access token:
8-
open http://localhost:88888
8+
open http://localhost:8888
99

1010
If you set up your own password, remember to restart jupyter server to update the configuration.
11-
File -> Shut Down
11+
File -> Shut Down
1212

1313
{{- if .Values.ingress.enabled }}
1414
Ingress is enabled:
15-
{{- range .Values.ingress.tls }}
16-
{{- range .hosts }}
17-
open https://{{ . }}
18-
{{- end }}
19-
{{- end }}
20-
{{- range .Values.ingress.hosts }}
21-
open http://{{ . }}
15+
{{- if .Values.ingress.tls }}
16+
open https://{{ .Values.ingress.hostname }}
17+
{{- else }}
18+
open http://{{ .Values.ingress.hostname }}
2219
{{- end }}
2320
{{- end }}
Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,14 @@
1-
{{/* vim: set filetype=mustache: */}}
2-
{{/*
3-
Expand the name of the chart.
4-
*/}}
5-
{{- define "jupyter.name" -}}
6-
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7-
{{- end -}}
81

92
{{/*
10-
Create a default fully qualified app name.
11-
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
3+
Return the proper jupyter image name
124
*/}}
13-
{{- define "jupyter.fullname" -}}
14-
{{- if .Values.fullnameOverride -}}
15-
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
16-
{{- else -}}
17-
{{- $name := default .Chart.Name .Values.nameOverride -}}
18-
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
19-
{{- end -}}
5+
{{- define "jupyter.image" -}}
6+
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
207
{{- end -}}
218

229
{{/*
23-
Standard Labels from Helm documentation https://helm.sh/docs/chart_best_practices/#labels-and-annotations
10+
Return the proper Docker Image Registry Secret Names
2411
*/}}
25-
26-
{{- define "jupyter.labels" -}}
27-
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
28-
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
29-
app.kubernetes.io/instance: {{ .Release.Name | quote }}
30-
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
31-
app.kubernetes.io/part-of: {{ .Chart.Name }}
12+
{{- define "jupyter.imagePullSecrets" -}}
13+
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image) "global" .Values.global) -}}
3214
{{- end -}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ include "common.names.fullname" . }}-git
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
{{- if .Values.commonLabels }}
9+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
10+
{{- end }}
11+
{{- if .Values.commonAnnotations }}
12+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
13+
{{- end }}
14+
data:
15+
git-notebooks.sh: |
16+
{{ tpl (.Files.Get "resources/git-notebooks.sh") . | indent 4 }}

charts/jupyter/templates/git-notebooks-configmap.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,63 @@
1-
{{- if .Values.ingress.enabled -}}
2-
{{- $fullName := include "jupyter.fullname" . -}}
3-
{{- $ingressPath := .Values.ingress.path -}}
4-
apiVersion: extensions/v1beta1
1+
2+
{{- if .Values.ingress.enabled }}
3+
apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }}
54
kind: Ingress
65
metadata:
7-
name: {{ $fullName }}
8-
labels:
9-
app.kubernetes.io/name: {{ include "jupyter.name" . }}
10-
{{- include "jupyter.labels" . | nindent 4 }}
11-
{{- if .Values.ingress.labels }}
12-
{{ toYaml .Values.ingress.labels | indent 4 }}
13-
{{- end }}
14-
{{- with .Values.ingress.annotations }}
6+
name: {{ include "common.names.fullname" . }}
7+
namespace: {{ .Release.Namespace | quote }}
8+
labels: {{- include "common.labels.standard" . | nindent 4 }}
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
{{- if or .Values.ingress.annotations .Values.commonAnnotations .Values.ingress.certManager }}
1513
annotations:
16-
{{ toYaml . | indent 4 }}
17-
{{- end }}
14+
{{- if .Values.ingress.certManager }}
15+
kubernetes.io/tls-acme: "true"
16+
{{- end }}
17+
{{- if .Values.ingress.annotations }}
18+
{{- include "common.tplvalues.render" ( dict "value" .Values.ingress.annotations "context" $) | nindent 4 }}
19+
{{- end }}
20+
{{- if .Values.commonAnnotations }}
21+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
22+
{{- end }}
23+
{{- end }}
1824
spec:
19-
{{- if .Values.ingress.tls }}
20-
tls:
21-
{{- range .Values.ingress.tls }}
22-
- hosts:
23-
{{- range .hosts }}
24-
- {{ . }}
25-
{{- end }}
26-
secretName: {{ .secretName }}
25+
{{- if .Values.ingress.ingressClassName }}
26+
ingressClassName: {{ .Values.ingress.ingressClassName | quote }}
2727
{{- end }}
28-
{{- end }}
2928
rules:
30-
{{- range .Values.ingress.hosts }}
31-
- host: {{ . }}
29+
{{- if .Values.ingress.hostname }}
30+
- host: {{ .Values.ingress.hostname }}
3231
http:
3332
paths:
34-
- path: {{ $ingressPath }}
35-
backend:
36-
serviceName: {{ $fullName }}
37-
servicePort: web
33+
{{- if .Values.ingress.extraPaths }}
34+
{{- toYaml .Values.ingress.extraPaths | nindent 10 }}
35+
{{- end }}
36+
- path: {{ .Values.ingress.path }}
37+
{{- if eq "true" (include "common.ingress.supportsPathType" .) }}
38+
pathType: {{ .Values.ingress.pathType }}
39+
{{- end }}
40+
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" .) "servicePort" "http" "context" $) | nindent 14 }}
41+
{{- end }}
42+
{{- range .Values.ingress.extraHosts }}
43+
- host: {{ .name | quote }}
44+
http:
45+
paths:
46+
- path: {{ default "/" .path }}
47+
{{- if eq "true" (include "common.ingress.supportsPathType" $) }}
48+
pathType: {{ default "ImplementationSpecific" .pathType }}
49+
{{- end }}
50+
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" $) "servicePort" "http" "context" $) | nindent 14 }}
51+
{{- end }}
52+
{{- if or (and .Values.ingress.tls (or .Values.ingress.certManager .Values.ingress.selfSigned)) .Values.ingress.extraTls }}
53+
tls:
54+
{{- if and .Values.ingress.tls (or .Values.ingress.certManager .Values.ingress.selfSigned) }}
55+
- hosts:
56+
- {{ .Values.ingress.hostname | quote }}
57+
secretName: {{ printf "%s-tls" .Values.ingress.hostname }}
58+
{{- end }}
59+
{{- if .Values.ingress.extraTls }}
60+
{{- include "common.tplvalues.render" (dict "value" .Values.ingress.extraTls "context" $) | nindent 4 }}
61+
{{- end }}
3862
{{- end }}
3963
{{- end }}
Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
1+
12
apiVersion: v1
23
kind: Service
34
metadata:
4-
name: {{ include "jupyter.fullname" . }}
5-
labels:
6-
app.kubernetes.io/name: {{ include "jupyter.name" . }}
7-
{{- include "jupyter.labels" . | nindent 4 }}
5+
name: {{ include "common.names.fullname" . }}
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels: {{- include "common.labels.standard" . | nindent 4 }}
8+
{{- if .Values.commonLabels }}
9+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
10+
{{- end }}
11+
{{- if .Values.commonAnnotations }}
12+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
13+
{{- end }}
814
spec:
915
type: {{ .Values.service.type }}
10-
selector:
11-
app.kubernetes.io/name: {{ include "jupyter.name" . }}
12-
app.kubernetes.io/instance: {{ .Release.Name }}
16+
sessionAffinity: {{ default "None" .Values.service.sessionAffinity }}
17+
{{- if and .Values.service.clusterIP (eq .Values.service.type "ClusterIP") }}
18+
clusterIP: {{ .Values.service.clusterIP }}
19+
{{- end }}
20+
{{- if and .Values.service.loadBalancerIP (eq .Values.service.type "LoadBalancer") }}
21+
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
22+
{{- end }}
23+
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges }}
24+
loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
25+
{{- end }}
26+
{{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
27+
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
28+
{{- end }}
1329
ports:
14-
- name: web
15-
protocol: TCP
16-
port: {{ .Values.service.externalPort | default 8888 }}
17-
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort.http))) }}
18-
nodePort: {{ .Values.service.nodePort.http }}
30+
- name: http
31+
port: {{ .Values.service.port }}
32+
targetPort: http
33+
{{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.http)) }}
34+
nodePort: {{ .Values.service.nodePorts.http }}
35+
{{- else if eq .Values.service.type "ClusterIP" }}
36+
nodePort: null
1937
{{- end }}
20-
targetPort: 8888
38+
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)