feat(mixingx-agent-unit): 添加后端配置模板并集成Ultra服务发现
- 新增 `mixingx-unit.backendConfigData` 模板定义,统一管理后端服务配置项 - 在 unit.yaml 中添加配置校验和注解,确保配置变更时触发滚动更新 - 将硬编码的 ConfigMap 配置替换为模板引用,提高维护性 - 添加 Ultra 服务发现配置,默认指向 ultra-service:8080 - 支持多 Ultra 部署场景下的地址覆盖能力
This commit is contained in:
1 parent
6fcb0340ed
commit
f74201a7ef
3 files changed
+33
-18
No files matched your search
@@ -49,3 +49,28 @@ affinity:
|
||||
topologyKey: kubernetes.io/hostname
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "mixingx-unit.backendConfigData" -}}
|
||||
{{- $name := include "mixingx-unit.name" . -}}
|
||||
{{- $serviceId := include "mixingx-unit.serviceId" . -}}
|
||||
{{- $pgHost := printf "%s-postgres-service" $name -}}
|
||||
HTTP_PORTS: "{{ .Values.ports.backend }}"
|
||||
REDIS_HOST: "{{ .Values.sharedInfra.redis.host }}"
|
||||
REDIS_PORT: "{{ .Values.sharedInfra.redis.port }}"
|
||||
POSTGRESQL_HOST: "{{ $pgHost }}"
|
||||
POSTGRESQL_PORT: "{{ .Values.sharedInfra.postgres.port }}"
|
||||
POSTGRESQL_USERNAME: "{{ .Values.sharedInfra.postgres.username }}"
|
||||
MESSAGING_HOST: "{{ .Values.sharedInfra.rabbitmq.host }}"
|
||||
MESSAGING_PORT: "{{ .Values.sharedInfra.rabbitmq.port }}"
|
||||
MESSAGING_USERNAME: "{{ .Values.sharedInfra.rabbitmq.username }}"
|
||||
services__gateway__http__0: "http://gateway-service:8080"
|
||||
services__ultra__http__0: "http://{{ .Values.sharedInfra.ultra.host }}:{{ .Values.sharedInfra.ultra.port }}"
|
||||
AGENT_SERVICE_ID: "{{ $serviceId }}"
|
||||
{{- if .Values.phaseType }}
|
||||
AGENT_PHASE_TYPE: "{{ .Values.phaseType }}"
|
||||
{{- end }}
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: "{{ .Values.sharedInfra.otlp.endpoint }}"
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: "{{ .Values.sharedInfra.otlp.protocol }}"
|
||||
OTEL_SERVICE_NAME: "{{ $name }}"
|
||||
ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
|
||||
{{- end -}}
|
||||
@@ -22,6 +22,8 @@ spec:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: {{ $name }}
|
||||
annotations:
|
||||
checksum/config: {{ include "mixingx-unit.backendConfigData" . | sha256sum }}
|
||||
spec:
|
||||
{{ include "mixingx-unit.backendScheduling" . | nindent 6 }}
|
||||
containers:
|
||||
@@ -86,24 +88,7 @@ kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ $name }}-config
|
||||
data:
|
||||
HTTP_PORTS: "{{ .Values.ports.backend }}"
|
||||
REDIS_HOST: "{{ .Values.sharedInfra.redis.host }}"
|
||||
REDIS_PORT: "{{ .Values.sharedInfra.redis.port }}"
|
||||
POSTGRESQL_HOST: "{{ $pgHost }}"
|
||||
POSTGRESQL_PORT: "{{ .Values.sharedInfra.postgres.port }}"
|
||||
POSTGRESQL_USERNAME: "{{ .Values.sharedInfra.postgres.username }}"
|
||||
MESSAGING_HOST: "{{ .Values.sharedInfra.rabbitmq.host }}"
|
||||
MESSAGING_PORT: "{{ .Values.sharedInfra.rabbitmq.port }}"
|
||||
MESSAGING_USERNAME: "{{ .Values.sharedInfra.rabbitmq.username }}"
|
||||
services__gateway__http__0: "http://gateway-service:8080"
|
||||
AGENT_SERVICE_ID: "{{ $serviceId }}"
|
||||
{{- if .Values.phaseType }}
|
||||
AGENT_PHASE_TYPE: "{{ .Values.phaseType }}"
|
||||
{{- end }}
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: "{{ .Values.sharedInfra.otlp.endpoint }}"
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: "{{ .Values.sharedInfra.otlp.protocol }}"
|
||||
OTEL_SERVICE_NAME: "{{ $name }}"
|
||||
ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
|
||||
{{- include "mixingx-unit.backendConfigData" . | nindent 2 }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
|
||||
@@ -36,6 +36,11 @@ nodeName: ""
|
||||
nodeSelector: {}
|
||||
|
||||
sharedInfra:
|
||||
# Agent 侧服务发现注入的 Ultra 地址(services__ultra__http__0)。
|
||||
# 默认指向平台级 Ultra;未来多 Ultra 部署时在对应 agent 的 values 覆盖 host 即可。
|
||||
ultra:
|
||||
host: ultra-service
|
||||
port: 8080
|
||||
postgres:
|
||||
username: postgres
|
||||
password: "Admin12345"
|
||||
|
||||
Reference in new issue
Block a user