Tasks 5-9: _tier-affinity.tpl + _point-affinity.tpl + values tier 块 + _backend.tpl 三层注入 + instances.yaml 解析 Point 对象。
81 lines
2.5 KiB
Smarty
81 lines
2.5 KiB
Smarty
{{/*
|
|
渲染全局 tier 档位调度 nodeAffinity — 完整 affinity 块(无现成 affinity 的模板用)。
|
|
三层优先级的最底层(点位 nodeName > 点位 nodeAffinity > 全局 tier)。
|
|
|
|
参数:
|
|
role - 服务角色(gateway/sso/ultra/agent/edge/audit/sharedDatastores)
|
|
root - $ (root context)
|
|
*/}}
|
|
{{- define "mixingx.tierAffinity" -}}
|
|
{{- $root := .root -}}
|
|
{{- $cfg := $root.Values.tier -}}
|
|
{{- if and $cfg $cfg.enabled -}}
|
|
{{- $svc := index $cfg.services .role -}}
|
|
{{- if $svc -}}
|
|
{{- $label := $cfg.nodeLabel | default "mixingx.io/tier" -}}
|
|
{{- if eq $svc.mode "required" }}
|
|
affinity:
|
|
nodeAffinity:
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: {{ $label }}
|
|
operator: In
|
|
values:
|
|
{{- range $svc.tiers }}
|
|
- {{ . | quote }}
|
|
{{- end }}
|
|
{{- else if eq $svc.mode "preferred" }}
|
|
affinity:
|
|
nodeAffinity:
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
{{- range $svc.tiers }}
|
|
- weight: 100
|
|
preference:
|
|
matchExpressions:
|
|
- key: {{ $label }}
|
|
operator: In
|
|
values:
|
|
- {{ . | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end -}}
|
|
|
|
{{/* 只渲染 nodeAffinity 子块(供 frontend/postgres 合并 podAffinity 用)*/}}
|
|
{{- define "mixingx.tierNodeAffinity" -}}
|
|
{{- $root := .root -}}
|
|
{{- $cfg := $root.Values.tier -}}
|
|
{{- if and $cfg $cfg.enabled -}}
|
|
{{- $svc := index $cfg.services .role -}}
|
|
{{- if $svc -}}
|
|
{{- $label := $cfg.nodeLabel | default "mixingx.io/tier" -}}
|
|
{{- if eq $svc.mode "required" }}
|
|
nodeAffinity:
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: {{ $label }}
|
|
operator: In
|
|
values:
|
|
{{- range $svc.tiers }}
|
|
- {{ . | quote }}
|
|
{{- end }}
|
|
{{- else if eq $svc.mode "preferred" }}
|
|
nodeAffinity:
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
{{- range $svc.tiers }}
|
|
- weight: 100
|
|
preference:
|
|
matchExpressions:
|
|
- key: {{ $label }}
|
|
operator: In
|
|
values:
|
|
- {{ . | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end -}}
|