Skip to content

Commit

Permalink
Separate charts [BREAKING CHANGE TO HELM CHARTS] (#220)
Browse files Browse the repository at this point in the history
Split the model catalog in `charts/kubeai/` into its own chart
(`charts/models/`). Move CRDs to `templates/` to allow users to `helm
upgrade` CRDs.

Fixes #213

---------

Co-authored-by: Sam Stoelinga <[email protected]>
  • Loading branch information
nstogner and samos123 authored Sep 19, 2024
1 parent a50468e commit 280ab8d
Show file tree
Hide file tree
Showing 30 changed files with 292 additions and 191 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ go.work
*~

# Files that might be committed from running guides
/kubeai.yaml
/kubeai-models.yaml
/helm-values.yaml
/model-helm-values.yaml
Chart.lock

# Ignore python virtual env
Expand Down
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ help: ## Display this help.
##@ Development

.PHONY: manifests
manifests: controller-gen ## Generate CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd webhook paths="./..." output:crd:artifacts:config=charts/kubeai/charts/crds/crds
manifests: controller-gen yq
# Generate CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd webhook paths="./..." output:crd:artifacts:config=charts/kubeai/templates/crds/

# Generate model manifests.
rm -f ./manifests/models/*
helm template ./charts/models --set all.enabled=true | \
$(YQ) -s '"./manifests/models/" + .metadata.name + ".yaml"' --no-doc

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down Expand Up @@ -135,12 +141,14 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
CRD_REF_DOCS ?= $(LOCALBIN)/crd-ref-docs
YQ ?= $(LOCALBIN)/yq

## Tool Versions
KUSTOMIZE_VERSION ?= v5.4.2
CONTROLLER_TOOLS_VERSION ?= v0.15.0
ENVTEST_VERSION ?= release-0.18
GOLANGCI_LINT_VERSION ?= v1.59.1
YQ_VERSION ?= v4.44.3

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand All @@ -162,6 +170,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

.PHONY: yq
yq: $(YQ) ## Download yq locally if necessary.
$(YQ): $(LOCALBIN)
$(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4,$(YQ_VERSION))

.PHONY: docs
docs: generate-kubernetes-api-reference
cd ./docs && \
Expand Down
14 changes: 1 addition & 13 deletions charts/kubeai/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@ dependencies:
- name: openwebui
condition: openwebui.enabled
version: 0.1.1
# Custom Resource Definitions are cluster scoped. Sometimes cluster admins need to install
# these resources as a separate step.
# https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/
- name: crds
condition: crds.enabled
version: 0.1.1
# Models are the machine learning models that kubeai will serve.
# These are instances of the Model custom resource.
- name: models
condition: models.enabled
version: 0.1.1


keywords: ["LLM", "AI"]

Expand All @@ -41,7 +29,7 @@ home: https://www.substratus.ai

maintainers:
- name: nstogner
email: nicholas.stogner@gmail.com
url: https://www.linkedin.com/in/nstogner/
- name: samos123
email: [email protected]
url: https://www.linkedin.com/in/samstoelinga/
24 changes: 0 additions & 24 deletions charts/kubeai/charts/crds/Chart.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions charts/kubeai/charts/models/.helmignore

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ version: 0.1.1
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"

maintainers:
- name: nstogner
url: https://www.linkedin.com/in/nstogner/
- name: samos123
email: [email protected]
url: https://www.linkedin.com/in/samstoelinga/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- range $name, $model := .Values.catalog}}
{{- if $model.enabled}}
{{- if or $model.enabled $.Values.all.enabled }}
---
apiVersion: kubeai.org/v1
kind: Model
Expand All @@ -14,11 +14,11 @@ spec:
{{- end }}
{{- with $model.args }}
args:
{{ . | toYaml | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $model.env }}
env:
{{ . | toYaml | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $model.minReplicas }}
minReplicas: {{ . }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
all:
# Enable all models instead of enabling them one-by-one via .catalog.<name>.enabled
enabled: false

catalog:
# Mistral #
e5-mistral-7b-instruct-cpu:
Expand Down Expand Up @@ -79,4 +83,3 @@ catalog:
url: "hf://Systran/faster-whisper-medium.en"
engine: FasterWhisper
resourceProfile: cpu:1

30 changes: 17 additions & 13 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,25 @@ helm repo update
Install KubeAI and wait for all components to be ready (may take a minute).

```bash
cat <<EOF > helm-values.yaml
models:
catalog:
gemma2-2b-cpu:
enabled: true
minReplicas: 1
qwen2-500m-cpu:
enabled: true
nomic-embed-text-cpu:
enabled: true
helm install kubeai kubeai/kubeai --wait --timeout 10m
```

Install some predefined models.

```bash
cat <<EOF > kubeai-models.yaml
catalog:
gemma2-2b-cpu:
enabled: true
minReplicas: 1
qwen2-500m-cpu:
enabled: true
nomic-embed-text-cpu:
enabled: true
EOF

helm upgrade --install kubeai kubeai/kubeai \
-f ./helm-values.yaml \
--wait --timeout 10m
helm install kubeai-models kubeai/models \
-f ./kubeai-models.yaml
```

Before progressing to the next steps, start a watch on Pods in a standalone terminal to see how KubeAI deploys models.
Expand Down
25 changes: 12 additions & 13 deletions docs/how-to/configure-autoscaling.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This guide with cover how to configure KubeAI [autoscaling](../concepts/autoscal

## System Settings

KubeAI administrators can define system-wide autoscaling settings by setting the following helm values:
KubeAI administrators can define system-wide autoscaling settings by setting the following Helm values (for the `kubeai/kubeai` chart):

Example:

Expand All @@ -24,21 +24,20 @@ The following settings can be configured on a model-by-model basis.

### Model settings: helm

If you are managing models via Helm, you can use:
If you are managing models via the `kubeai/models` Helm chart, you can use:

```yaml
# helm-values.yaml
models:
catalog:
model-a:
# ...
minReplicas: 1
maxReplicas: 9
targetRequests: 250
scaleDownDelaySeconds: 45
model-b:
# ...
disableAutoscaling: true
catalog:
model-a:
# ...
minReplicas: 1
maxReplicas: 9
targetRequests: 250
scaleDownDelaySeconds: 45
model-b:
# ...
disableAutoscaling: true
# ...
```

Expand Down
12 changes: 6 additions & 6 deletions docs/how-to/configure-speech-to-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ KubeAI provides a Speech to Text endpoint that can be used to transcribe audio f
You can create new models by creating a Model CRD object or by enabling a model from the model catalog.

### Enable from model catalog
KubeAI provides predefined models in the model catalog. To enable the Speech to Text model, you can set the `enabled` flag to `true` in the `helm-values.yaml` file.
KubeAI provides predefined models in the `kubeai/models` Helm chart. To enable the Speech to Text model, you can set the `enabled` flag to `true` in your values file.

```yaml
models:
catalog:
faster-whisper-medium-en-cpu:
enabled: true
minReplicas: 1
# models-helm-values.yaml
catalog:
faster-whisper-medium-en-cpu:
enabled: true
minReplicas: 1
```
### Enable by creating Model CRD
Expand Down
37 changes: 18 additions & 19 deletions docs/how-to/install-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,42 @@ This guide provides instructions on how to configure KubeAI models.

## Installing models with helm

KubeAI provides a [chart](https://github.com/substratusai/kubeai/blob/main/charts/models) that contains preconfigured models.

### Preconfigured models with helm

When you are defining KubeAI Helm values, you can install a preconfigured Model by setting `enabled: true`. You can view a list of all preconfigured models [here](https://github.com/substratusai/kubeai/blob/main/charts/kubeai/charts/models/values.yaml). NOTE: When you are installing the KubeAI chart, the catalog is accessed under `.models.catalog.<model-name>`:
When you are defining Helm values for the `kubeai/models` chart you can install a preconfigured Model by setting `enabled: true`. You can view a list of all preconfigured models in the chart's [default values file](https://github.com/substratusai/kubeai/blob/main/charts/models/values.yaml).

```yaml
# helm-values.yaml
models:
catalog:
llama-3.1-8b-instruct-fp8-l4:
enabled: true
catalog:
llama-3.1-8b-instruct-fp8-l4:
enabled: true
```
You can optionally override preconfigured settings, for example, `resourceProfile`:

```yaml
# helm-values.yaml
models:
catalog:
llama-3.1-8b-instruct-fp8-l4:
enabled: true
resourceProfile: nvidia-gpu-l4:2 # Require "2 NVIDIA L4 GPUs"
catalog:
llama-3.1-8b-instruct-fp8-l4:
enabled: true
resourceProfile: nvidia-gpu-l4:2 # Require "2 NVIDIA L4 GPUs"
```

### Custom models with helm

If you prefer to add a custom model via the same Helm chart you use for installed KubeAI, you can add your custom model entry into the `.models.catalog` array of your existing Helm values file:
If you prefer to add a custom model via the same Helm chart you use for installed KubeAI, you can add your custom model entry into the `.catalog` array of your existing values file for the `kubeai/models` Helm chart:

```yaml
# helm-values.yaml
models:
catalog:
my-custom-model-name:
enabled: true
features: ["TextEmbedding"]
owner: me
url: "hf://me/my-custom-model"
resourceProfile: CPU:1
catalog:
my-custom-model-name:
enabled: true
features: ["TextEmbedding"]
owner: me
url: "hf://me/my-custom-model"
resourceProfile: CPU:1
```

## Installing models with kubectl
Expand Down
Loading

0 comments on commit 280ab8d

Please sign in to comment.