Skip to content

Commit

Permalink
feat: add charts for jupyterlab
Browse files Browse the repository at this point in the history
Signed-off-by: bjwswang <[email protected]>
  • Loading branch information
bjwswang committed Jul 25, 2023
1 parent 4031fa8 commit 27786d8
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: helm/[email protected]
with:
charts_dir: charts
charts_repo_url: https://kubeagi.github.io/arcadia/
charts_repo_url: https://kubeagi.github.io/charts/
# FIXME: uncomment this once customized configuration is needed
# config: cr.yaml
env:
Expand Down
10 changes: 10 additions & 0 deletions .kubebb_repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: Repository
metadata:
name: kubeagi
namespace: kubebb-system
spec:
url: https://kubeagi.github.io/charts
pullStategy:
intervalSeconds: 120
retry: 5
23 changes: 23 additions & 0 deletions charts/jupyterlab/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/jupyterlab/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: jupyterlab
description: A Helm chart for JupyterLab

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "4.0.3"
92 changes: 92 additions & 0 deletions charts/jupyterlab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Jupyterlab

[Jupyterlab](https://github.com/jupyterlab/jupyterlab) is a web-based interactive development environment for Jupyter notebooks, code, and data.

## Requirements

- Kubernetes

## Install Jupyterlab

### With Helm

#### 1. Get Repo Info

```shell
helm repo add kubeagi https://kubeagi.github.io/charts
helm repo update
```

#### 2. Install Jupyterlab

```shell
helm install [RELEASE_NAME] kubeagi/jupyterlab
```

**If you want to enable `ingress` for Jupyterlab, you should update field `ingress` in `values.yaml` before install.**

### With Kubebb Core

#### 1. Create a repository `kubeagi` into kubebb

```shell
kubectl apply -f https://raw.githubusercontent.com/kubebb/arcadia/master/.kubebb_repo.yaml
```

> Note: If you want to create this repository in other namespace, you should update field `metadata.namespace` in `.kubebb_repo.yaml` before apply.
#### 2. Install Jupyterlab with `ComponentPlan`

```shell
apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: ComponentPlan
metadata:
name: jupyterlab
namespace: default
spec:
approved: true
name: jupyterlab
version: 0.1.0
component:
name: kubeagi.jupyterlab
# If you have changed the namespace in step 1, you should update this field.
namespace: kubebb-system
```

If you want to enable `ingress` with the help of `u4a-component (IngressNodeIP is 172.18.0.2)`, you should update field `override` in `ComponentPlan` before install.For example:

```yaml
apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: ComponentPlan
metadata:
name: jupyterlab
namespace: default
spec:
approved: true
name: jupyterlab
version: 0.1.0
override:
set:
- ingress.enabled=true
# ingressNodeIP is `172.18.0.2`
- ingress.hosts[0].host=jupyterlab.172.18.0.2.nip.io
component:
name: kubeagi.jupyterlab
# If you have changed the namespace in step 1, you should update this field.
namespace: kubebb-system
```
## Configuration
The following table lists the important configurable parameters of the Jupyterlab chart and their default values.
| Parameter | Description | Default |
| --------- | ----------- | ------- |
| `nameOverride` | Override the name of the chart | `""` |
| `image.repository` | Image repository | `jupyter/tensorflow-notebook` |
| `image.tag` | Image tag | `lab-4.0.3` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `imagePullSecrets` | Image pull secrets to access image registry | `[]` |
| `ingress.enabled` | Enable ingress | `false` |
| `ingress.className` | Ingress class name | `"portal-ingress"` |
| `ingress.host` | Set Ingress host | `jupyterlab.172.18.0.2.nip.io` (Must update this to real ingress node ip if `ingress.enabled` is `true`)|
9 changes: 9 additions & 0 deletions charts/jupyterlab/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.host }}/
{{- else }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "jupyterlab.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
51 changes: 51 additions & 0 deletions charts/jupyterlab/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "jupyterlab.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "jupyterlab.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "jupyterlab.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "jupyterlab.labels" -}}
helm.sh/chart: {{ include "jupyterlab.chart" . }}
{{ include "jupyterlab.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "jupyterlab.selectorLabels" -}}
app.kubernetes.io/name: {{ include "jupyterlab.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
58 changes: 58 additions & 0 deletions charts/jupyterlab/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "jupyterlab.fullname" . }}
labels:
{{- include "jupyterlab.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "jupyterlab.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "jupyterlab.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8888
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
55 changes: 55 additions & 0 deletions charts/jupyterlab/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "jupyterlab.fullname" . -}}
{{- $svcPort := 8888 -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "jupyterlab.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/jupyterlab/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "jupyterlab.fullname" . }}
labels:
{{- include "jupyterlab.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 8888
targetPort: http
protocol: TCP
name: http
selector:
{{- include "jupyterlab.selectorLabels" . | nindent 4 }}
Loading

0 comments on commit 27786d8

Please sign in to comment.