diff --git a/.gitignore b/.gitignore index 6ef5822c..f8e65abf 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,7 @@ cscope.* /bazel-* *.pyc + +# Helm chart dependecies cache +**/Chart.lock +**/charts/*.tgz \ No newline at end of file diff --git a/ai/ai-starter-kit/Makefile b/ai/ai-starter-kit/Makefile new file mode 100644 index 00000000..00f3e860 --- /dev/null +++ b/ai/ai-starter-kit/Makefile @@ -0,0 +1,17 @@ +lint: + helm lint helm-chart/ai-starter-kit + +dep_update: + helm dependency update helm-chart/ai-starter-kit + +install: + helm upgrade --install ai-starter-kit helm-chart/ai-starter-kit --timeout 10m + +start: + minikube start --cpus 4 --memory 8192 + +uninstall: + helm uninstall ai-starter-kit + +destroy: + minikube delete diff --git a/ai/ai-starter-kit/helm-chart/ai-starter-kit/.helmignore b/ai/ai-starter-kit/helm-chart/ai-starter-kit/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/ai/ai-starter-kit/helm-chart/ai-starter-kit/.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/ai/ai-starter-kit/helm-chart/ai-starter-kit/Chart.yaml b/ai/ai-starter-kit/helm-chart/ai-starter-kit/Chart.yaml new file mode 100644 index 00000000..bd83805b --- /dev/null +++ b/ai/ai-starter-kit/helm-chart/ai-starter-kit/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: ai-starter-kit +description: A Helm chart for Kubernetes + +# 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: "1.16.0" + + +dependencies: + - name: kuberay-operator + version: "1.3.0" + repository: "https://ray-project.github.io/kuberay-helm" + - name: ray-cluster + version: "1.3.0" + repository: "https://ray-project.github.io/kuberay-helm" + - name: jupyterhub + version: "9.0.16" + repository: "https://charts.bitnami.com/bitnami" + - name: mlflow + version: "4.0.4" + repository: "https://charts.bitnami.com/bitnami" diff --git a/ai/ai-starter-kit/helm-chart/ai-starter-kit/templates/NOTES.txt b/ai/ai-starter-kit/helm-chart/ai-starter-kit/templates/NOTES.txt new file mode 100644 index 00000000..4e33a20e --- /dev/null +++ b/ai/ai-starter-kit/helm-chart/ai-starter-kit/templates/NOTES.txt @@ -0,0 +1 @@ +AI Starter Kit installed. Enjoy \ No newline at end of file diff --git a/ai/ai-starter-kit/helm-chart/ai-starter-kit/templates/_helpers.tpl b/ai/ai-starter-kit/helm-chart/ai-starter-kit/templates/_helpers.tpl new file mode 100644 index 00000000..cf0c5e08 --- /dev/null +++ b/ai/ai-starter-kit/helm-chart/ai-starter-kit/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "ai-starter-kit.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 "ai-starter-kit.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 "ai-starter-kit.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ai-starter-kit.labels" -}} +helm.sh/chart: {{ include "ai-starter-kit.chart" . }} +{{ include "ai-starter-kit.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ai-starter-kit.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ai-starter-kit.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "ai-starter-kit.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "ai-starter-kit.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/ai/ai-starter-kit/helm-chart/ai-starter-kit/values.yaml b/ai/ai-starter-kit/helm-chart/ai-starter-kit/values.yaml new file mode 100644 index 00000000..3bba8a25 --- /dev/null +++ b/ai/ai-starter-kit/helm-chart/ai-starter-kit/values.yaml @@ -0,0 +1,40 @@ + +jupyterhub: + nameOverride: "jupyterhub" + postgresql: + nameOverride: "jupyterhub-postgresql" + enabled: true + auth: + password: "changeme" + + singleuser: + extraEnvVars: + RAY_ADDRESS: "{{ tpl .Release.Name $ }}-kuberay-head-svc:6379" + MLFLOW_TRACKING_URI: "http://{{ tpl .Release.Name $ }}-mlflow-tracking" + JUPYTERLAB_DIR: "/opt" + hub: + password: "sneakypass" + extraEnvVars: + - name: "RAY_ADDRESS" + value: "{{ tpl .Release.Name $ }}-kuberay-head-svc" + - name: "MLFLOW_TRACKING_URI" + value: "http://{{ tpl .Release.Name $ }}-mlflow-tracking" + +ray-cluster: + head: + serviceType: ClusterIP + resources: + limits: + memory: "8G" + +mlflow: + postgresql: + auth: + password: "changeme" + minio: + auth: + rootPassword: "somepassword" + tracking: + auth: + password: "changemeibegyou" + flaskServerSecretKey: "noneedtochangethisone" diff --git a/ai/ai-starter-kit/notebooks/test_ray.py b/ai/ai-starter-kit/notebooks/test_ray.py new file mode 100644 index 00000000..b04ef8cd --- /dev/null +++ b/ai/ai-starter-kit/notebooks/test_ray.py @@ -0,0 +1,12 @@ +!pip install ray +from ray.job_submission import JobSubmissionClient + +# If using a remote cluster, replace 127.0.0.1 with the head node's IP address or set up port forwarding. +client = JobSubmissionClient() +job_id = client.submit_job( + # Entrypoint shell command to execute + entrypoint="python script.py", + # Path to the local directory that contains the script.py file + runtime_env={"working_dir": "./","excludes": ["/.cache","/.local"]} +) +print(job_id) \ No newline at end of file