Liuyang 068aaecdbc feat(k8s-deployment): 添加 Kubernetes 部署文件
- 新增 MySQL、Redis、Server 和 Nginx 的 Deployment、Service 和 ConfigMap 文件
- 添加初始化 SQL 文件和 Nginx 配置文件
- 设置环境变量和持久化存储
2025-03-12 09:47:00 +08:00

401 lines
12 KiB
YAML

# MySQL Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: m.daocloud.io/docker.io/mysql:8.0.33
ports:
- containerPort: 3306
env:
- name: TZ
value: "Asia/Shanghai"
- name: MYSQL_CHARACTER_SET_SERVER
value: "utf8mb4"
- name: MYSQL_COLLATION_SERVER
value: "utf8mb4_unicode_ci"
- name: MYSQL_DATABASE
value: "ruoyi-vue-pro"
- name: MYSQL_ROOT_PASSWORD
value: "123456"
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
- name: init-sql
mountPath: /docker-entrypoint-initdb.d/init.sql
volumes:
- name: mysql-data
persistentVolumeClaim:
claimName: mysql-pvc
- name: init-sql
hostPath:
path: /host/xhllm.sql
type: File
---
# MySQL Service
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- port: 3306
targetPort: 3306
selector:
app: mysql
---
# MySQL PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
# Redis Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: m.daocloud.io/docker.io/redis
ports:
- containerPort: 6379
volumeMounts:
- name: redis-data
mountPath: /data
volumes:
- name: redis-data
persistentVolumeClaim:
claimName: redis-pvc
---
# Redis Service
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: redis
---
# Redis PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redis-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
# Server Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: yudao-server
spec:
replicas: 1
selector:
matchLabels:
app: yudao-server
template:
metadata:
labels:
app: yudao-server
spec:
containers:
- name: yudao-server
image: crpi-yaxyc8k2krkbnrmv.cn-hangzhou.personal.cr.aliyuncs.com/llm-server/xhllm-server
ports:
- containerPort: 48080
env:
- name: SPRING_PROFILES_ACTIVE
value: "local"
- name: JAVA_OPTS
value: "-Xms512m -Xmx512m -Djava.security.egd=file:/dev/./urandom -Dfile.encoding=UTF-8"
- name: MASTER_DATASOURCE_URL
value: "jdbc:mysql://mysql:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF-8&connectionCollation=utf8mb4_unicode_ci"
- name: MASTER_DATASOURCE_USERNAME
value: "root"
- name: MASTER_DATASOURCE_PASSWORD
value: "123456"
- name: SLAVE_DATASOURCE_URL
value: "jdbc:mysql://mysql:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF-8&connectionCollation=utf8mb4_unicode_ci"
- name: SLAVE_DATASOURCE_USERNAME
value: "root"
- name: SLAVE_DATASOURCE_PASSWORD
value: "123456"
- name: REDIS_HOST
value: "redis" # 使用 Redis Service 的名称
- name: REDIS_PORT
value: "6379" # Redis Service 的端口
volumeMounts:
- name: llm-config
mountPath: /app/config/llm_config.yml
subPath: llm_config.yml
imagePullSecrets:
- name: my-registry-key
volumes:
- name: llm-config
configMap:
name: llm-config
---
# Server Service
apiVersion: v1
kind: Service
metadata:
name: yudao-server
spec:
ports:
- port: 48080
targetPort: 48080
selector:
app: yudao-server
---
# Server ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: llm-config
data:
llm_config.yml: |
llm:
backend:
#################### 8123: RAG服务、训练集和标注相关API。 ###################
### RAG服务
#RAG健康检查 GET
rag_health: http://36.103.199.248:8123/health
#上传并向量化 POST
rag_embed: http://36.103.199.248:8123/embed
#获取所有向量id GET
rag_ids: http://36.103.199.248:8123/ids
#根据id获取文档 GET
rag_documents: http://36.103.199.248:8123/documents
#根据id删除文档 DEL
rag_documents_del: http://36.103.199.248:8123/documents
#根据file_id检索向量 POST
rag_query: http://36.103.199.248:8123/query
#支持多个文件id查询向量 GET
rag_query_multiple: http://36.103.199.248:8123/query_multiple
# 知识库向量嵌入
embed: http://36.103.199.248:8123/embed
# 知识库查询
embed_query: http://36.103.199.248:8123/query
#### LLM train and service api 训练集、标注相关API
# 训练集列表 GET
dataset_list: http://localhost:8123/api/mgr/datasets/list
# 上传训练集 POST
dataset_create: http://localhost:8123/api/mgr/datasets/create
# 删除训练集 DELETE
dataset_delete: http://localhost:8123/api/mgr/datasets/
# 训练集标注 GET
annotation_task_list: http://localhost:8123/api/mgr/annotation/task/list
# 标注信息 GET
annotation_task: http://localhost:8123/api/mgr/annotation/task
# 保存标注 POST
annotation_task_save: http://localhost:8123/api/mgr/annotation/task/task-6025001b-692c-44a1-9bc7-2a34bd7c0efe/segment/das-2eedd7bf-3770-4816-a961-b30c446b7a4f/mark
#################### 9000: 大模型管理、微调任务、文件上传和模型部署相关API。 ###################
# 大模型列表 GET
models_list: http://36.103.199.248:9000/api/models
# 登录 POST
login: http://36.103.199.248:9000/api/auth/login
account: http://36.103.199.248:9000/api/auth/account
login_username: admin
login_password: admin
# 微调任务详情 GET
finetuning_detail: http://36.103.199.248:9000/api/finetuning
# 微调任务取消
finetuning_cancel: http://36.103.199.248:9000/api/finetuning/%s/cancel
# 微调文件列表 GET
finetuning_file_list: http://36.103.199.248:9000/api/files?purpose=fine-tune
# 模型部署
model_create: http://36.103.199.248:9000/api/models
# aigc模型推理
aigc_model_completions: http://36.103.199.248:9000/api/channels/chat/completions
#################### 5123: 微调任务、模型部署、文件管理、提示词优化、自动评估、文生图等API。 ###################
# 创建微调任务 POST
# 微调文件上传
aigc_file_upload: /api/files
finetuning_create: /llm/finetuning
# 日志获取
finetuning_log: /llm/get_log
# 开始部署
model_deploy: /llm/deploy
# 取消部署
model_undeploy: /llm/deploy/stop?deploy_id=
# aigc表数据查询接口
table_data_query: /table/%s
# 模型文件列表
model_file_list: /models/?path=
# 模型文件下载
model_file_download: /models/download/?file_path=
# 提示词优化
optimize_prompt: http://36.103.199.248:5123/optimize-prompt
# 自动评估
auto_evaluation: /llm-eval
# 文生图
text_to_image: http://36.103.199.248:5123/generate-image
# 检查点文件列表
check_file_list: /llm/finetuning/checkpoints?model_name=
# 模型调优停止 POST
stop_finetuning: /llm/finetuning/stop
# 基座模型状态 POST
base_model_status: http://36.103.199.248:5123/llm/deploy/list
# 模型部署 POST
deploy_model: http://36.103.199.248:5123/llm/deploy
# 模型删除
delete_model: http://36.103.199.248:5123/llm/deploy/stop
#################### 30000: 大模型对话相关API。 ###################
#### 大模型对话
# 模型列表 GET
base_model_list: http://36.103.199.248:30000/model/v1/models
# 模型对话 POST
model_completions: http://36.103.199.248:30000/v1/chat/completions
#################### 48080: 应用和管理服务相关API。 ###################
application_api: http://localhost:48080/admin-api/llm/application/api/apiKey/chat
model_service_api: http://localhost:48080/admin-api/llm/model-service/api/apiKey/chat
---
# Nginx Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: m.daocloud.io/docker.io/nginx:1.23.0
ports:
- containerPort: 80
- containerPort: 443
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: nginx-html
mountPath: /usr/share/nginx/html/yudao-admin-ui
imagePullSecrets:
- name: my-registry-nginx-key
volumes:
- name: nginx-config
configMap:
name: nginx-config
- name: nginx-html
hostPath:
path: /host/dist-prod
type: Directory
---
# Nginx Service
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- name: http
port: 80
targetPort: 80
- name: https
port: 443
targetPort: 443
selector:
app: nginx
---
# Nginx ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
nginx.conf: |
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
charset utf-8;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name _;# 替换为你的域名或外网IP
charset utf-8;
location / { # 前端配置
root /usr/share/nginx/html/yudao-admin-ui;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /admin-api/ { # 后端代理配置
proxy_pass http://yudao-server:48080/admin-api/; # 替换为实际后端IP
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}