diff --git a/Chart.yaml b/Chart.yaml index b5151f3..4493167 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: mixingx description: MixingX 全栈部署 Helm Chart(替代 Aspire publish) type: application -version: 1.1.0 +version: 1.2.0 appVersion: "1.0.1" diff --git a/templates/_frontend.tpl b/templates/_frontend.tpl index d4f255e..97e6ac3 100644 --- a/templates/_frontend.tpl +++ b/templates/_frontend.tpl @@ -33,8 +33,10 @@ spec: labels: app.kubernetes.io/component: {{ .name }} spec: - {{- if .affinity }} - # 四胞胎:前端必须和后端同节点 + {{- if .nodeName }} + nodeName: {{ .nodeName }} + {{- else if .affinity }} + # 四胞胎:前端必须和后端同节点(podAffinity + 点位/tier nodeAffinity 合并到同一 affinity 块) affinity: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -42,6 +44,15 @@ spec: matchLabels: app.kubernetes.io/component: {{ .affinity }} topologyKey: kubernetes.io/hostname + {{- if .pointAffinity }} + {{ include "mixingx.pointNodeAffinity" (dict "affinity" .pointAffinity "root" $root) }} + {{- else if and $root.Values.tier $root.Values.tier.enabled }} + {{ include "mixingx.tierNodeAffinity" (dict "role" .tierRole "root" $root) }} + {{- end }} + {{- else if .pointAffinity }} + {{ include "mixingx.pointAffinity" (dict "affinity" .pointAffinity "root" $root) }} + {{- else if and $root.Values.tier $root.Values.tier.enabled }} + {{ include "mixingx.tierAffinity" (dict "role" .tierRole "root" $root) }} {{- end }} containers: - name: {{ .name }} diff --git a/templates/_postgres.tpl b/templates/_postgres.tpl index a4c964f..9faf6c6 100644 --- a/templates/_postgres.tpl +++ b/templates/_postgres.tpl @@ -40,8 +40,10 @@ spec: labels: app.kubernetes.io/component: {{ .name }}-postgres spec: - {{- if .affinity }} - # 四胞胎:postgres 必须和后端 Pod 同节点 + {{- if .nodeName }} + nodeName: {{ .nodeName }} + {{- else if .affinity }} + # 四胞胎:postgres 必须和后端 Pod 同节点(podAffinity + 点位/tier nodeAffinity 合并到同一 affinity 块) affinity: podAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -49,6 +51,15 @@ spec: matchLabels: app.kubernetes.io/component: {{ .name }} topologyKey: kubernetes.io/hostname + {{- if .pointAffinity }} + {{ include "mixingx.pointNodeAffinity" (dict "affinity" .pointAffinity "root" $root) }} + {{- else if and $root.Values.tier $root.Values.tier.enabled }} + {{ include "mixingx.tierNodeAffinity" (dict "role" .tierRole "root" $root) }} + {{- end }} + {{- else if .pointAffinity }} + {{ include "mixingx.pointAffinity" (dict "affinity" .pointAffinity "root" $root) }} + {{- else if and $root.Values.tier $root.Values.tier.enabled }} + {{ include "mixingx.tierAffinity" (dict "role" .tierRole "root" $root) }} {{- end }} containers: - name: postgres diff --git a/templates/audit.yaml b/templates/audit.yaml index 78d026f..a635553 100644 --- a/templates/audit.yaml +++ b/templates/audit.yaml @@ -18,6 +18,7 @@ spec: labels: app.kubernetes.io/component: audit spec: + {{ include "mixingx.tierAffinity" (dict "role" "audit" "root" $) }} containers: - name: audit image: "{{ .Values.registry }}/{{ .Values.audit.image }}:{{ .Values.tag | default "latest" }}" diff --git a/templates/shared-infra.yaml b/templates/shared-infra.yaml index abf39bb..3fac2aa 100644 --- a/templates/shared-infra.yaml +++ b/templates/shared-infra.yaml @@ -33,6 +33,7 @@ spec: labels: app.kubernetes.io/component: {{ .name }} spec: + {{ include "mixingx.tierAffinity" (dict "role" "sharedDatastores" "root" $root) }} containers: - name: {{ .name }} image: {{ .image }} diff --git a/templates/standalones.yaml b/templates/standalones.yaml index 185bec6..daed1f7 100644 --- a/templates/standalones.yaml +++ b/templates/standalones.yaml @@ -10,9 +10,9 @@ # 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) }} +# 2. 前端(无 podAffinity,走 tier nodeAffinity) +{{ include "mixingx.frontend" (dict "name" $inst.webName "image" $inst.webImage "basePath" $inst.webBasePath "tierRole" $inst.role "root" $root) }} -# 3. 独立 postgres(无亲和) -{{ include "mixingx.postgres" (dict "name" $inst.name "database" $inst.database "pgStorage" $inst.pgStorage "affinity" false "root" $root) }} +# 3. 独立 postgres(无 podAffinity,走 tier nodeAffinity) +{{ include "mixingx.postgres" (dict "name" $inst.name "database" $inst.database "pgStorage" $inst.pgStorage "affinity" false "tierRole" $inst.role "root" $root) }} {{- end }}