diff --git a/templates/_backend.tpl b/templates/_backend.tpl index 5be18c8..028fe73 100644 --- a/templates/_backend.tpl +++ b/templates/_backend.tpl @@ -11,6 +11,7 @@ serviceId - 业务身份(可选) database - 数据库名(有则生成 PG 连接串,指向 {name}-postgres-service) rbac - 是否需要 serviceAccount(只有 gateway) + description - 中文展示名(可选,写为 mixingx.io/description annotation) root - $ (root context) */}} {{- define "mixingx.backend" -}} @@ -53,13 +54,16 @@ spec: name: {{ .name }}-config - secretRef: name: {{ .name }}-secrets - {{- if .rbac }} env: + # 时区(部署地域覆盖,优先级 > 镜像内 /etc/localtime) + - name: TZ + value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}" + {{- if .rbac }} - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - {{- end }} + {{- end }} livenessProbe: httpGet: path: /health @@ -88,6 +92,10 @@ metadata: mixingx.io/role: {{ .role }} mixingx.io/node-id: {{ .name }} {{- end }} + {{- if and .role (ne .role "gateway") .description }} + annotations: + mixingx.io/description: {{ .description | quote }} + {{- end }} spec: selector: app.kubernetes.io/component: {{ .name }} @@ -123,6 +131,8 @@ data: EDGE_SERVICE_ID: "{{ .serviceId }}" {{- else if hasPrefix "sso" .name }} SSO_SERVICE_ID: "{{ .serviceId }}" + {{- else if hasPrefix "ultra" .name }} + ULTRA_SERVICE_ID: "{{ .serviceId }}" {{- end }} {{- end }} OTEL_EXPORTER_OTLP_ENDPOINT: "{{ $root.Values.sharedInfra.otlp.endpoint }}" diff --git a/templates/_frontend.tpl b/templates/_frontend.tpl index 736f90f..d4f255e 100644 --- a/templates/_frontend.tpl +++ b/templates/_frontend.tpl @@ -52,6 +52,9 @@ spec: containerPort: {{ $port }} protocol: TCP env: + # 时区(部署地域覆盖,优先级 > 镜像内 /etc/localtime) + - name: TZ + value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}" - name: VITE_BASE_PATH value: "{{ .basePath }}" - name: PORT diff --git a/templates/audit.yaml b/templates/audit.yaml index 9252a25..78d026f 100644 --- a/templates/audit.yaml +++ b/templates/audit.yaml @@ -27,6 +27,9 @@ spec: containerPort: {{ .Values.audit.port }} protocol: TCP env: + # 时区(部署地域覆盖) + - name: TZ + value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}" - name: MONGODB_URI value: "mongodb://{{ .Values.sharedInfra.mongo.username }}:{{ .Values.sharedInfra.mongo.password }}@{{ .Values.sharedInfra.mongo.host }}:{{ .Values.sharedInfra.mongo.port }}" - name: MONGODB_DATABASE diff --git a/templates/instance-agent-0.yaml b/templates/instance-agent-0.yaml deleted file mode 100644 index 3ff373e..0000000 --- a/templates/instance-agent-0.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{/* -agent-0 四胞胎:后端 + 前端 + 独立 postgres(三者 podAffinity 同节点) -*/}} -{{- $root := $ }} -# 1. 后端 -{{ include "mixingx.backend" (dict "name" "agent-0" "image" "agent" "role" "agent" "serviceId" "agent-0" "database" "agent-db-0" "root" $root) }} - -# 2. 前端(亲和到 agent-0) -{{ include "mixingx.frontend" (dict "name" "agent-web-0" "image" "agent-web" "basePath" "/agent-0/" "affinity" "agent-0" "root" $root) }} - -# 3. 独立 postgres(亲和到 agent-0) -{{ include "mixingx.postgres" (dict "name" "agent-0" "database" "agent-db-0" "pgStorage" "5Gi" "affinity" true "root" $root) }} diff --git a/templates/instance-edge-0.yaml b/templates/instance-edge-0.yaml deleted file mode 100644 index ba0ff02..0000000 --- a/templates/instance-edge-0.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{/* -edge-0 四胞胎:后端 + 前端 + 独立 postgres(三者 podAffinity 同节点) -*/}} -{{- $root := $ }} -# 1. 后端 -{{ include "mixingx.backend" (dict "name" "edge-0" "image" "edge" "role" "edge" "serviceId" "edge-0" "database" "edge-db-0" "root" $root) }} - -# 2. 前端(亲和到 edge-0) -{{ include "mixingx.frontend" (dict "name" "edge-web-0" "image" "edge-web" "basePath" "/edge-0/" "affinity" "edge-0" "root" $root) }} - -# 3. 独立 postgres(亲和到 edge-0) -{{ include "mixingx.postgres" (dict "name" "edge-0" "database" "edge-db-0" "pgStorage" "5Gi" "affinity" true "root" $root) }} diff --git a/templates/instances.yaml b/templates/instances.yaml new file mode 100644 index 0000000..80d8d64 --- /dev/null +++ b/templates/instances.yaml @@ -0,0 +1,18 @@ +{{/* +四胞胎实例(agent/edge)— 遍历 values.instances 数组 +每个实例生成:后端 Deployment + 前端 Deployment + 独立 postgres StatefulSet(三者 podAffinity 同节点) + +加/删点位:只改 values.yaml 的 instances 数组,helm upgrade 自动生效。 +*/}} +{{- 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) }} + +# 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) }} +{{- end }} diff --git a/templates/mock.yaml b/templates/mock.yaml index d5294d8..098765b 100644 --- a/templates/mock.yaml +++ b/templates/mock.yaml @@ -36,6 +36,10 @@ spec: - name: tcp containerPort: {{ .port }} protocol: TCP + env: + # 时区(部署地域覆盖) + - name: TZ + value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}" --- apiVersion: v1 kind: Service diff --git a/templates/standalone-sso.yaml b/templates/standalone-sso.yaml deleted file mode 100644 index 128a03c..0000000 --- a/templates/standalone-sso.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{/* -sso:后端(×2 副本) + 前端 + 独立 postgres(无亲和) -*/}} -{{- $root := $ }} -# 1. 后端(×2) -{{ include "mixingx.backend" (dict "name" "sso" "image" "sso" "role" "sso" "replicas" 2 "serviceId" "sso" "database" "sso-db" "root" $root) }} - -# 2. 前端(无亲和) -{{ include "mixingx.frontend" (dict "name" "sso-web" "image" "sso-web" "basePath" "/sso/" "root" $root) }} - -# 3. 独立 postgres(无亲和) -{{ include "mixingx.postgres" (dict "name" "sso" "database" "sso-db" "pgStorage" "10Gi" "affinity" false "root" $root) }} diff --git a/templates/standalone-ultra.yaml b/templates/standalone-ultra.yaml deleted file mode 100644 index e60b06d..0000000 --- a/templates/standalone-ultra.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{/* -ultra:后端(×2 副本) + 前端 + 独立 postgres(无亲和) -*/}} -{{- $root := $ }} -# 1. 后端(×2) -{{ include "mixingx.backend" (dict "name" "ultra" "image" "ultra" "role" "ultra" "replicas" 2 "database" "ultra-db" "root" $root) }} - -# 2. 前端 -{{ include "mixingx.frontend" (dict "name" "ultra-web" "image" "ultra-web" "basePath" "/ultra/" "root" $root) }} - -# 3. 独立 postgres -{{ include "mixingx.postgres" (dict "name" "ultra" "database" "ultra-db" "pgStorage" "10Gi" "affinity" false "root" $root) }} diff --git a/templates/standalones.yaml b/templates/standalones.yaml new file mode 100644 index 0000000..185bec6 --- /dev/null +++ b/templates/standalones.yaml @@ -0,0 +1,18 @@ +{{/* +独立实例(sso/ultra)— 遍历 values.standalones 数组 +每个实例生成:后端 Deployment + 前端 Deployment + 独立 postgres StatefulSet(无亲和,多副本) + +与 instances 的差异:无 podAffinity、replicas 可 >1、pgStorage 量级更大。 +*/}} +{{- range $inst := .Values.standalones }} +{{- $root := $ }} +# ═══ 实例: {{ $inst.name }} ({{ $inst.description }}) ═══ +# 1. 后端(多副本) +{{ include "mixingx.backend" (dict "name" $inst.name "image" $inst.image "role" $inst.role "replicas" $inst.replicas "serviceId" $inst.serviceId "database" $inst.database "description" $inst.description "root" $root) }} + +# 2. 前端(无亲和) +{{ include "mixingx.frontend" (dict "name" $inst.webName "image" $inst.webImage "basePath" $inst.webBasePath "root" $root) }} + +# 3. 独立 postgres(无亲和) +{{ include "mixingx.postgres" (dict "name" $inst.name "database" $inst.database "pgStorage" $inst.pgStorage "affinity" false "root" $root) }} +{{- end }} diff --git a/values.yaml b/values.yaml index 452634d..0a16ffd 100644 --- a/values.yaml +++ b/values.yaml @@ -7,6 +7,10 @@ registry: 192.168.1.105:8888/mixingx tag: latest +# 时区(部署地域覆盖):中国 Asia/Shanghai,海外按需改如 America/New_York +# 注入所有容器的 TZ env,覆盖镜像内默认时区(镜像内置 Asia/Shanghai 兜底) +timezone: Asia/Shanghai + # ── 共享基础设施(所有服务连同一个) ── sharedInfra: postgres: # postgres 连接参数(每个独立 postgres 共用) @@ -41,23 +45,40 @@ instances: - name: agent-0 image: agent role: agent + webName: agent-web-0 # 前端服务名(显式,因为命名不统一:agent-web-0 / ultra-web) webImage: agent-web webBasePath: /agent-0/ serviceId: agent-0 database: agent-db-0 pgStorage: 5Gi + description: "Agent 实例 0" # Gateway 中文展示名(mixingx.io/description annotation) affinity: true # 前端和 DB 必须和后端同节点 - name: edge-0 image: edge role: edge + webName: edge-web-0 webImage: edge-web webBasePath: /edge-0/ serviceId: edge-0 database: edge-db-0 pgStorage: 5Gi + description: "Edge 实例 0" affinity: true + # 加点位示例(取消注释 + helm upgrade 即生效): + # - 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 + # ═══════════════════════════════════════════════════════════════ # 类型 B:独立不亲和(sso/ultra)— 后端+前端+独立DB,无亲和,多副本 # 固定数量,不动态添加 @@ -66,21 +87,25 @@ standalones: - name: sso image: sso role: sso + webName: sso-web webImage: sso-web webBasePath: /sso/ serviceId: sso database: sso-db pgStorage: 10Gi + description: "统一登录" replicas: 2 affinity: false - name: ultra image: ultra role: ultra + webName: ultra-web webImage: ultra-web webBasePath: /ultra/ database: ultra-db pgStorage: 10Gi + description: "Ultra 看板" replicas: 2 affinity: false @@ -139,3 +164,5 @@ mocks: ingress: enabled: true domain: app.mixingx.local + gatewayService: gateway-service # 所有流量 → gateway,由 gateway 动态路由 + gatewayPort: 8080