refactor(chart): instances 数组改为 agents/edges 字符串数组,模板自动推导资源名

This commit is contained in:
ximenchuifeng committed 2026-06-30 08:27:25 +08:00
1 parent 7854605631
commit 4c031d7cf7
2 files changed
+43 -54

No files matched your search

+27 -14
View File
@@ -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 }}