jupyterlab
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
{{/*
|
||||
Common resource name: uses Helm release name
|
||||
*/}}
|
||||
{{- define "jupyterlab.name" -}}
|
||||
{{- .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
ConfigMap name: <release-name>-scripts
|
||||
*/}}
|
||||
{{- define "jupyterlab.configMapName" -}}
|
||||
{{- printf "%s-scripts" .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Home volume PVC name: pvc-<release-name>-home
|
||||
*/}}
|
||||
{{- define "jupyterlab.homePvcName" -}}
|
||||
{{- printf "pvc-%s-home" .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Data volume PVC name: pvc-<release-name>-data
|
||||
*/}}
|
||||
{{- define "jupyterlab.dataPvcName" -}}
|
||||
{{- printf "pvc-%s-data" .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Resolved home directory path (mountPath or default /home/jovyan)
|
||||
*/}}
|
||||
{{- define "jupyterlab.homeDir" -}}
|
||||
{{- .Values.homeVolume.mountPath | default "/home/jovyan" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Resolved data volume mount path: <homeDir>/<mountPath or "data">
|
||||
*/}}
|
||||
{{- define "jupyterlab.dataDir" -}}
|
||||
{{- $home := include "jupyterlab.homeDir" . }}
|
||||
{{- $sub := .Values.dataVolume.mountPath | default "data" }}
|
||||
{{- printf "%s/%s" $home $sub }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "jupyterlab.labels" -}}
|
||||
app: {{ include "jupyterlab.name" . }}
|
||||
app.kubernetes.io/name: jupyterlab
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Full image reference: [registry/]repository:tag
|
||||
*/}}
|
||||
{{- define "jupyterlab.image" -}}
|
||||
{{- if .Values.image.registry }}
|
||||
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository .Values.image.tag }}
|
||||
{{- else }}
|
||||
{{- printf "%s:%s" .Values.image.repository .Values.image.tag }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
JupyterLab startup command
|
||||
*/}}
|
||||
{{- define "jupyterlab.command" -}}
|
||||
{{- $token := .Values.jupyterConfig.token }}
|
||||
{{- $homeDir := include "jupyterlab.homeDir" . }}
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
start.sh jupyter lab \
|
||||
--core-mode \
|
||||
{{- if $token }}
|
||||
--ServerApp.password='sha256::{{ $token | sha256sum | trimSuffix " -" }}' \
|
||||
--ServerApp.token='' \
|
||||
{{- else }}
|
||||
--ServerApp.token='' \
|
||||
--ServerApp.password='' \
|
||||
{{- end }}
|
||||
--ServerApp.ip='0.0.0.0' \
|
||||
--ServerApp.allow_origin='*' \
|
||||
--IdentityProvider.cookie_options="max-age=28800" \
|
||||
--ServerApp.disable_check_xsrf=True \
|
||||
--ServerApp.quit_button=False \
|
||||
--ServerApp.allow_root=False \
|
||||
--ServerApp.terminals_enabled=True \
|
||||
--ServerApp.root_dir={{ $homeDir }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "jupyterlab.configMapName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "jupyterlab.labels" . | nindent 4 }}
|
||||
data:
|
||||
startup-script.sh: |
|
||||
#!/bin/bash
|
||||
apt-get update -y
|
||||
python -m pip install --upgrade pip
|
||||
@@ -0,0 +1,100 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "jupyterlab.name" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "jupyterlab.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ include "jupyterlab.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "jupyterlab.labels" . | nindent 8 }}
|
||||
spec:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
fsGroup: 100
|
||||
{{- if .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: jupyterlab
|
||||
image: {{ include "jupyterlab.image" . | quote }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
command:
|
||||
{{- include "jupyterlab.command" . | nindent 12 }}
|
||||
ports:
|
||||
- containerPort: 8888
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: NVIDIA_DRIVER_CAPABILITIES
|
||||
value: "compute,utility"
|
||||
resources:
|
||||
limits:
|
||||
cpu: {{ .Values.resources.limits.cpu | quote }}
|
||||
memory: {{ .Values.resources.limits.memory | quote }}
|
||||
{{- if .Values.resources.gpu }}
|
||||
nvidia.com/gpu: {{ .Values.resources.gpu | quote }}
|
||||
{{- end }}
|
||||
requests:
|
||||
cpu: {{ .Values.resources.requests.cpu | quote }}
|
||||
memory: {{ .Values.resources.requests.memory | quote }}
|
||||
{{- if .Values.resources.gpu }}
|
||||
nvidia.com/gpu: {{ .Values.resources.gpu | quote }}
|
||||
{{- end }}
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: 8888
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
failureThreshold: 27
|
||||
volumeMounts:
|
||||
- name: localtime
|
||||
mountPath: /etc/localtime
|
||||
readOnly: true
|
||||
- name: startup-script
|
||||
mountPath: /usr/local/bin/start-notebook.d/startup-script.sh
|
||||
subPath: startup-script.sh
|
||||
{{- if .Values.homeVolume.enabled }}
|
||||
- name: home-volume
|
||||
mountPath: {{ include "jupyterlab.homeDir" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.dataVolume.enabled }}
|
||||
- name: data-volume
|
||||
mountPath: {{ include "jupyterlab.dataDir" . }}
|
||||
{{- end }}
|
||||
{{- range .Values.groupVolumes }}
|
||||
- name: gv-{{ .claimName }}
|
||||
mountPath: {{ .mountPath }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: localtime
|
||||
hostPath:
|
||||
path: /usr/share/zoneinfo/Asia/Seoul
|
||||
- name: startup-script
|
||||
configMap:
|
||||
name: {{ include "jupyterlab.configMapName" . }}
|
||||
defaultMode: 0755
|
||||
{{- if .Values.homeVolume.enabled }}
|
||||
- name: home-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "jupyterlab.homePvcName" . }}
|
||||
{{- end }}
|
||||
{{- if .Values.dataVolume.enabled }}
|
||||
- name: data-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "jupyterlab.dataPvcName" . }}
|
||||
{{- end }}
|
||||
{{- range .Values.groupVolumes }}
|
||||
- name: gv-{{ .claimName }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ .claimName }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,42 @@
|
||||
{{- if .Values.ingress.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "jupyterlab.name" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "jupyterlab.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- range $k, $v := . }}
|
||||
{{ $k }}: {{ $v | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
ingressClassName: {{ .Values.ingress.ingressClassName }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ . }}
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ include "jupyterlab.name" $ }}
|
||||
port:
|
||||
number: 8888
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,43 @@
|
||||
{{- if .Values.homeVolume.enabled }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ include "jupyterlab.homePvcName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "jupyterlab.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
# Uncomment below to retain the PVC even after helm uninstall.
|
||||
# helm.sh/resource-policy: keep
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.homeVolume.accessMode }}
|
||||
{{- if .Values.homeVolume.storageClassName }}
|
||||
storageClassName: {{ .Values.homeVolume.storageClassName }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.homeVolume.size }}
|
||||
---
|
||||
{{- end }}
|
||||
{{- if .Values.dataVolume.enabled }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ include "jupyterlab.dataPvcName" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "jupyterlab.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
# Uncomment below to retain the PVC even after helm uninstall.
|
||||
# helm.sh/resource-policy: keep
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.dataVolume.accessMode }}
|
||||
{{- if .Values.dataVolume.storageClassName }}
|
||||
storageClassName: {{ .Values.dataVolume.storageClassName }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.dataVolume.size }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "jupyterlab.name" . }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "jupyterlab.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: {{ include "jupyterlab.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
ports:
|
||||
- name: http
|
||||
port: 8888
|
||||
targetPort: 8888
|
||||
protocol: TCP
|
||||
Reference in New Issue
Block a user