From 27786d827d02f01485e61d7cbd6f448ef1a86ecc Mon Sep 17 00:00:00 2001 From: bjwswang Date: Tue, 25 Jul 2023 19:05:53 +0800 Subject: [PATCH 1/3] feat: add charts for jupyterlab Signed-off-by: bjwswang --- .github/workflows/release.yaml | 2 +- .kubebb_repo.yaml | 10 +++ charts/jupyterlab/.helmignore | 23 ++++++ charts/jupyterlab/Chart.yaml | 24 ++++++ charts/jupyterlab/README.md | 92 +++++++++++++++++++++ charts/jupyterlab/templates/NOTES.txt | 9 ++ charts/jupyterlab/templates/_helpers.tpl | 51 ++++++++++++ charts/jupyterlab/templates/deployment.yaml | 58 +++++++++++++ charts/jupyterlab/templates/ingress.yaml | 55 ++++++++++++ charts/jupyterlab/templates/service.yaml | 15 ++++ charts/jupyterlab/values.yaml | 61 ++++++++++++++ 11 files changed, 399 insertions(+), 1 deletion(-) create mode 100644 .kubebb_repo.yaml create mode 100644 charts/jupyterlab/.helmignore create mode 100644 charts/jupyterlab/Chart.yaml create mode 100644 charts/jupyterlab/README.md create mode 100644 charts/jupyterlab/templates/NOTES.txt create mode 100644 charts/jupyterlab/templates/_helpers.tpl create mode 100644 charts/jupyterlab/templates/deployment.yaml create mode 100644 charts/jupyterlab/templates/ingress.yaml create mode 100644 charts/jupyterlab/templates/service.yaml create mode 100644 charts/jupyterlab/values.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a24a226ec..46b62071a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,7 @@ jobs: uses: helm/chart-releaser-action@v1.5.0 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: diff --git a/.kubebb_repo.yaml b/.kubebb_repo.yaml new file mode 100644 index 000000000..2b98d5236 --- /dev/null +++ b/.kubebb_repo.yaml @@ -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 diff --git a/charts/jupyterlab/.helmignore b/charts/jupyterlab/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/charts/jupyterlab/.helmignore @@ -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/ diff --git a/charts/jupyterlab/Chart.yaml b/charts/jupyterlab/Chart.yaml new file mode 100644 index 000000000..681639681 --- /dev/null +++ b/charts/jupyterlab/Chart.yaml @@ -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" diff --git a/charts/jupyterlab/README.md b/charts/jupyterlab/README.md new file mode 100644 index 000000000..644e274c7 --- /dev/null +++ b/charts/jupyterlab/README.md @@ -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`)| diff --git a/charts/jupyterlab/templates/NOTES.txt b/charts/jupyterlab/templates/NOTES.txt new file mode 100644 index 000000000..ae6bbc71c --- /dev/null +++ b/charts/jupyterlab/templates/NOTES.txt @@ -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 }} diff --git a/charts/jupyterlab/templates/_helpers.tpl b/charts/jupyterlab/templates/_helpers.tpl new file mode 100644 index 000000000..db338dab1 --- /dev/null +++ b/charts/jupyterlab/templates/_helpers.tpl @@ -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 }} diff --git a/charts/jupyterlab/templates/deployment.yaml b/charts/jupyterlab/templates/deployment.yaml new file mode 100644 index 000000000..f670736a0 --- /dev/null +++ b/charts/jupyterlab/templates/deployment.yaml @@ -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 }} diff --git a/charts/jupyterlab/templates/ingress.yaml b/charts/jupyterlab/templates/ingress.yaml new file mode 100644 index 000000000..3394d39c0 --- /dev/null +++ b/charts/jupyterlab/templates/ingress.yaml @@ -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 }} diff --git a/charts/jupyterlab/templates/service.yaml b/charts/jupyterlab/templates/service.yaml new file mode 100644 index 000000000..298dc8a06 --- /dev/null +++ b/charts/jupyterlab/templates/service.yaml @@ -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 }} diff --git a/charts/jupyterlab/values.yaml b/charts/jupyterlab/values.yaml new file mode 100644 index 000000000..d3199f700 --- /dev/null +++ b/charts/jupyterlab/values.yaml @@ -0,0 +1,61 @@ +# Default values for jupyterlab. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" + +image: + repository: jupyter/minimal-notebook + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "lab-4.0.3" + +imagePullSecrets: [] + +ingress: + enabled: true + # portal-ingress is the default ingress provided by kubebb + className: "portal-ingress" + host: jupyterlab.172.190.30.163.nip.io + annotations: + {} + # kubernetes.io/ingress.class: portal-ingress + # kubernetes.io/tls-acme: "true" + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +podAnnotations: {} + +podSecurityContext: + {} + # fsGroup: 2000 + +securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +resources: + {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} From fa7caa373cab6174773a8fcccea9f0b1838d4344 Mon Sep 17 00:00:00 2001 From: bjwswang Date: Tue, 25 Jul 2023 19:37:07 +0800 Subject: [PATCH 2/3] fix: disable ingress by default;update kubeagi repo link Signed-off-by: bjwswang --- .kubebb_repo.yaml => .kubeagi_repo.yaml | 0 charts/jupyterlab/README.md | 4 ++-- charts/jupyterlab/values.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename .kubebb_repo.yaml => .kubeagi_repo.yaml (100%) diff --git a/.kubebb_repo.yaml b/.kubeagi_repo.yaml similarity index 100% rename from .kubebb_repo.yaml rename to .kubeagi_repo.yaml diff --git a/charts/jupyterlab/README.md b/charts/jupyterlab/README.md index 644e274c7..08724df7d 100644 --- a/charts/jupyterlab/README.md +++ b/charts/jupyterlab/README.md @@ -30,10 +30,10 @@ helm install [RELEASE_NAME] kubeagi/jupyterlab #### 1. Create a repository `kubeagi` into kubebb ```shell -kubectl apply -f https://raw.githubusercontent.com/kubebb/arcadia/master/.kubebb_repo.yaml +kubectl apply -f https://raw.githubusercontent.com/kubeagi/arcadia/main/.kubeagi_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. +> Note: If you want to create this repository in other namespace, you should update field `metadata.namespace` in `.kubeagi_repo.yaml` before apply. #### 2. Install Jupyterlab with `ComponentPlan` diff --git a/charts/jupyterlab/values.yaml b/charts/jupyterlab/values.yaml index d3199f700..1f16df464 100644 --- a/charts/jupyterlab/values.yaml +++ b/charts/jupyterlab/values.yaml @@ -13,10 +13,10 @@ image: imagePullSecrets: [] ingress: - enabled: true + enabled: false # portal-ingress is the default ingress provided by kubebb className: "portal-ingress" - host: jupyterlab.172.190.30.163.nip.io + host: jupyterlab.172.168.0.2.nip.io annotations: {} # kubernetes.io/ingress.class: portal-ingress From 6bf30c99e5c971303e951fc10380e2d6cca59c74 Mon Sep 17 00:00:00 2001 From: bjwswang Date: Tue, 25 Jul 2023 23:44:54 +0800 Subject: [PATCH 3/3] fix: rename charts repo url to arcadia Signed-off-by: bjwswang --- .github/workflows/release.yaml | 2 +- .kubeagi_repo.yaml | 2 +- charts/jupyterlab/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 46b62071a..a24a226ec 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,7 @@ jobs: uses: helm/chart-releaser-action@v1.5.0 with: charts_dir: charts - charts_repo_url: https://kubeagi.github.io/charts/ + charts_repo_url: https://kubeagi.github.io/arcadia/ # FIXME: uncomment this once customized configuration is needed # config: cr.yaml env: diff --git a/.kubeagi_repo.yaml b/.kubeagi_repo.yaml index 2b98d5236..55d91dc77 100644 --- a/.kubeagi_repo.yaml +++ b/.kubeagi_repo.yaml @@ -4,7 +4,7 @@ metadata: name: kubeagi namespace: kubebb-system spec: - url: https://kubeagi.github.io/charts + url: https://kubeagi.github.io/arcadia pullStategy: intervalSeconds: 120 retry: 5 diff --git a/charts/jupyterlab/README.md b/charts/jupyterlab/README.md index 08724df7d..19e28db7c 100644 --- a/charts/jupyterlab/README.md +++ b/charts/jupyterlab/README.md @@ -13,7 +13,7 @@ #### 1. Get Repo Info ```shell -helm repo add kubeagi https://kubeagi.github.io/charts +helm repo add kubeagi https://kubeagi.github.io/arcadia helm repo update ```