Add Ollama and Open WebUI deployment to Kubernetes and migration plan
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.11"
|
||||
# dependencies = [
|
||||
# "rich",
|
||||
# "ollama",
|
||||
# ]
|
||||
# ///
|
||||
from typing import Union
|
||||
|
||||
from rich import print
|
||||
import os
|
||||
|
||||
# client = Client(headers={'Authorization': f"Bearer {os.getenv('OLLAMA_API_KEY')}"} if api_key else None)
|
||||
# --- MODIFICATION STARTS HERE ---
|
||||
ollama_url = os.getenv("OLLAMA_API_BASE_URL")
|
||||
|
||||
if not ollama_url:
|
||||
raise EnvironmentError("OLLAMA_API_BASE_URL environment variable must be set to connect to the Ollama service.")
|
||||
|
||||
client = Client(base_url=ollama_url, headers={'Authorization': f"Bearer {os.getenv('OLLAMA_API_KEY')}"} if os.getenv('OLLAMA_API_KEY') else None)
|
||||
# --- MODIFICATION ENDS HERE ---
|
||||
from ollama import WebFetchResponse, WebSearchResponse, chat, web_fetch, web_search
|
||||
|
||||
|
||||
def format_tool_results(
|
||||
results: Union[WebSearchResponse, WebFetchResponse],
|
||||
user_search: str,
|
||||
):
|
||||
output = []
|
||||
if isinstance(results, WebSearchResponse):
|
||||
output.append(f'Search results for "{user_search}":')
|
||||
for result in results.results:
|
||||
output.append(f'{result.title}' if result.title else f'{result.content}')
|
||||
output.append(f' URL: {result.url}')
|
||||
output.append(f' Content: {result.content}')
|
||||
output.append('')
|
||||
return '\n'.join(output).rstrip()
|
||||
|
||||
elif isinstance(results, WebFetchResponse):
|
||||
output.append(f'Fetch results for "{user_search}":')
|
||||
output.extend(
|
||||
[
|
||||
f'Title: {results.title}',
|
||||
f'URL: {user_search}' if user_search else '',
|
||||
f'Content: {results.content}',
|
||||
]
|
||||
)
|
||||
if results.links:
|
||||
output.append(f'Links: {", ".join(results.links)}')
|
||||
output.append('')
|
||||
return '\n'.join(output).rstrip()
|
||||
|
||||
|
||||
# client = Client(headers={'Authorization': f"Bearer {os.getenv('OLLAMA_API_KEY')}"} if api_key else None)
|
||||
available_tools = {'web_search': web_search, 'web_fetch': web_fetch}
|
||||
|
||||
query = "what is ollama's new engine"
|
||||
print('Query: ', query)
|
||||
|
||||
messages = [{'role': 'user', 'content': query}]
|
||||
while True:
|
||||
response = chat(model='qwen3', messages=messages, tools=[web_search, web_fetch], think=True)
|
||||
if response.message.thinking:
|
||||
print('Thinking: ')
|
||||
print(response.message.thinking + '\n\n')
|
||||
if response.message.content:
|
||||
print('Content: ')
|
||||
print(response.message.content + '\n')
|
||||
|
||||
messages.append(response.message)
|
||||
|
||||
if response.message.tool_calls:
|
||||
for tool_call in response.message.tool_calls:
|
||||
function_to_call = available_tools.get(tool_call.function.name)
|
||||
if function_to_call:
|
||||
args = tool_call.function.arguments
|
||||
result: Union[WebSearchResponse, WebFetchResponse] = function_to_call(**args)
|
||||
print('Result from tool call name:', tool_call.function.name, 'with arguments:')
|
||||
print(args)
|
||||
print()
|
||||
|
||||
user_search = args.get('query', '') or args.get('url', '')
|
||||
formatted_tool_results = format_tool_results(result, user_search=user_search)
|
||||
|
||||
print(formatted_tool_results[:300])
|
||||
print()
|
||||
|
||||
# caps the result at ~2000 tokens
|
||||
messages.append({'role': 'tool', 'content': formatted_tool_results[: 2000 * 4], 'tool_name': tool_call.function.name})
|
||||
else:
|
||||
print(f'Tool {tool_call.function.name} not found')
|
||||
messages.append({'role': 'tool', 'content': f'Tool {tool_call.function.name} not found', 'tool_name': tool_call.function.name})
|
||||
else:
|
||||
# no more tool calls, we can stop the loop
|
||||
break
|
||||
@@ -0,0 +1,219 @@
|
||||
# Ollama / Open WebUI → Kubernetes migration plan
|
||||
|
||||
## Current state
|
||||
|
||||
- Ollama runs on the workstation `pop-os` as a systemd service (`/usr/local/bin/ollama serve`).
|
||||
- It listens on `0.0.0.0:11434`.
|
||||
- Local models are stored under `/usr/share/ollama/.ollama/models` (≈ 24 GB). The Kubernetes Ollama instance will **not** use these; it will use **Ollama Cloud models only**.
|
||||
- The GPU is an NVIDIA GeForce RTX 2070 (8 GB VRAM) on `pop-os` — it stays on the workstation; Kubernetes has no GPU.
|
||||
- The Kubernetes cluster currently runs on three Hetzner nodes with **no GPU** and **no NVIDIA device plugin**.
|
||||
- Open WebUI runs on `pop-os` as a Docker container (`open-webui`), image `ghcr.io/open-webui/open-webui:main`, exposing host port `3000` mapped to container port `8080`.
|
||||
- Open WebUI stores data in a Docker volume (`/var/lib/docker/volumes/open-webui/_data`, ≈ 1.4 GB) mounted at `/app/backend/data`.
|
||||
- Current Open WebUI points to Ollama at `OLLAMA_BASE_URL=/ollama` via `host.docker.internal`.
|
||||
- The Kubernetes cluster has an existing PostgreSQL instance (`postgres-hetzner` in the `database` namespace) with pgvector support.
|
||||
|
||||
## Goal
|
||||
|
||||
Move Ollama and Open WebUI into the existing Kubernetes cluster:
|
||||
- Ollama will run **CPU-only** on the Hetzner nodes and use **Ollama Cloud models only**.
|
||||
- Ollama is exposed **only inside the cluster** (Service `ollama.ollama.svc.cluster.local:11434`), no Ingress.
|
||||
- Open WebUI is exposed on `chat.mariushome.lt` via Cilium dedicated LB Ingress.
|
||||
- Open WebUI connects to the in-cluster Ollama service and uses the existing PostgreSQL for its main database and pgvector RAG store.
|
||||
- This is a **fresh start** for Open WebUI data: existing chats/settings on `pop-os` are not migrated to PostgreSQL.
|
||||
- `pop-os` Ollama will be shut down after the migration.
|
||||
|
||||
## Important limitation / warning
|
||||
|
||||
The Hetzner worker nodes have only **~7.8 GB allocatable memory** and the master only **~3.8 GB**. Because Kubernetes Ollama uses **Ollama Cloud models only**, it does not download or run large models locally, so the small CPU/memory footprint is safe. If you later want to run local models in Kubernetes, you must add a larger/GPU node.
|
||||
|
||||
## Manifests added
|
||||
|
||||
All manifests are in `Ollama/`:
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `ollama_namespace.yaml` | `ollama` namespace (shared) |
|
||||
| `ollama_pvc.yaml` | PVC for Ollama state on `slow` StorageClass |
|
||||
| `ollama_secret_example.yaml` | Example Secret for `OLLAMA_API_KEY` (do NOT commit) |
|
||||
| `ollama_deployment.yaml` | CPU-only Ollama Deployment with cloud API key + PVC |
|
||||
| `ollama_service.yaml` | ClusterIP Service `ollama:11434` |
|
||||
| `openwebui_secret_example.yaml` | Example Secret with admin credentials and DB URLs (do NOT commit) |
|
||||
| `openwebui_db_setup.yaml` | One-time Job to create the `openwebui` DB/user in PostgreSQL |
|
||||
| `openwebui_deployment.yaml` | Open WebUI Deployment (PostgreSQL + pgvector) |
|
||||
| `openwebui_service.yaml` | ClusterIP Service `open-webui:8080` |
|
||||
| `openwebui_ingress.yaml` | Cilium dedicated LB ingress `chat.mariushome.lt` |
|
||||
|
||||
## Storage
|
||||
|
||||
### Ollama
|
||||
|
||||
Kubernetes Ollama uses **Ollama Cloud models only**, so no model blobs are stored locally. The Deployment mounts a PVC (`slow` StorageClass) at `/root/.ollama` to persist the Ollama Cloud login session / API key state across pod restarts.
|
||||
|
||||
### Ollama Cloud authentication
|
||||
|
||||
Ollama Cloud models require authentication. Two options:
|
||||
|
||||
1. **API key (recommended for Kubernetes)**: create an API key at https://ollama.com/settings/keys, then create the `ollama-cloud` Secret from `ollama_secret_example.yaml`. The Deployment injects `OLLAMA_API_KEY` automatically.
|
||||
|
||||
2. **Interactive signin**: exec into the pod and run `ollama signin`:
|
||||
|
||||
```bash
|
||||
kubectl -n ollama exec -it deploy/ollama -- ollama signin
|
||||
```
|
||||
|
||||
Because `/root/.ollama` is now persisted on a PVC, the session survives pod restarts.
|
||||
|
||||
### Open WebUI
|
||||
|
||||
Open WebUI uses the existing PostgreSQL (`postgres-hetzner.database.svc.cluster.local:5432`) for both the main relational database and the pgvector vector store. Uploaded files are still written to `/app/backend/data`, but since this is a fresh install, an `emptyDir` is sufficient.
|
||||
|
||||
If you later want persistence for uploads, create a small PVC using the **`slow`** StorageClass (SMB CSI — the cluster default). Do **not** use `hcloud-volumes` for Open WebUI uploads. Example:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: open-webui-uploads
|
||||
namespace: ollama
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
storageClassName: slow
|
||||
```
|
||||
|
||||
## Pre-deployment database setup
|
||||
|
||||
1. The existing `postgres-secret` in the `database` namespace already contains the superuser password, so no new Secret is needed.
|
||||
2. Edit `Ollama/openwebui_db_setup.yaml` and replace the placeholder password `openwebui-password` in the `CREATE USER` statement with a strong, unique password.
|
||||
3. Create the database and user:
|
||||
|
||||
```bash
|
||||
kubectl apply -f Ollama/openwebui_db_setup.yaml
|
||||
kubectl wait job/openwebui-db-setup -n database --for=condition=complete
|
||||
kubectl delete -f Ollama/openwebui_db_setup.yaml
|
||||
```
|
||||
|
||||
If the user/database already exists from a previous run with the old password, drop them first (requires the postgres superuser):
|
||||
|
||||
```bash
|
||||
kubectl run -it --rm -n database psql-cleanup --image=rg.mariushome.lt/custom-postgres --restart=Never --env="PGUSER=admin" --env="PGPASSWORD=$(kubectl get secret -n database postgres-secret -o jsonpath='{.data.POSTGRES_PASSWORD}' | base64 -d)" -- psql -h postgres.database.svc.cluster.local -d postgres -c "DROP DATABASE IF EXISTS openwebui; DROP USER IF EXISTS openwebui;"
|
||||
```
|
||||
|
||||
## Secret creation (interactive)
|
||||
|
||||
The `openwebui-secret` must be created out-of-band because it contains passwords. Use the helper script and enter the same password you set in `openwebui_db_setup.yaml`:
|
||||
|
||||
```bash
|
||||
./Ollama/create_openwebui_secret.sh
|
||||
```
|
||||
|
||||
Or create it manually, replacing `YOUR-OPENWEBUI-DB-PASSWORD` with the password from `openwebui_db_setup.yaml`:
|
||||
|
||||
```bash
|
||||
kubectl create secret generic -n ollama openwebui-secret \
|
||||
--from-literal=WEBUI_SECRET_KEY="977a7a4e9051d31575f17ed7610c7bf7f9af9475205cc636ead271e699f1a680" \
|
||||
--from-literal=WEBUI_ADMIN_EMAIL="admin@mariushome.lt" \
|
||||
--from-literal=WEBUI_ADMIN_PASSWORD="fsbubSHADBJKASDs4s4ds5" \
|
||||
--from-literal=DATABASE_URL="postgresql://openwebui:YOUR-OPENWEBUI-DB-PASSWORD@postgres-hetzner.database.svc.cluster.local:5432/openwebui" \
|
||||
--from-literal=PGVECTOR_DB_URL="postgresql://openwebui:YOUR-OPENWEBUI-DB-PASSWORD@postgres-hetzner.database.svc.cluster.local:5432/openwebui"
|
||||
```
|
||||
|
||||
## Rollout steps
|
||||
|
||||
1. Recreate the `openwebui` database/user with the new password (see "Pre-deployment database setup" above).
|
||||
|
||||
2. Create the Open WebUI namespace:
|
||||
|
||||
```bash
|
||||
kubectl apply -f Ollama/ollama_namespace.yaml
|
||||
```
|
||||
|
||||
3. Create the `openwebui-secret` interactively (see "Secret creation" above) using the new password.
|
||||
|
||||
4. Create the Ollama PVC and (optionally) cloud Secret:
|
||||
|
||||
```bash
|
||||
# PVC for /root/.ollama state
|
||||
kubectl apply -f Ollama/ollama_pvc.yaml
|
||||
|
||||
# Optional: if using an Ollama Cloud API key, create the Secret first:
|
||||
# (Get your key from https://ollama.com/settings/keys)
|
||||
kubectl apply -f Ollama/ollama_secret_example.yaml
|
||||
```
|
||||
|
||||
5. Apply Ollama manifests:
|
||||
|
||||
```bash
|
||||
kubectl apply -f Ollama/ollama_service.yaml
|
||||
kubectl apply -f Ollama/ollama_deployment.yaml
|
||||
```
|
||||
|
||||
6. Verify Ollama is running and accessible inside the cluster:
|
||||
|
||||
```bash
|
||||
kubectl -n ollama get pods -o wide
|
||||
kubectl -n ollama logs -f deploy/ollama
|
||||
kubectl -n ollama exec -it deploy/ollama -- ollama list
|
||||
```
|
||||
|
||||
7. Apply Open WebUI manifests:
|
||||
|
||||
```bash
|
||||
kubectl apply -f Ollama/openwebui_service.yaml
|
||||
kubectl apply -f Ollama/openwebui_deployment.yaml
|
||||
kubectl apply -f Ollama/openwebui_ingress.yaml
|
||||
```
|
||||
|
||||
8. Verify:
|
||||
|
||||
```bash
|
||||
kubectl -n ollama get pods -o wide
|
||||
kubectl -n ollama logs -f deploy/open-webui
|
||||
kubectl -n ollama get ingress
|
||||
```
|
||||
|
||||
9. Update DNS for `chat.mariushome.lt` to point to the Cilium LB IP assigned to the `open-webui` Ingress.
|
||||
|
||||
10. After confirming Open WebUI works on `chat.mariushome.lt`, shut down the local `pop-os` services (keep the Docker volume as a backup):
|
||||
|
||||
```bash
|
||||
sudo systemctl stop ollama
|
||||
sudo systemctl disable ollama
|
||||
docker stop open-webui
|
||||
# Keep the volume for backup; only remove the container.
|
||||
docker rm open-webui
|
||||
```
|
||||
|
||||
## Client / consumer reconfiguration
|
||||
|
||||
- Update Open WebUI access from `http://pop-os:3000` to `http://chat.mariushome.lt`.
|
||||
- Ollama consumers inside the cluster should use `http://ollama.ollama.svc.cluster.local:11434`. No external Ollama endpoint is exposed.
|
||||
- For OpenCode, change the Ollama host to `http://ollama.ollama.svc.cluster.local:11434` if OpenCode runs inside the cluster, or use the Open WebUI endpoint externally.
|
||||
|
||||
## Important security notes
|
||||
|
||||
- Ollama is **not exposed via Ingress**; it is reachable only inside the cluster.
|
||||
- Open WebUI is exposed on `chat.mariushome.lt` inside the LAN. Do not publish it to the public Internet without an authenticating proxy.
|
||||
- Signups are disabled (`ENABLE_SIGNUP=false`). The initial admin account is bootstrapped from the Secret.
|
||||
- `openwebui_secret_example.yaml` and `openwebui_db_setup.yaml` contain sensitive values and must be created out-of-band; do not commit them.
|
||||
|
||||
## Rollback
|
||||
|
||||
```bash
|
||||
kubectl delete -f Ollama/openwebui_ingress.yaml
|
||||
kubectl delete -f Ollama/openwebui_deployment.yaml
|
||||
kubectl delete -f Ollama/openwebui_service.yaml
|
||||
kubectl delete -f Ollama/ollama_deployment.yaml
|
||||
kubectl delete -f Ollama/ollama_service.yaml
|
||||
# Restart local services on pop-os if needed:
|
||||
sudo systemctl start ollama
|
||||
docker start open-webui
|
||||
```
|
||||
|
||||
## Decisions made
|
||||
|
||||
- The `openwebui` PostgreSQL user must use a **different password than the example `openwebui-password`**. Edit `openwebui_db_setup.yaml`, replace the password in the `CREATE USER` statement, and re-run the Job to recreate the user/database before creating the `openwebui-secret`.
|
||||
- The `pop-os` Open WebUI Docker data (`/var/lib/docker/volumes/open-webui/_data`, ≈ 1.4 GB) will be **kept as a backup** after shutdown. Do not delete the Docker volume when stopping the container.
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Helper script to create the openwebui-secret without committing passwords.
|
||||
# Run interactively and enter the password when prompted.
|
||||
|
||||
NAMESPACE="ollama"
|
||||
SECRET_NAME="openwebui-secret"
|
||||
|
||||
echo "=== Create Kubernetes secret for Open WebUI ==="
|
||||
|
||||
read -rsp "Enter password for the 'openwebui' PostgreSQL user: " DB_PASSWORD
|
||||
echo
|
||||
read -rsp "Enter WEBUI_SECRET_KEY (or press Enter to auto-generate one): " SECRET_KEY
|
||||
echo
|
||||
if [[ -z "$SECRET_KEY" ]]; then
|
||||
SECRET_KEY=$(openssl rand -hex 32)
|
||||
echo "Auto-generated WEBUI_SECRET_KEY: $SECRET_KEY"
|
||||
fi
|
||||
|
||||
read -rp "Enter Open WebUI admin email [admin@mariushome.lt]: " ADMIN_EMAIL
|
||||
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@mariushome.lt}
|
||||
|
||||
read -rsp "Enter Open WebUI admin password [fsbubSHADBJKASDs4s4ds5]: " ADMIN_PASSWORD
|
||||
echo
|
||||
ADMIN_PASSWORD=${ADMIN_PASSWORD:-fsbubSHADBJKASDs4s4ds5}
|
||||
|
||||
DATABASE_URL="postgresql://openwebui:${DB_PASSWORD}@postgres-hetzner.database.svc.cluster.local:5432/openwebui"
|
||||
PGVECTOR_DB_URL="postgresql://openwebui:${DB_PASSWORD}@postgres-hetzner.database.svc.cluster.local:5432/openwebui"
|
||||
|
||||
kubectl create secret generic -n "$NAMESPACE" "$SECRET_NAME" \
|
||||
--from-literal=WEBUI_SECRET_KEY="$SECRET_KEY" \
|
||||
--from-literal=WEBUI_ADMIN_EMAIL="$ADMIN_EMAIL" \
|
||||
--from-literal=WEBUI_ADMIN_PASSWORD="$ADMIN_PASSWORD" \
|
||||
--from-literal=DATABASE_URL="$DATABASE_URL" \
|
||||
--from-literal=PGVECTOR_DB_URL="$PGVECTOR_DB_URL" \
|
||||
--dry-run=client -o yaml | kubectl apply -f -
|
||||
|
||||
echo "Secret '$SECRET_NAME' created/updated in namespace '$NAMESPACE'."
|
||||
@@ -0,0 +1,73 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ollama
|
||||
namespace: ollama
|
||||
labels:
|
||||
app: ollama
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ollama
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ollama
|
||||
spec:
|
||||
# CPU-only Ollama running on Hetzner nodes. No GPU available.
|
||||
containers:
|
||||
- name: ollama
|
||||
image: ollama/ollama:0.32.4
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: OLLAMA_HOST
|
||||
value: "0.0.0.0:11434"
|
||||
# Optional: keep models loaded for N minutes after last use (e.g. 15m).
|
||||
# - name: OLLAMA_KEEP_ALIVE
|
||||
# value: "15m"
|
||||
# Ollama Cloud API key for cloud models. Create the ollama-cloud Secret
|
||||
# from ollama_secret_example.yaml, or sign in with `ollama signin`.
|
||||
- name: OLLAMA_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: ollama-cloud
|
||||
key: OLLAMA_API_KEY
|
||||
optional: true
|
||||
ports:
|
||||
- containerPort: 11434
|
||||
name: http
|
||||
protocol: TCP
|
||||
# OllamaCloud-only: no local model execution, so CPU/RAM needs are minimal.
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 1Gi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 11434
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 6
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 11434
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 6
|
||||
volumeMounts:
|
||||
- name: ollama-state
|
||||
mountPath: /root/.ollama
|
||||
volumes:
|
||||
- name: ollama-state
|
||||
persistentVolumeClaim:
|
||||
claimName: ollama-state
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: ollama
|
||||
labels:
|
||||
app: ollama
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: ollama-state
|
||||
namespace: ollama
|
||||
labels:
|
||||
app: ollama
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
storageClassName: slow
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: ollama
|
||||
namespace: ollama
|
||||
labels:
|
||||
app: ollama
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: ollama
|
||||
ports:
|
||||
- name: http
|
||||
port: 11434
|
||||
targetPort: 11434
|
||||
protocol: TCP
|
||||
@@ -0,0 +1,47 @@
|
||||
# Run this init job once to create the Open WebUI database and user on the
|
||||
# existing postgres-hetzner instance.
|
||||
#
|
||||
# This manifest references the existing postgres-secret in the database namespace.
|
||||
# If your secret has a different name or key, update the env block below.
|
||||
#
|
||||
# Then:
|
||||
# 1. kubectl apply -f Ollama/openwebui_db_setup.yaml
|
||||
# 2. kubectl wait job/openwebui-db-setup -n database --for=condition=complete
|
||||
# 3. kubectl delete -f Ollama/openwebui_db_setup.yaml
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: openwebui-db-setup
|
||||
namespace: database
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
imagePullSecrets:
|
||||
- name: registry-creds
|
||||
containers:
|
||||
- name: psql
|
||||
image: rg.mariushome.lt/custom-postgres
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: PGUSER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secret
|
||||
key: POSTGRES_USER
|
||||
- name: PGPASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secret
|
||||
key: POSTGRES_PASSWORD
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
psql -h postgres.database.svc.cluster.local -d postgres -e <<'SQL'
|
||||
CREATE USER openwebui WITH PASSWORD '6b44a0043b23368a18b6aa940dd30ae7299a77dcd2e555f554c51066a1e4e76f';
|
||||
CREATE DATABASE openwebui OWNER openwebui;
|
||||
\c openwebui
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
GRANT ALL PRIVILEGES ON DATABASE openwebui TO openwebui;
|
||||
SQL
|
||||
@@ -0,0 +1,103 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: open-webui
|
||||
namespace: ollama
|
||||
labels:
|
||||
app: open-webui
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: open-webui
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: open-webui
|
||||
spec:
|
||||
containers:
|
||||
- name: open-webui
|
||||
image: ghcr.io/open-webui/open-webui:main
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: OLLAMA_BASE_URL
|
||||
value: "http://ollama.ollama.svc.cluster.local:11434"
|
||||
- name: WEBUI_URL
|
||||
value: "http://chat.mariushome.lt"
|
||||
- name: PORT
|
||||
value: "8080"
|
||||
- name: ENABLE_SIGNUP
|
||||
value: "false"
|
||||
- name: ENABLE_LOGIN_FORM
|
||||
value: "true"
|
||||
- name: ENABLE_RAG
|
||||
value: "true"
|
||||
- name: RAG_EMBEDDING_ENGINE
|
||||
value: "ollama"
|
||||
- name: RAG_EMBEDDING_MODEL
|
||||
value: "nomic-embed-text"
|
||||
- name: VECTOR_DB
|
||||
value: "pgvector"
|
||||
- name: ENABLE_PERSISTENT_CONFIG
|
||||
value: "true"
|
||||
- name: WEBUI_SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openwebui-secret
|
||||
key: WEBUI_SECRET_KEY
|
||||
- name: WEBUI_ADMIN_EMAIL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openwebui-secret
|
||||
key: WEBUI_ADMIN_EMAIL
|
||||
- name: WEBUI_ADMIN_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openwebui-secret
|
||||
key: WEBUI_ADMIN_PASSWORD
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openwebui-secret
|
||||
key: DATABASE_URL
|
||||
- name: PGVECTOR_DB_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openwebui-secret
|
||||
key: PGVECTOR_DB_URL
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: http
|
||||
protocol: TCP
|
||||
resources:
|
||||
requests:
|
||||
cpu: "250m"
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: "2"
|
||||
memory: 4Gi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8080
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8080
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 5
|
||||
# Fresh PostgreSQL install: uploads go to emptyDir. Add a PVC later if needed.
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /app/backend/data
|
||||
volumes:
|
||||
- name: data
|
||||
emptyDir: {}
|
||||
@@ -0,0 +1,20 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: open-webui
|
||||
namespace: ollama
|
||||
annotations:
|
||||
ingress.cilium.io/loadbalancer-mode: "dedicated"
|
||||
spec:
|
||||
ingressClassName: cilium
|
||||
rules:
|
||||
- host: chat.mariushome.lt
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: open-webui
|
||||
port:
|
||||
number: 8080
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: open-webui
|
||||
namespace: ollama
|
||||
labels:
|
||||
app: open-webui
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: open-webui
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
protocol: TCP
|
||||
Reference in New Issue
Block a user