Ollama + Open WebUI 使用随记

Ollama 是简化本地设备上大型语言模型 (LLM) 安装和管理的平台,而 Open WebUI 是 Ollama LLM 运行程序的可扩展网络用户界面。

Ollama

在 Kubernetes 上部署 Ollama:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
helm repo add ollama-helm https://otwld.github.io/ollama-helm/
helm repo update

cat <<EOF > ollama-values.yaml
replicaCount: 1
knative:
enabled: false
image:
repository: ollama/ollama
pullPolicy: IfNotPresent
ollama:
gpu:
enabled: true
type: 'nvidia'
number: 1
nvidiaResource: "nvidia.com/gpu"
mig:
enabled: false
models:
pull: []
run: []
create: []
insecure: false
serviceAccount:
create: true
automount: true
runtimeClassName: "nvidia"
service:
type: ClusterIP
port: 11434
nodePort: 31434
loadBalancerIP:
ingress:
enabled: false
livenessProbe:
enabled: true
path: /
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
successThreshold: 1
readinessProbe:
enabled: true
path: /
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 6
successThreshold: 1
autoscaling:
enabled: false
persistentVolume:
enabled: true
accessModes:
- ReadWriteOnce
size: 10Gi
storageClass: "longhorn"
updateStrategy:
type: "Recreate"
hostIPC: false
hostPID: false
hostNetwork: false
EOF

helm -n ollama upgrade --install ollama ollama-helm/ollama -f ollama-values.yaml --version 1.7.0

下载 deepseek-r1:1.5b 模型并运行:

调用 API 运行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
root@rke2-cilium-01:~/ai-related# curl -s -X POST http://<ollama-svc-ip>:11434/api/generate -d '{ "model": "deepseek-r1:1.5b", "prompt": "你好?", "stream": false }' | jq
{
"model": "deepseek-r1:1.5b",
"created_at": "2025-02-27T04:46:43.19616833Z",
"response": "<think>\n\n</think>\n\n您好!很高兴为您服务。请问有什么可以帮助您的?",
"done": true,
"done_reason": "stop",
"context": [
151644,
108386,
30,
151645,
151648,
271,
151649,
271,
111308,
6313,
112169,
102804,
47874,
1773,
109194,
104139,
111728,
101214,
11319
],
"total_duration": 3243229672,
"load_duration": 2905513629,
"prompt_eval_count": 5,
"prompt_eval_duration": 82000000,
"eval_count": 16,
"eval_duration": 253000000
}

Open WebUI

在 Kubernetes 上部署 Open WebUI:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
helm repo add open-webui https://helm.openwebui.com/
helm repo update

cat <<EOF > open-webui-values.yaml
ollama:
enabled: false
fullnameOverride: "open-webui-ollama"
pipelines:
enabled: false
tika:
enabled: false
ollamaUrls:
- http://ollama.ollama.svc.cluster.local:11434
ollamaUrlsFromExtraEnv: false
websocket:
enabled: false
redis-cluster:
enabled: false
clusterDomain: cluster.local
replicaCount: 1
image:
repository: harbor.warnerchen.com/open-webui/open-webui
pullPolicy: "IfNotPresent"
serviceAccount:
enable: true
automountServiceAccountToken: false
managedCertificate:
enabled: false
ingress:
enabled: true
class: "nginx"
tls: false
host: "open-webui.warnerchen.com"
persistence:
enabled: true
size: 2Gi
accessModes:
- ReadWriteOnce
storageClass: "longhorn"
service:
type: ClusterIP
port: 80
containerPort: 8080
openaiBaseApiUrl: "https://api.openai.com/v1"
extraEnvVars:
- name: OPENAI_API_KEY
value: "0p3n-w3bu!"
- name: WEBUI_AUTH
value: "False"
EOF

helm -n ollama upgrade --install open-webui open-webui/open-webui -f open-webui-values.yaml --version 5.20.0

访问 Open WebUI:

Author

Warner Chen

Posted on

2025-02-27

Updated on

2025-02-27

Licensed under

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.