Skip to content

Instantly share code, notes, and snippets.

@markuskreitzer
Last active February 13, 2025 16:25
Show Gist options
  • Save markuskreitzer/6dad0f00bd19951f3f51c3ee30137aad to your computer and use it in GitHub Desktop.
Save markuskreitzer/6dad0f00bd19951f3f51c3ee30137aad to your computer and use it in GitHub Desktop.
Deploying OpenWebUI and Ollama to your Kubernetes Homelab

Deploying Ollama and OpenWebUI to Kubernetes

Deployment Order

  • Create the PVs and PVCs for ollama and open-webui.
  • Deploy the ollama Deployment and Service.
  • Deploy the open-webui Deployment and Service.
  • Finally, apply the Ingress for open-webui.
kubectl apply -f ollama-pv.yaml
kubectl apply -f ollama-pvc.yaml
kubectl apply -f open-webui-pv.yaml
kubectl apply -f open-webui-pvc.yaml
kubectl apply -f ollama-deployment.yaml
kubectl apply -f ollama-service.yaml
kubectl apply -f open-webui-deployment.yaml
kubectl apply -f open-webui-service.yaml
kubectl apply -f open-webui-ingress.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: ollama
spec:
replicas: 1
selector:
matchLabels:
app: ollama
template:
metadata:
labels:
app: ollama
spec:
containers:
- name: ollama
image: ollama/ollama:latest
imagePullPolicy: Always
tty: true
ports:
- containerPort: 11434
volumeMounts:
- name: ollama-data
mountPath: /root/.ollama
resources:
limits:
nvidia.com/gpu: 1 # Request one NVIDIA GPU
volumes:
- name: ollama-data
persistentVolumeClaim:
claimName: ollama-pvc
apiVersion: v1
kind: PersistentVolume
metadata:
name: ollama-pv
spec:
capacity:
storage: 500Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /your/path/to/ollama-data
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ollama-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Gi
apiVersion: v1
kind: Service
metadata:
name: ollama
spec:
selector:
app: ollama
ports:
- protocol: TCP
port: 11434
targetPort: 11434
apiVersion: apps/v1
kind: Deployment
metadata:
name: open-webui
spec:
replicas: 1
selector:
matchLabels:
app: open-webui
template:
metadata:
labels:
app: open-webui
spec:
containers:
- name: open-webui
image: ghcr.io/open-webui/open-webui:main
ports:
- containerPort: 8080
volumeMounts:
- name: open-webui-data
mountPath: /app/backend/data
env:
- name: OLLAMA_BASE_URL
value: "http://ollama:11434"
- name: WEBUI_SECRET_KEY
value: ""
imagePullPolicy: IfNotPresent
volumes:
- name: open-webui-data
persistentVolumeClaim:
claimName: open-webui-pvc
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: open-webui-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: openwebui.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: open-webui
port:
number: 8080
apiVersion: v1
kind: PersistentVolume
metadata:
name: open-webui-pv
spec:
capacity:
storage: 50Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /your/path/to/open-webui-data
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: open-webui-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
apiVersion: v1
kind: Service
metadata:
name: open-webui
spec:
selector:
app: open-webui
ports:
- protocol: TCP
port: 8080
targetPort: 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment