Lobe Chat 是一个基于 Kubernetes 部署的聊天应用程序,使用 PostgreSQL 作为数据库,并集成了 OpenAI 和 DeepSeek 等第三方 API。应用程序通过 Ingress 暴露服务,支持 HTTPS 访问。
在开始部署之前,请确保以下环境和工具已准备就绪:
chart.jiufog.space
)和对应的 TLS 证书。强制,因为与Logto有关。将以下 Manifest 文件保存为 lobe-deployment.yaml
,并根据实际情况替换 {{ }}
中的内容。
apiVersion: apps/v1
kind: Deployment
metadata:
name: lobe-chat
namespace: dev
spec:
replicas: 1
selector:
matchLabels:
app: lobe-chat
template:
metadata:
labels:
app: lobe-chat
spec:
containers:
- name: lobe-chat-container
image: lobehub/lobe-chat-database:latest
imagePullPolicy: Always
ports:
- containerPort: 3210
env:
- name: ENABLED_OPENAI
value: "0"
- name: SILICONCLOUD_API_KEY
value: "{{ YOUR_SILICONCLOUD_API_KEY }}" # 替换为实际的 SiliconCloud API 密钥
- name: DATABASE_URL
value: "{{ YOUR_DATABASE_URL }}" # 替换为实际的 PostgreSQL 连接字符串
- name: S3_ACCESS_KEY_ID
value: "{{ YOUR_S3_ACCESS_KEY_ID }}" # 替换为实际的 S3 Access Key ID
- name: S3_SECRET_ACCESS_KEY
value: "{{ YOUR_S3_SECRET_ACCESS_KEY }}" # 替换为实际的 S3 Secret Access Key
- name: S3_ENDPOINT
value: "{{ YOUR_S3_ENDPOINT }}" # 替换为实际的 S3 Endpoint
- name: S3_PUBLIC_DOMAIN
value: "{{ YOUR_S3_PUBLIC_DOMAIN }}" # 替换为实际的 S3 Public Domain
- name: S3_ENABLE_PATH_STYLE
value: "1"
- name: S3_BUCKET
value: "{{ YOUR_S3_BUCKET }}" # 替换为实际的 S3 Bucket 名称
- name: APP_URL
value: "{{ YOUR_APP_URL }}" # 替换为你的域名
- name: KEY_VAULTS_SECRET
value: "{{ YOUR_KEY_VAULTS_SECRET }}" # 替换为实际的 Key Vaults Secret
- name: NEXT_AUTH_SECRET
value: "{{ YOUR_NEXT_AUTH_SECRET }}" # 替换为实际的 Next Auth Secret
- name: NEXTAUTH_URL
value: "{{ YOUR_NEXTAUTH_URL }}" # 替换为实际的 NextAuth URL
- name: NEXT_AUTH_SSO_PROVIDERS
value: logto # 采用的logto作为用户管理
- name: AUTH_LOGTO_ID
value: "{{ YOUR_AUTH_LOGTO_ID }}" # 替换为实际的 Logto ID
- name: AUTH_LOGTO_SECRET
value: "{{ YOUR_AUTH_LOGTO_SECRET }}" # 替换为实际的 Logto Secret
- name: AUTH_LOGTO_ISSUER
value: "{{ YOUR_AUTH_LOGTO_ISSUER }}" # 替换为实际的 Logto Issuer
- name: LOGTO_WEBHOOK_SIGNING_KEY
value: "{{ YOUR_LOGTO_WEBHOOK_SIGNING_KEY }}" # 替换为实际的 Logto Webhook Signing Key
- name: DEFAULT_FILES_CONFIG
value: embedding_model=siliconcloud/BAAI/bge-m3 # 向量分析使用的模型
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ai-ingress
namespace: dev
spec:
ingressClassName: nginx
rules:
- host: "{{ YOUR_HOST }}" # 替换为实际的域名
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: ai-chat
port:
number: 80
tls:
- hosts:
- "{{ YOUR_HOST }}" # 替换为实际的域名
secretName: "{{ YOUR_TLS_SECRET_NAME }}" # 替换为实际的 TLS Secret 名称
---
apiVersion: v1
kind: Service
metadata:
name: ai-chat
namespace: dev
spec:
selector:
app: lobe-chat
ports:
- protocol: TCP
port: 80
targetPort: 3210
选择硅基流动API(避免deepseek的API服务器性能瓶颈,还会额外赠送14元的体验金):
https://cloud.siliconflow.cn/i/frVugSQo
硅基流动API接入文档:
如果 dev
Namespace 尚未创建,请先创建:
kubectl create namespace dev
使用 kubectl
部署应用程序:
kubectl apply -f lobe-deployment.yaml
检查 Deployment、Service 和 Ingress 是否成功创建:
kubectl -n dev get deployment,service,ingress
确保 Pod 已成功启动并处于 Running
状态:
kubectl -n dev get pods
通过浏览器访问 https://{{ YOUR_HOST }}
,确保应用程序能够正常加载。
如果应用程序无法正常工作,可以查看 Pod 日志以排查问题:
kubectl -n dev logs <pod-name>
根据需要调整 Deployment 的副本数:
kubectl -n dev scale deployment lobe-chat --replicas=3
如果需要更新应用程序镜像,可以修改 image
字段并重新应用 Manifest:
kubectl apply -f lobe-deployment.yaml
建议配置 Prometheus 和 Grafana 对应用程序进行监控,重点关注以下指标:
kubectl logs
查看 Pod 日志以获取更多信息。DATABASE_URL
的值正确。以下是需要用户根据实际情况替换的内容:
{{ YOUR_SILICONCLOUD_API_KEY }}
:替换为实际的 SiliconCloud API 密钥。{{ YOUR_DATABASE_URL }}
:替换为实际的 PostgreSQL 连接字符串。{{ YOUR_S3_ACCESS_KEY_ID }}
、{{ YOUR_S3_SECRET_ACCESS_KEY }}
、{{ YOUR_S3_ENDPOINT }}
、{{ YOUR_S3_BUCKET }}
:替换为实际的 S3 存储配置。{{ YOUR_HOST }}
:替换为实际的域名。{{ YOUR_TLS_SECRET_NAME }}
:替换为实际的 TLS 证书 Secret 名称。{{ YOUR_APP_URL }}
:替换为实际的应用程序 URL。{{ YOUR_KEY_VAULTS_SECRET }}
:替换为实际的 Key Vaults Secret。{{ YOUR_NEXT_AUTH_SECRET }}
:替换为实际的 Next Auth Secret。{{ YOUR_NEXTAUTH_URL }}
:替换为实际的 NextAuth URL。{{ YOUR_AUTH_LOGTO_ID }}
:替换为实际的 Logto ID。{{ YOUR_AUTH_LOGTO_SECRET }}
:替换为实际的 Logto Secret。{{ YOUR_AUTH_LOGTO_ISSUER }}
:替换为实际的 Logto Issuer。{{ YOUR_LOGTO_WEBHOOK_SIGNING_KEY }}
:替换为实际的 Logto Webhook Signing Key。选择硅基流动API(避免deepseek的API服务器性能瓶颈,还会额外赠送14元的体验金):
https://cloud.siliconflow.cn/i/frVugSQo
硅基流动API接入文档: