From 068aaecdbc5ea04d79faf25d0d400bf956d749c5 Mon Sep 17 00:00:00 2001 From: Liuyang <2746366019@qq.com> Date: Wed, 12 Mar 2025 09:47:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(k8s-deployment):=20=E6=B7=BB=E5=8A=A0=20Ku?= =?UTF-8?q?bernetes=20=E9=83=A8=E7=BD=B2=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 MySQL、Redis、Server 和 Nginx 的 Deployment、Service 和 ConfigMap 文件 - 添加初始化 SQL 文件和 Nginx 配置文件 - 设置环境变量和持久化存储 --- script/k8s-deployment/deployment.yaml | 400 ++++++++++++++++++ script/k8s-deployment/mysql-deployment.yaml | 68 +++ .../mysql/mysql-deployment.yaml | 43 ++ script/k8s-deployment/mysql/mysql-pvc.yaml | 10 + .../k8s-deployment/mysql/mysql-service.yaml | 10 + script/k8s-deployment/nginx-deployment.yaml | 106 +++++ .../nginx/nginx-config-configmap.yaml | 7 + .../nginx/nginx-deployment.yaml | 34 ++ .../k8s-deployment/nginx/nginx-service.yaml | 12 + script/k8s-deployment/redis-deployment.yaml | 51 +++ .../redis/redis-deployment.yaml | 27 ++ script/k8s-deployment/redis/redis-pvc.yaml | 10 + .../k8s-deployment/redis/redis-service.yaml | 10 + script/k8s-deployment/server-service.yaml | 170 ++++++++ .../server/llm-config-configmap.yaml | 7 + .../k8s-deployment/server/server-service.yaml | 10 + 16 files changed, 975 insertions(+) create mode 100644 script/k8s-deployment/deployment.yaml create mode 100644 script/k8s-deployment/mysql-deployment.yaml create mode 100644 script/k8s-deployment/mysql/mysql-deployment.yaml create mode 100644 script/k8s-deployment/mysql/mysql-pvc.yaml create mode 100644 script/k8s-deployment/mysql/mysql-service.yaml create mode 100644 script/k8s-deployment/nginx-deployment.yaml create mode 100644 script/k8s-deployment/nginx/nginx-config-configmap.yaml create mode 100644 script/k8s-deployment/nginx/nginx-deployment.yaml create mode 100644 script/k8s-deployment/nginx/nginx-service.yaml create mode 100644 script/k8s-deployment/redis-deployment.yaml create mode 100644 script/k8s-deployment/redis/redis-deployment.yaml create mode 100644 script/k8s-deployment/redis/redis-pvc.yaml create mode 100644 script/k8s-deployment/redis/redis-service.yaml create mode 100644 script/k8s-deployment/server-service.yaml create mode 100644 script/k8s-deployment/server/llm-config-configmap.yaml create mode 100644 script/k8s-deployment/server/server-service.yaml diff --git a/script/k8s-deployment/deployment.yaml b/script/k8s-deployment/deployment.yaml new file mode 100644 index 000000000..03a373023 --- /dev/null +++ b/script/k8s-deployment/deployment.yaml @@ -0,0 +1,400 @@ +# 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; + } + } + + } diff --git a/script/k8s-deployment/mysql-deployment.yaml b/script/k8s-deployment/mysql-deployment.yaml new file mode 100644 index 000000000..a25e1fa83 --- /dev/null +++ b/script/k8s-deployment/mysql-deployment.yaml @@ -0,0 +1,68 @@ +# 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 diff --git a/script/k8s-deployment/mysql/mysql-deployment.yaml b/script/k8s-deployment/mysql/mysql-deployment.yaml new file mode 100644 index 000000000..8db84e740 --- /dev/null +++ b/script/k8s-deployment/mysql/mysql-deployment.yaml @@ -0,0 +1,43 @@ +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 + volumes: + - name: mysql-data + persistentVolumeClaim: + claimName: mysql-pvc + - name: init-sql + hostPath: + path: /Users/yangliu/Desktop/xhllm.sql + type: File diff --git a/script/k8s-deployment/mysql/mysql-pvc.yaml b/script/k8s-deployment/mysql/mysql-pvc.yaml new file mode 100644 index 000000000..16b609282 --- /dev/null +++ b/script/k8s-deployment/mysql/mysql-pvc.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi diff --git a/script/k8s-deployment/mysql/mysql-service.yaml b/script/k8s-deployment/mysql/mysql-service.yaml new file mode 100644 index 000000000..b06779319 --- /dev/null +++ b/script/k8s-deployment/mysql/mysql-service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: mysql +spec: + ports: + - port: 3306 + targetPort: 3306 + selector: + app: mysql diff --git a/script/k8s-deployment/nginx-deployment.yaml b/script/k8s-deployment/nginx-deployment.yaml new file mode 100644 index 000000000..dbdadc158 --- /dev/null +++ b/script/k8s-deployment/nginx-deployment.yaml @@ -0,0 +1,106 @@ +# 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; + } + } + + } diff --git a/script/k8s-deployment/nginx/nginx-config-configmap.yaml b/script/k8s-deployment/nginx/nginx-config-configmap.yaml new file mode 100644 index 000000000..ea742b3f6 --- /dev/null +++ b/script/k8s-deployment/nginx/nginx-config-configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-config +data: + nginx.conf: | + # 你的 nginx.conf 文件内容 diff --git a/script/k8s-deployment/nginx/nginx-deployment.yaml b/script/k8s-deployment/nginx/nginx-deployment.yaml new file mode 100644 index 000000000..5572e8805 --- /dev/null +++ b/script/k8s-deployment/nginx/nginx-deployment.yaml @@ -0,0 +1,34 @@ +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: 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 + volumes: + - name: nginx-config + configMap: + name: nginx-config + - name: nginx-html + hostPath: + path: /Users/yangliu/Desktop/dist-prod + type: Directory diff --git a/script/k8s-deployment/nginx/nginx-service.yaml b/script/k8s-deployment/nginx/nginx-service.yaml new file mode 100644 index 000000000..9363dfe3b --- /dev/null +++ b/script/k8s-deployment/nginx/nginx-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: nginx +spec: + ports: + - port: 80 + targetPort: 80 + - port: 443 + targetPort: 443 + selector: + app: nginx diff --git a/script/k8s-deployment/redis-deployment.yaml b/script/k8s-deployment/redis-deployment.yaml new file mode 100644 index 000000000..dad917b78 --- /dev/null +++ b/script/k8s-deployment/redis-deployment.yaml @@ -0,0 +1,51 @@ +# 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 diff --git a/script/k8s-deployment/redis/redis-deployment.yaml b/script/k8s-deployment/redis/redis-deployment.yaml new file mode 100644 index 000000000..3590ce14b --- /dev/null +++ b/script/k8s-deployment/redis/redis-deployment.yaml @@ -0,0 +1,27 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: redis + namespace: aiedu +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 diff --git a/script/k8s-deployment/redis/redis-pvc.yaml b/script/k8s-deployment/redis/redis-pvc.yaml new file mode 100644 index 000000000..671986fe5 --- /dev/null +++ b/script/k8s-deployment/redis/redis-pvc.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: redis-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi diff --git a/script/k8s-deployment/redis/redis-service.yaml b/script/k8s-deployment/redis/redis-service.yaml new file mode 100644 index 000000000..85f2ca227 --- /dev/null +++ b/script/k8s-deployment/redis/redis-service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: redis +spec: + ports: + - port: 6379 + targetPort: 6379 + selector: + app: redis diff --git a/script/k8s-deployment/server-service.yaml b/script/k8s-deployment/server-service.yaml new file mode 100644 index 000000000..a257ab13d --- /dev/null +++ b/script/k8s-deployment/server-service.yaml @@ -0,0 +1,170 @@ +# 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 + 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 diff --git a/script/k8s-deployment/server/llm-config-configmap.yaml b/script/k8s-deployment/server/llm-config-configmap.yaml new file mode 100644 index 000000000..5a92235fa --- /dev/null +++ b/script/k8s-deployment/server/llm-config-configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: llm-config +data: + llm_config.yml: | + # 你的 llm_config.yml 文件内容 diff --git a/script/k8s-deployment/server/server-service.yaml b/script/k8s-deployment/server/server-service.yaml new file mode 100644 index 000000000..71e813498 --- /dev/null +++ b/script/k8s-deployment/server/server-service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: yudao-server +spec: + ports: + - port: 48080 + targetPort: 48080 + selector: + app: yudao-server