refactor(chart): instances 数组改为 agents/edges 字符串数组,模板自动推导资源名
This commit is contained in:
1 parent
7854605631
commit
4c031d7cf7
2 files changed
+43
-54
No files matched your search
+27
-14
@@ -1,18 +1,31 @@
|
||||
{{/*
|
||||
四胞胎实例(agent/edge)— 遍历 values.instances 数组
|
||||
每个实例生成:后端 Deployment + 前端 Deployment + 独立 postgres StatefulSet(三者 podAffinity 同节点)
|
||||
|
||||
加/删点位:只改 values.yaml 的 instances 数组,helm upgrade 自动生效。
|
||||
Agent 点位 — 遍历 .Values.agents 数组,每个元素生成完整的三件套
|
||||
生成: 后端 Deployment/Service/ConfigMap/Secret + 前端 Deployment/Service + 独立 Postgres StatefulSet/Service/PVC
|
||||
三者通过 podAffinity 强制同节点
|
||||
*/}}
|
||||
{{- range $inst := .Values.instances }}
|
||||
{{- $root := $ }}
|
||||
# ═══ 实例: {{ $inst.name }} ({{ $inst.description }}) ═══
|
||||
# 1. 后端
|
||||
{{ include "mixingx.backend" (dict "name" $inst.name "image" $inst.image "role" $inst.role "serviceId" $inst.serviceId "database" $inst.database "description" $inst.description "root" $root) }}
|
||||
{{- range $site := .Values.agents }}
|
||||
{{- $instName := printf "agent-%s" $site }}
|
||||
{{- $webName := printf "agent-web-%s" $site }}
|
||||
{{- $dbName := printf "agent-db-%s" $site }}
|
||||
{{- $basePath := printf "/agent-%s" $site }}
|
||||
{{- $description := printf "Agent 实例 %s" $site }}
|
||||
# ═══ 实例: {{ $instName }} ({{ $description }}) ═══
|
||||
{{ include "mixingx.backend" (dict "name" $instName "image" "agent" "role" "agent" "serviceId" $instName "database" $dbName "description" $description "root" $) }}
|
||||
{{ include "mixingx.frontend" (dict "name" $webName "image" "agent-web" "basePath" $basePath "affinity" $instName "root" $) }}
|
||||
{{ include "mixingx.postgres" (dict "name" $instName "database" $dbName "pgStorage" "5Gi" "affinity" true "root" $) }}
|
||||
{{- end }}
|
||||
|
||||
# 2. 前端(亲和到后端同节点)
|
||||
{{ include "mixingx.frontend" (dict "name" $inst.webName "image" $inst.webImage "basePath" $inst.webBasePath "affinity" $inst.name "root" $root) }}
|
||||
|
||||
# 3. 独立 postgres(亲和到后端同节点)
|
||||
{{ include "mixingx.postgres" (dict "name" $inst.name "database" $inst.database "pgStorage" $inst.pgStorage "affinity" true "root" $root) }}
|
||||
{{/*
|
||||
Edge 点位 — 遍历 .Values.edges 数组,逻辑同上
|
||||
*/}}
|
||||
{{- range $site := .Values.edges }}
|
||||
{{- $instName := printf "edge-%s" $site }}
|
||||
{{- $webName := printf "edge-web-%s" $site }}
|
||||
{{- $dbName := printf "edge-db-%s" $site }}
|
||||
{{- $basePath := printf "/edge-%s" $site }}
|
||||
{{- $description := printf "Edge 实例 %s" $site }}
|
||||
# ═══ 实例: {{ $instName }} ({{ $description }}) ═══
|
||||
{{ include "mixingx.backend" (dict "name" $instName "image" "edge" "role" "edge" "serviceId" $instName "database" $dbName "description" $description "root" $) }}
|
||||
{{ include "mixingx.frontend" (dict "name" $webName "image" "edge-web" "basePath" $basePath "affinity" $instName "root" $) }}
|
||||
{{ include "mixingx.postgres" (dict "name" $instName "database" $dbName "pgStorage" "5Gi" "affinity" true "root" $) }}
|
||||
{{- end }}
|
||||
+16
-40
@@ -41,48 +41,24 @@ sharedInfra:
|
||||
# 每个实例生成:后端 Deployment + 前端 Deployment + 独立 postgres StatefulSet
|
||||
# 默认各 1 个,以后按需加(加一行 values + helm upgrade)
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
instances:
|
||||
- name: agent-0
|
||||
image: agent
|
||||
role: agent
|
||||
webName: agent-web-0 # 前端服务名(显式,因为命名不统一:agent-web-0 / ultra-web)
|
||||
webImage: agent-web
|
||||
# 注:webBasePath 不要带尾斜杠!Dockerfile 的 sed `s|/__BASE__|${VITE_BASE_PATH}|g`
|
||||
# 配合 nginx.conf 的 `location /__BASE__/`(本身已带尾斜杠),再带尾斜杠会拼成
|
||||
# /agent-0//(双斜杠)→ 浏览器 ERR_TOO_MANY_REDIRECTS 死循环。
|
||||
# sso/ultra 不受影响(它们的 nginx.conf 用硬编码 /sso/,不走 __BASE__ 占位符)。
|
||||
webBasePath: /agent-0
|
||||
serviceId: agent-0
|
||||
database: agent-db-0
|
||||
pgStorage: 5Gi
|
||||
description: "Agent 实例 0" # Gateway 中文展示名(mixingx.io/description annotation)
|
||||
affinity: true # 前端和 DB 必须和后端同节点
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# 点位配置 — 只写名字,模板自动推导其余字段
|
||||
# 格式: agents/edges 为字符串数组,每个元素为点位后缀
|
||||
# 生成规则:
|
||||
# 后端: {role}-{site} 如 agent-0, agent-beijing
|
||||
# 前端: {role}-web-{site} 如 agent-web-0, agent-web-beijing
|
||||
# 数据库: {role}-db-{site} 如 agent-db-0, agent-db-beijing
|
||||
# basePath: /{role}-{site} 如 /agent-0, /agent-beijing
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
- name: edge-0
|
||||
image: edge
|
||||
role: edge
|
||||
webName: edge-web-0
|
||||
webImage: edge-web
|
||||
webBasePath: /edge-0 # 不带尾斜杠(同上,见 agent-0 注释)
|
||||
serviceId: edge-0
|
||||
database: edge-db-0
|
||||
pgStorage: 5Gi
|
||||
description: "Edge 实例 0"
|
||||
affinity: true
|
||||
agents:
|
||||
- "0"
|
||||
# - beijing
|
||||
# - shanghai
|
||||
|
||||
# 加点位示例(取消注释 + helm upgrade 即生效):
|
||||
# 注意:webBasePath 不能带尾斜杠,否则 Dockerfile sed 拼出双斜杠 → 重定向死循环
|
||||
# - name: agent-beijing
|
||||
# image: agent
|
||||
# role: agent
|
||||
# webName: agent-web-beijing
|
||||
# webImage: agent-web
|
||||
# webBasePath: /agent-beijing
|
||||
# serviceId: agent-beijing
|
||||
# database: agent-db-beijing
|
||||
# pgStorage: 5Gi
|
||||
# description: "北京厂区 注塑车间"
|
||||
# affinity: true
|
||||
edges:
|
||||
- "0"
|
||||
# - guangzhou
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# 类型 B:独立不亲和(sso/ultra)— 后端+前端+独立DB,无亲和,多副本
|
||||
|
||||
Reference in new issue
Block a user