ollama
by OTWLD
Get up and running with large language models locally.
About this chart
Ollama, get up and running with large language models, locally.
This Community Chart is for deploying Ollama.
Requirements
-
Kubernetes:
>= 1.16.0-0for CPU only -
Kubernetes:
>= 1.26.0-0for GPU stable support (NVIDIA and AMD)
Not all GPUs are currently supported with ollama (especially with AMD)
Deploying Ollama chart
To install the ollama chart in the ollama namespace:
[!IMPORTANT]
We are migrating the registry from https://otwld.github.io/ollama-helm/ url to OTWLD Helm central registry https://helm.otwld.com/ Please update your Helm registry accordingly.
helm repo add otwld https://helm.otwld.com/
helm repo update
helm install ollama otwld/ollama --namespace ollama --create-namespace
Upgrading Ollama chart
First please read the release notes of Ollama to make sure there are no backwards incompatible changes.
Make adjustments to your values as needed, then run helm upgrade:
# -- This pulls the latest version of the ollama chart from the repo.
helm repo update
helm upgrade ollama otwld/ollama --namespace ollama --values values.yaml
Uninstalling Ollama chart
To uninstall/delete the ollama deployment in the ollama namespace:
helm delete ollama --namespace ollama
Substitute your values if they differ from the examples. See helm delete --help for a full reference on delete
parameters and flags.
Interact with Ollama
- Ollama documentation can be found HERE
- Interact with RESTful API: Ollama API
- Interact with official clients libraries: ollama-js and ollama-python
- Interact with langchain: langchain-js and langchain-python
Examples
- It's highly recommended to run an updated version of Kubernetes for deploying ollama with GPU
Basic values.yaml example with GPU and two models pulled at startup
ollama:
gpu:
# -- Enable GPU integration
enabled: true
# -- GPU type: 'nvidia' or 'amd'
type: 'nvidia'
# -- Specify the number of GPU to 1
number: 1
# -- List of models to pull at container startup
models:
pull:
- mistral
- llama2
Basic values.yaml example with Ingress
ollama:
models:
pull:
- llama2
ingress:
enabled: true
hosts:
- host: ollama.domain.lan
paths:
- path: /
pathType: Prefix
- API is now reachable at
ollama.domain.lan
Create and run model from template
ollama:
models:
create:
- name: llama3.1-ctx32768
template: |
FROM llama3.1
PARAMETER num_ctx 32768
run:
- llama3.1-ctx32768
Upgrading from 0.X.X to 1.X.X
The version 1.X.X introduces the ability to load models in memory at startup, the values have been changed.
Please change ollama.models to ollama.models.pull to avoid errors before upgrading:
ollama:
models:
- mistral
- llama2
To:
ollama:
models:
pull:
- mistral
- llama2
Knative
When knative.enabled=true, this chart deploys a Knative Service instead of a standard Kubernetes Deployment and
Service.
Knative cluster requirements
If you want to mount a PVC in Knative mode, your Knative Serving cluster must enable these feature flags:
kubernetes.podspec-persistent-volume-claimkubernetes.podspec-persistent-volume-writekubernetes.podspec-tolerations
If these features are disabled, Knative will reject the rendered Service with webhook validation errors.
You can verify the current settings with:
kubectl get configmap/config-features -n knative-serving -o yaml
On a standard Knative Serving installation, you can enable them with:
kubectl patch configmap/config-features -n knative-serving --type merge --patch '{
"data": {
"kubernetes.podspec-persistent-volume-claim": "enabled",
"kubernetes.podspec-persistent-volume-write": "enabled",
"kubernetes.podspec-tolerations": "enabled"
}
}'
If your Knative installation is managed by the Knative Operator, configure these feature flags on the KnativeServing
resource instead of patching the ConfigMap directly.
Existing PVC example
To reuse an existing PVC in Knative mode:
knative:
enabled: true
persistentVolume:
enabled: true
existingClaim: ollama-pvc
Model bootstrap behavior
When knative.enabled=true and model bootstrap is configured with ollama.models.pull, ollama.models.run, or
ollama.models.create, the chart renders a separate bootstrap Job.
- The Job is non-blocking:
helm installandhelm upgradedo not wait for model preload to finish. - The Job name includes a hash of
ollama.models.pull,ollama.models.run,ollama.models.create, andollama.models.clean, so changing those settings on upgrade creates a new Job and reruns bootstrap. - Completed bootstrap Jobs are cleaned up according to
knative.modelBootstrap.ttlSecondsAfterFinished. - Knative bootstrap requires
persistentVolume.enabled=trueso the bootstrap Job and KnativeServicecan share the same model data.
Helm Values
- See values.yaml to see the Chart's default values.
| Key | Type | Default | Description |
|---|---|---|---|
| affinity | object | {} | Affinity for pod assignment |
| autoscaling.enabled | bool | false | Enable autoscaling |
| autoscaling.maxReplicas | int | 100 | Number of maximum replicas |
| autoscaling.minReplicas | int | 1 | Number of minimum replicas |
| autoscaling.targetCPUUtilizationPercentage | int | 80 | CPU usage to target replica |
| deployment.labels | object | {} | Labels to add to the deployment |
| extraArgs | list | [] | Additional arguments on the output Deployment definition. |
| extraEnv | list | [] | Additional environments variables on the output Deployment definition. For extra OLLAMA env, please refer to https://github.com/ollama/ollama/blob/main/envconfig/config.go |
| extraEnvFrom | list | [] | Additionl environment variables from external sources (like ConfigMap) |
| extraObjects | list | [] | Extra K8s manifests to deploy |
| fullnameOverride | string | "" | String to fully override template |
| gateway.annotations | object | {} | Annotations to add to the Gateway |
| gateway.className | string | "" | Name of an existing Gateway Class. Mandatory non-empty field |
| gateway.enabled | bool | false | Create Gateway if gateway.enabled = true. Otherwise, httpRoute will need parentRefs to attach to an existing Gateway. |
Deploy ollama with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ollama on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartollama is pinned at v1.96.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply