Skip to content

Commit eba0bfe

Browse files
committed
create nbviewer helm chart
1 parent b2946f3 commit eba0bfe

File tree

10 files changed

+321
-0
lines changed

10 files changed

+321
-0
lines changed

helm-chart/minikube.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
service:
2+
type: NodePort
3+
ports:
4+
nodePort: 32567
5+
6+
resources:
7+
requests:
8+
memory: null
9+
cpu: null
10+
11+
nbviewer:
12+
extraArgs:
13+
- "--logging=debug"
14+
15+
memcached:
16+
replicas: 1

helm-chart/nbviewer/Chart.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
name: nbviewer
3+
version: 0.0.1
4+
appVersion: 1.0.1
5+
description: Jupyter Notebook Viewer
6+
home: https://nbviewer.jupyter.org
7+
sources:
8+
- https://github.com/jupyter/nbviewer
9+
kubeVersion: '>=1.11.0-0'
10+
tillerVersion: '>=2.11.0-0'

helm-chart/nbviewer/requirements.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: memcached
3+
repository: https://kubernetes-charts.storage.googleapis.com
4+
version: 3.2.2
5+
digest: sha256:b0f92f7e3f8bfeb286cf8566d86c9c795a2712d7c690bdf66eb037dbae7b9036
6+
generated: "2020-03-03T10:17:51.050357+01:00"

helm-chart/nbviewer/requirements.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies:
2+
- name: memcached
3+
version: 3.2.2
4+
repository: https://kubernetes-charts.storage.googleapis.com
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "nbviewer.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
6+
{{- end -}}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
*/}}
12+
{{- define "nbviewer.fullname" -}}
13+
{{- if .Values.fullnameOverride -}}
14+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
15+
{{- else -}}
16+
{{- $name := default .Chart.Name .Values.nameOverride -}}
17+
{{- if contains $name .Release.Name -}}
18+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
19+
{{- else -}}
20+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
21+
{{- end -}}
22+
{{- end -}}
23+
{{- end -}}
24+
25+
{{/*
26+
Common labels
27+
*/}}
28+
{{- define "nbviewer.labels" -}}
29+
app.kubernetes.io/name: {{ include "nbviewer.name" . }}
30+
helm.sh/chart: {{ include "nbviewer.chart" . }}
31+
app.kubernetes.io/instance: {{ .Release.Name }}
32+
{{- if .Chart.AppVersion }}
33+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
34+
{{- end }}
35+
app.kubernetes.io/managed-by: {{ .Release.Service }}
36+
{{- end -}}
37+
38+
{{- define "nbviewer.matchLabels" -}}
39+
app.kubernetes.io/name: {{ include "nbviewer.name" . }}
40+
app.kubernetes.io/instance: {{ .Release.Name }}
41+
{{- end -}}
42+
43+
{{/*
44+
Create chart name and version as used by the chart label.
45+
*/}}
46+
{{- define "nbviewer.chart" -}}
47+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
48+
{{- end -}}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "nbviewer.fullname" . }}
5+
labels:
6+
{{- include "nbviewer.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicas }}
9+
selector:
10+
matchLabels:
11+
{{- include "nbviewer.matchLabels" . | nindent 6 }}
12+
{{- if .Values.deploymentStrategy }}
13+
strategy:
14+
{{- .Values.deploymentStrategy | toYaml | trimSuffix "\n" | nindent 4 }}
15+
{{- end }}
16+
template:
17+
metadata:
18+
labels:
19+
{{- include "nbviewer.matchLabels" . | nindent 8 }}
20+
annotations:
21+
# This lets us autorestart when the secret changes!
22+
checksum/secret: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum }}
23+
{{- if .Values.annotations }}
24+
{{- .Values.annotations | toYaml | trimSuffix "\n" | nindent 8 }}
25+
{{- end }}
26+
spec:
27+
nodeSelector: {{ toJson .Values.nodeSelector }}
28+
volumes:
29+
- name: secret
30+
secret:
31+
secretName: {{ template "nbviewer.fullname" . }}-secret
32+
# - name: files
33+
# secret:
34+
# secretName: {{ template "nbviewer.fullname" . }}-secret
35+
{{- if .Values.extraVolumes }}
36+
{{- .Values.extraVolumes | toYaml | trimSuffix "\n" | nindent 8 }}
37+
{{- end }}
38+
{{- if .Values.initContainers }}
39+
initContainers:
40+
{{- .Values.initContainers | toYaml | trimSuffix "\n" | nindent 8 }}
41+
{{- end }}
42+
containers:
43+
{{- if .Values.extraContainers }}
44+
{{- .Values.extraContainers | toYaml | trimSuffix "\n" | nindent 8 }}
45+
{{- end }}
46+
- name: nbviewer
47+
image: {{ .Values.image }}
48+
command:
49+
- python3
50+
- "-m"
51+
- nbviewer
52+
- --port=5000
53+
{{- if .Values.nbviewer.extraArgs }}
54+
{{- .Values.nbviewer.extraArgs | toYaml | trimSuffix "\n" | nindent 12 }}
55+
{{- end }}
56+
57+
volumeMounts:
58+
# - mountPath: /srv/nbviewer
59+
# name: files
60+
61+
# - mountPath: /etc/nbviewer/values.json
62+
# subPath: values.json
63+
# name: values
64+
65+
{{- if .Values.extraVolumeMounts }}
66+
{{- .Values.extraVolumeMounts | toYaml | trimSuffix "\n" | nindent 12 }}
67+
{{- end }}
68+
resources:
69+
{{- .Values.resources | toYaml | trimSuffix "\n" | nindent 12 }}
70+
{{- with .Values.imagePullPolicy }}
71+
imagePullPolicy: {{ . }}
72+
{{- end }}
73+
env:
74+
- name: PYTHONUNBUFFERED
75+
value: "1"
76+
- name: HELM_RELEASE_NAME
77+
value: {{ .Release.Name | quote }}
78+
- name: POD_NAMESPACE
79+
valueFrom:
80+
fieldRef:
81+
fieldPath: metadata.namespace
82+
{{- if .Values.github.clientId }}
83+
- name: GITHUB_OAUTH_KEY
84+
valueFrom:
85+
secretKeyRef:
86+
name: {{ template "nbviewer.fullname" }}
87+
key: github.clientId
88+
{{- end }}
89+
{{- if .Values.github.clientSecret }}
90+
- name: GITHUB_OAUTH_SECRET
91+
valueFrom:
92+
secretKeyRef:
93+
name: {{ template "nbviewer.fullname" }}
94+
key: github.client-secret
95+
{{- end }}
96+
{{- if .Values.github.accessToken }}
97+
- name: GITHUB_API_TOKEN
98+
valueFrom:
99+
secretKeyRef:
100+
name: {{ template "nbviewer.fullname" }}
101+
key: github.accessToken
102+
{{- end }}
103+
- name: MEMCACHIER_SERVERS
104+
value: {{ .Release.Name }}-memcached:11211
105+
{{- if .Values.extraEnv }}
106+
{{- range $key, $value := .Values.extraEnv }}
107+
- name: {{ $key | quote }}
108+
value: {{ $value | quote }}
109+
{{- end }}
110+
{{- end }}
111+
ports:
112+
- containerPort: 5000
113+
name: nbviewer
114+
{{- if .Values.livenessProbe.enabled }}
115+
# livenessProbe notes:
116+
# We don't know how long hub database upgrades could take
117+
# so having a liveness probe could be a bit risky unless we put
118+
# a initialDelaySeconds value with long enough margin for that
119+
# to not be an issue. If it is too short, we could end up aborting
120+
# database upgrades midway or ending up in an infinite restart
121+
# loop.
122+
livenessProbe:
123+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
124+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
125+
httpGet:
126+
path: {{ .Values.nbviewer.baseUrl | trimSuffix "/" | quote }}
127+
port: nbviewer
128+
{{- end }}
129+
{{- if .Values.readinessProbe.enabled }}
130+
readinessProbe:
131+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
132+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
133+
httpGet:
134+
path: {{ .Values.nbviewer.baseUrl | trimSuffix "/" | quote }}
135+
port: nbviewer
136+
{{- end }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.pdb.enabled -}}
2+
apiVersion: policy/v1beta1
3+
kind: PodDisruptionBudget
4+
metadata:
5+
name: {{ template "nbviewer.fullname" . }}
6+
labels:
7+
{{- include "nbviewer.labels" . | nindent 4 }}
8+
spec:
9+
minAvailable: {{ .Values.pdb.minAvailable }}
10+
selector:
11+
matchLabels:
12+
{{- include "nbviewer.matchLabels" . | nindent 6 }}
13+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
kind: Secret
2+
apiVersion: v1
3+
metadata:
4+
name: {{ template "nbviewer.fullname" . }}-secret
5+
labels:
6+
{{- include "nbviewer.labels" . | nindent 4 }}
7+
type: Opaque
8+
data:
9+
github-accessToken: {{ .Values.github.accessToken }}
10+
github-clientId: {{ .Values.github.clientId }}
11+
github-clientSecret: {{ .Values.github.clientSecret }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ template "nbviewer.fullname" . }}
5+
labels:
6+
{{- include "nbviewer.labels" . | nindent 4 }}
7+
annotations:
8+
{{- if .Values.service.annotations }}
9+
{{- .Values.service.annotations | toYaml | nindent 4 }}
10+
{{- end }}
11+
spec:
12+
type: {{ .Values.service.type }}
13+
{{- if .Values.service.loadBalancerIP }}
14+
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
15+
{{- end }}
16+
selector:
17+
{{- include "nbviewer.matchLabels" . | nindent 4 }}
18+
ports:
19+
- protocol: TCP
20+
port: 80
21+
targetPort: 5000
22+
{{- if .Values.service.ports.nodePort }}
23+
nodePort: {{ .Values.service.ports.nodePort }}
24+
{{- end }}

helm-chart/nbviewer/values.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
image: "jupyter/nbviewer"
2+
imagePullPolicy: null
3+
4+
service: {}
5+
nodeSelector: null
6+
7+
replicas: 2
8+
9+
pdb:
10+
minAvailable: 1
11+
12+
resources:
13+
requests:
14+
memory: 256M
15+
cpu: "1"
16+
17+
annotations: {}
18+
19+
extraContainers: null
20+
extraVolumes: null
21+
22+
livenessProbe:
23+
enabled: true
24+
initialDelaySeconds: 5
25+
periodSeconds: 10
26+
27+
readinessProbe:
28+
enabled: true
29+
initialDelaySeconds: 5
30+
periodSeconds: 10
31+
32+
service:
33+
type: LoadBalancer
34+
ports:
35+
nodePort: null
36+
37+
github:
38+
accessToken: ""
39+
clientId: ""
40+
clientSecret: ""
41+
42+
nbviewer:
43+
baseUrl: "/"
44+
extraArgs: []
45+
46+
memcached:
47+
AntiAffinity: soft
48+
replicas: 2
49+
50+
updateStrategy:
51+
rollingUpdate:
52+
maxSurge: 1
53+
maxUnavailable: 1

0 commit comments

Comments
 (0)