2023-10-30 17:10:54 -07:00
# Deploy Ollama to Kubernetes
## Prerequisites
2024-02-09 15:19:30 -08:00
- Ollama: https://ollama.com/download
2023-10-30 17:10:54 -07:00
- Kubernetes cluster. This example will use Google Kubernetes Engine.
## Steps
2024-05-07 18:53:08 +02:00
1. Create the Ollama namespace, deployment, and service
2023-10-30 17:10:54 -07:00
2024-02-09 15:19:30 -08:00
```bash
kubectl apply -f cpu.yaml
```
2023-10-30 17:10:54 -07:00
2024-05-07 18:53:08 +02:00
## (Optional) Hardware Acceleration
Hardware acceleration in Kubernetes requires NVIDIA's [`k8s-device-plugin` ](https://github.com/NVIDIA/k8s-device-plugin ) which is deployed in Kubernetes in form of daemonset. Follow the link for more details.
Once configured, create a GPU enabled Ollama deployment.
```bash
kubectl apply -f gpu.yaml
```
## Test
2023-10-30 17:10:54 -07:00
1. Port forward the Ollama service to connect and use it locally
2024-02-09 15:19:30 -08:00
```bash
kubectl -n ollama port-forward service/ollama 11434:80
```
2023-10-30 17:10:54 -07:00
2023-11-06 11:32:23 -08:00
1. Pull and run a model, for example `orca-mini:3b`
2023-10-30 17:10:54 -07:00
2024-02-09 15:19:30 -08:00
```bash
ollama run orca-mini:3b
2024-05-07 18:53:08 +02:00
```