This project provides a simple and straightforward way to deploy a local Language Model (LLM) on a Kubernetes cluster. It uses Ollama to serve the LLM and Open WebUI as a web interface for interacting with the model.
- Local LLM Deployment: Run your own LLM locally on your Kubernetes cluster.
- Ollama Integration: Uses Ollama to serve a variety of open-source language models.
- Web Interface: Provides a user-friendly web interface with Open WebUI.
- Kubernetes-Native: Deploys all components as Kubernetes resources (Deployments, Services, Ingress).
- Customizable: Easily customize the LLM model and other configurations.
- Pre-configured Admin: The Open WebUI admin user can be pre-configured for immediate use.
- A running Kubernetes cluster.
kubectlinstalled and configured to connect to your cluster.- An Ingress controller (like NGINX Ingress Controller) running in your cluster to expose the web UI.
-
Clone the repository or download the manifest file: You will need the
k8sManifests.yamlfile. -
Customize the manifest (optional): You can edit the
k8sManifests.yamlfile to change the default configuration. For example, you can change the LLM model to be pulled by Ollama.In the
ollamadeployment, find theinitContainerssection and change theargsto pull a different model:args: ["ollama serve & sleep 5 && ollama pull <your-model-name>"]
By default, it pulls
phi3.5. -
Apply the manifest:
kubectl apply -f k8sManifests.yaml
This will create all the necessary Kubernetes resources:
- A
PersistentVolumeClaimfor Ollama's model storage. - A
Deploymentfor Ollama. - A
Servicefor Ollama. - A
Deploymentfor Open WebUI. - A
Servicefor Open WebUI. - An
Ingressresource to expose the Open WebUI.
- A
-
Access the Web UI: Once the Ingress is set up, you can access the Open WebUI in your browser. The default configuration uses the hostname
chat.local.opscale.ir. You might need to add a corresponding entry to your/etc/hostsfile or configure your DNS to point this hostname to your Ingress controller's IP address.The default admin credentials are:
- Email:
admin@local.opscale.ir - Password:
ChangeMe123!
- Email:
- Model: To change the model, modify the
argsof themodel-pullerinit container in theollamadeployment ink8sManifests.yaml. - Resources: You can adjust the CPU and memory resources for the
ollamacontainer based on the model you are using.
- Admin User: The admin user is configured via environment variables in the
open-webuideployment ink8sManifests.yaml. You can change theADMIN_EMAIL,ADMIN_PASSWORD, andADMIN_NAMEvalues. - Sign-up: The
ENABLE_SIGNUPenvironment variable is set tofalseby default to disable user sign-ups.
The project consists of the following components:
graph LR
subgraph User
U[Browser]
end
subgraph Kubernetes Cluster
Ingress(chat.local.opscale.ir)
WebUI[Open WebUI]
Ollama[Ollama]
PVC(Model Storage)
U -- HTTPS --> Ingress
Ingress -- HTTP --> WebUI
WebUI -- "Talks to" --> Ollama
Ollama -- "Loads/Saves Models" --> PVC
end
style U fill:#f9f,stroke:#333,stroke-width:2px
- Ollama Deployment: A Kubernetes Deployment that runs the Ollama server. It uses a
PersistentVolumeClaimto store the downloaded LLM models. AninitContaineris used to pull the desired model on startup. - Ollama Service: A ClusterIP service that exposes the Ollama server within the cluster.
- Open WebUI Deployment: A Kubernetes Deployment that runs the Open WebUI. It is configured to connect to the Ollama service.
- Open WebUI Service: A ClusterIP service that exposes the Open WebUI within the cluster.
- Ingress: A Kubernetes Ingress resource that exposes the Open WebUI service to the outside world via a hostname.