Skip to content

Commit c896b14

Browse files
authored
helm chart (#905)
helm chart
2 parents 0f92dc5 + edefe33 commit c896b14

File tree

15 files changed

+492
-0
lines changed

15 files changed

+492
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ notebook-*
2020
MANIFEST
2121
package-lock.json
2222
.vscode/
23+
*.tgz

helm-chart/minikube.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
replicaCount: 1
17+
pdbMinAvailable: 0

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: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "nbviewer.fullname" . }}
5+
labels:
6+
component: nbviewer
7+
{{- include "nbviewer.labels" . | nindent 4 }}
8+
spec:
9+
replicas: {{ .Values.replicas }}
10+
selector:
11+
matchLabels:
12+
component: nbviewer
13+
{{- include "nbviewer.matchLabels" . | nindent 6 }}
14+
{{- if .Values.deploymentStrategy }}
15+
strategy:
16+
{{- .Values.deploymentStrategy | toYaml | trimSuffix "\n" | nindent 4 }}
17+
{{- end }}
18+
template:
19+
metadata:
20+
labels:
21+
component: nbviewer
22+
{{- include "nbviewer.matchLabels" . | nindent 8 }}
23+
annotations:
24+
# This lets us autorestart when the secret changes!
25+
checksum/secret: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum }}
26+
{{- if .Values.annotations }}
27+
{{- .Values.annotations | toYaml | trimSuffix "\n" | nindent 8 }}
28+
{{- end }}
29+
spec:
30+
nodeSelector: {{ toJson .Values.nodeSelector }}
31+
volumes:
32+
- name: secret
33+
secret:
34+
secretName: {{ template "nbviewer.fullname" . }}
35+
items:
36+
- key: newrelic-ini
37+
path: newrelic.ini
38+
{{- if .Values.extraVolumes }}
39+
{{- .Values.extraVolumes | toYaml | trimSuffix "\n" | nindent 8 }}
40+
{{- end }}
41+
{{- if .Values.initContainers }}
42+
initContainers:
43+
{{- .Values.initContainers | toYaml | trimSuffix "\n" | nindent 8 }}
44+
{{- end }}
45+
containers:
46+
{{- if .Values.extraContainers }}
47+
{{- .Values.extraContainers | toYaml | trimSuffix "\n" | nindent 8 }}
48+
{{- end }}
49+
- name: nbviewer
50+
image: {{ .Values.image }}
51+
command:
52+
{{- if .Values.nbviewer.newrelicIni }}
53+
- newrelic-admin
54+
- run-python
55+
{{- else }}
56+
- python3
57+
{{- end }}
58+
- "-m"
59+
- nbviewer
60+
- --port=5000
61+
{{- if .Values.nbviewer.extraArgs }}
62+
{{- .Values.nbviewer.extraArgs | toYaml | trimSuffix "\n" | nindent 12 }}
63+
{{- end }}
64+
65+
volumeMounts:
66+
{{- if .Values.nbviewer.newrelicIni }}
67+
- mountPath: /etc/nbviewer/newrelic.ini
68+
name: secret
69+
subPath: newrelic.ini
70+
{{- end }}
71+
72+
# - mountPath: /etc/nbviewer/values.json
73+
# subPath: values.json
74+
# name: values
75+
76+
{{- if .Values.extraVolumeMounts }}
77+
{{- .Values.extraVolumeMounts | toYaml | trimSuffix "\n" | nindent 12 }}
78+
{{- end }}
79+
resources:
80+
{{- .Values.resources | toYaml | trimSuffix "\n" | nindent 12 }}
81+
{{- with .Values.imagePullPolicy }}
82+
imagePullPolicy: {{ . }}
83+
{{- end }}
84+
env:
85+
- name: PYTHONUNBUFFERED
86+
value: "1"
87+
- name: HELM_RELEASE_NAME
88+
value: {{ .Release.Name | quote }}
89+
- name: POD_NAMESPACE
90+
valueFrom:
91+
fieldRef:
92+
fieldPath: metadata.namespace
93+
{{- if .Values.github.clientId }}
94+
- name: GITHUB_OAUTH_KEY
95+
valueFrom:
96+
secretKeyRef:
97+
name: {{ template "nbviewer.fullname" . }}
98+
key: github-clientId
99+
{{- end }}
100+
{{- if .Values.github.clientSecret }}
101+
- name: GITHUB_OAUTH_SECRET
102+
valueFrom:
103+
secretKeyRef:
104+
name: {{ template "nbviewer.fullname" . }}
105+
key: github-clientSecret
106+
{{- end }}
107+
{{- if .Values.github.accessToken }}
108+
- name: GITHUB_API_TOKEN
109+
valueFrom:
110+
secretKeyRef:
111+
name: {{ template "nbviewer.fullname" . }}
112+
key: github-accessToken
113+
{{- end }}
114+
- name: MEMCACHIER_SERVERS
115+
value: {{ .Release.Name }}-memcached:11211
116+
- name: NEW_RELIC_CONFIG_FILE
117+
value: /etc/nbviewer/newrelic.ini
118+
{{- if .Values.extraEnv }}
119+
{{- range $key, $value := .Values.extraEnv }}
120+
- name: {{ $key | quote }}
121+
value: {{ $value | quote }}
122+
{{- end }}
123+
{{- end }}
124+
ports:
125+
- containerPort: 5000
126+
name: nbviewer
127+
{{- if .Values.livenessProbe.enabled }}
128+
# livenessProbe notes:
129+
# We don't know how long hub database upgrades could take
130+
# so having a liveness probe could be a bit risky unless we put
131+
# a initialDelaySeconds value with long enough margin for that
132+
# to not be an issue. If it is too short, we could end up aborting
133+
# database upgrades midway or ending up in an infinite restart
134+
# loop.
135+
livenessProbe:
136+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
137+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
138+
httpGet:
139+
path: {{ .Values.nbviewer.baseUrl | trimSuffix "/" | quote }}
140+
port: nbviewer
141+
{{- end }}
142+
{{- if .Values.readinessProbe.enabled }}
143+
readinessProbe:
144+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
145+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
146+
httpGet:
147+
path: {{ .Values.nbviewer.baseUrl | trimSuffix "/" | quote }}
148+
port: nbviewer
149+
{{- 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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
kind: Secret
2+
apiVersion: v1
3+
metadata:
4+
name: {{ template "nbviewer.fullname" . }}
5+
labels:
6+
{{- include "nbviewer.labels" . | nindent 4 }}
7+
type: Opaque
8+
data:
9+
github-accessToken: {{ .Values.github.accessToken | b64enc | quote }}
10+
github-clientId: {{ .Values.github.clientId | b64enc | quote }}
11+
github-clientSecret: {{ .Values.github.clientSecret | b64enc | quote }}
12+
statuspage-apiKey: {{ .Values.statuspage.apiKey | b64enc | quote }}
13+
newrelic-ini: {{ .Values.nbviewer.newrelicIni | b64enc | quote }}
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 }}

0 commit comments

Comments
 (0)