feat(mixingx-audit): chart 自包含重做(audit-db Postgres、audit-nanomq、audit-web;JWT 改 SSO base URL;storage/retention 参数)
This commit is contained in:
1 parent
6fcb0340ed
commit
c3fbbb0434
6 files changed
+225
-17
No files matched your search
@@ -1,3 +1,7 @@
|
|||||||
|
{{- define "mixingx-audit.storageClassName" -}}
|
||||||
|
{{- .Values.storage.className | default "local-path" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{- define "mixingx-audit.tierAffinity" -}}
|
{{- define "mixingx-audit.tierAffinity" -}}
|
||||||
{{- $root := .root -}}
|
{{- $root := .root -}}
|
||||||
{{- $role := .role -}}
|
{{- $role := .role -}}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
{{- if .Values.audit.enabled }}
|
||||||
|
{{- $root := $ }}
|
||||||
|
---
|
||||||
|
# ===== Audit 专属 PostgreSQL(ADR-0065:随 audit chart 发布,不进共享 infra) =====
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.audit.database }}-postgres
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: mixingx
|
||||||
|
app.kubernetes.io/component: {{ .Values.audit.database }}-postgres
|
||||||
|
spec:
|
||||||
|
serviceName: {{ .Values.audit.database }}-postgres-service
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/component: {{ .Values.audit.database }}-postgres
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- metadata:
|
||||||
|
name: data
|
||||||
|
annotations:
|
||||||
|
helm.sh/resource-policy: keep
|
||||||
|
spec:
|
||||||
|
accessModes: ["ReadWriteOnce"]
|
||||||
|
storageClassName: {{ include "mixingx-audit.storageClassName" $root }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.audit.pgStorage | default "5Gi" }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/component: {{ .Values.audit.database }}-postgres
|
||||||
|
spec:
|
||||||
|
{{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }}
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
value: "{{ $root.Values.sharedInfra.postgres.password }}"
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
value: "{{ .Values.audit.database }}"
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
value: "{{ $root.Values.sharedInfra.postgres.username }}"
|
||||||
|
- name: PGDATA
|
||||||
|
value: /var/lib/postgresql/data/pgdata
|
||||||
|
ports:
|
||||||
|
- name: tcp
|
||||||
|
containerPort: {{ $root.Values.sharedInfra.postgres.port }}
|
||||||
|
protocol: TCP
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.audit.database }}-postgres-service
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: mixingx
|
||||||
|
app.kubernetes.io/component: {{ .Values.audit.database }}-postgres
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app.kubernetes.io/component: {{ .Values.audit.database }}-postgres
|
||||||
|
ports:
|
||||||
|
- name: tcp
|
||||||
|
port: {{ $root.Values.sharedInfra.postgres.port }}
|
||||||
|
targetPort: tcp
|
||||||
|
protocol: TCP
|
||||||
|
{{- end }}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
{{- if .Values.audit.enabled }}
|
||||||
|
{{- $root := $ }}
|
||||||
|
---
|
||||||
|
# ===== 中心 Audit Broker(ADR-0048;ADR-0065:随 audit chart 发布) =====
|
||||||
|
# 无状态 Deployment:ADR-0049 实时可丢语义,broker 不做消息持久化。
|
||||||
|
# 不打 mixingx.io/role 标签 — 不参与 gateway 服务发现。
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: audit-nanomq
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: mixingx
|
||||||
|
app.kubernetes.io/component: audit-nanomq
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/component: audit-nanomq
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/component: audit-nanomq
|
||||||
|
spec:
|
||||||
|
{{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
|
||||||
|
containers:
|
||||||
|
- name: nanomq
|
||||||
|
image: {{ .Values.audit.mqtt.image | default "emqx/nanomq:0.25.2-2" }}
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command: ["/bin/sh"]
|
||||||
|
args:
|
||||||
|
- "-c"
|
||||||
|
- |
|
||||||
|
cat > /etc/nanomq.conf <<EOF
|
||||||
|
mqtt {
|
||||||
|
allow_anonymous = true
|
||||||
|
max_mqueue_len = 128
|
||||||
|
}
|
||||||
|
http_server {
|
||||||
|
enable = true
|
||||||
|
port = {{ .Values.audit.mqtt.managementPort }}
|
||||||
|
username = "{{ .Values.audit.mqtt.managementUsername }}"
|
||||||
|
password = "{{ .Values.audit.mqtt.managementPassword }}"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
exec nanomq start --conf /etc/nanomq.conf
|
||||||
|
ports:
|
||||||
|
- name: mqtt
|
||||||
|
containerPort: {{ .Values.audit.mqtt.brokerPort }}
|
||||||
|
protocol: TCP
|
||||||
|
- name: management
|
||||||
|
containerPort: {{ .Values.audit.mqtt.managementPort }}
|
||||||
|
protocol: TCP
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ .Values.audit.mqtt.brokerHost }}
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: mixingx
|
||||||
|
app.kubernetes.io/component: audit-nanomq
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app.kubernetes.io/component: audit-nanomq
|
||||||
|
ports:
|
||||||
|
- name: mqtt
|
||||||
|
port: {{ .Values.audit.mqtt.brokerPort }}
|
||||||
|
targetPort: mqtt
|
||||||
|
protocol: TCP
|
||||||
|
- name: management
|
||||||
|
port: {{ .Values.audit.mqtt.managementPort }}
|
||||||
|
targetPort: management
|
||||||
|
protocol: TCP
|
||||||
|
{{- end }}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
{{- if .Values.audit.enabled }}
|
||||||
|
{{- $root := $ }}
|
||||||
|
---
|
||||||
|
# ===== Audit 前端(nginx 静态,生产构建 base 固定 /audit/) =====
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: audit-web-deployment
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: mixingx
|
||||||
|
app.kubernetes.io/component: audit-web
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.audit.replicas | default 2 }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/component: audit-web
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/component: audit-web
|
||||||
|
spec:
|
||||||
|
{{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
|
||||||
|
containers:
|
||||||
|
- name: audit-web
|
||||||
|
image: "{{ .Values.registry }}/{{ .Values.images.auditWeb.repository | default "audit-web" }}:{{ .Values.images.auditWeb.tag | default .Values.tag | default "latest" }}"
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 80
|
||||||
|
protocol: TCP
|
||||||
|
env:
|
||||||
|
- name: TZ
|
||||||
|
value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}"
|
||||||
|
- name: VITE_BASE_PATH
|
||||||
|
value: "/audit"
|
||||||
|
- name: PORT
|
||||||
|
value: "80"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: audit-web-service
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: mixingx
|
||||||
|
app.kubernetes.io/component: audit-web
|
||||||
|
mixingx.io/role: web
|
||||||
|
mixingx.io/node-id: audit-web
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app.kubernetes.io/component: audit-web
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 80
|
||||||
|
targetPort: http
|
||||||
|
protocol: TCP
|
||||||
|
{{- end }}
|
||||||
@@ -42,6 +42,9 @@ spec:
|
|||||||
key: AUDIT_PG_URI
|
key: AUDIT_PG_URI
|
||||||
- name: AUDIT_PG_TIMEZONE
|
- name: AUDIT_PG_TIMEZONE
|
||||||
value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}"
|
value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}"
|
||||||
|
# 数据保留月数(按自然月清理分区)
|
||||||
|
- name: AUDIT_RETENTION_MONTHS
|
||||||
|
value: "{{ .Values.audit.retentionMonths | default 6 }}"
|
||||||
# MQTT broker
|
# MQTT broker
|
||||||
- name: AUDIT_MQTT_BROKER_URL
|
- name: AUDIT_MQTT_BROKER_URL
|
||||||
value: "mqtt://{{ .Values.audit.mqtt.brokerHost }}:{{ .Values.audit.mqtt.brokerPort }}"
|
value: "mqtt://{{ .Values.audit.mqtt.brokerHost }}:{{ .Values.audit.mqtt.brokerPort }}"
|
||||||
@@ -74,18 +77,10 @@ spec:
|
|||||||
value: "{{ .Values.audit.consume.dbWriteTimeoutMs }}"
|
value: "{{ .Values.audit.consume.dbWriteTimeoutMs }}"
|
||||||
- name: AUDIT_CONSUME_CONCURRENCY
|
- name: AUDIT_CONSUME_CONCURRENCY
|
||||||
value: "{{ .Values.audit.consume.concurrency }}"
|
value: "{{ .Values.audit.consume.concurrency }}"
|
||||||
# JWT
|
# JWT 鉴权:变量名沿用 JWT_JWKS_URI(代码契约),实际语义是 SSO base URL,
|
||||||
- name: JWT_ISSUER
|
# 后端用它拼 /api/sso/users/info 间接校验 token
|
||||||
value: "{{ .Values.audit.jwt.issuer }}"
|
|
||||||
- name: JWT_AUDIENCE
|
|
||||||
value: "{{ .Values.audit.jwt.audience }}"
|
|
||||||
- name: JWT_JWKS_URI
|
- name: JWT_JWKS_URI
|
||||||
value: "{{ .Values.audit.jwt.jwksUri }}"
|
value: "{{ .Values.audit.jwt.ssoBaseUrl }}"
|
||||||
# OpenTelemetry
|
|
||||||
- name: OTEL_EXPORTER_OTLP_ENDPOINT
|
|
||||||
value: "{{ $root.Values.sharedInfra.otlp.endpoint }}"
|
|
||||||
- name: OTEL_SERVICE_NAME
|
|
||||||
value: "audit"
|
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /health/live
|
path: /health/live
|
||||||
@@ -110,6 +105,8 @@ metadata:
|
|||||||
app.kubernetes.io/component: audit
|
app.kubernetes.io/component: audit
|
||||||
mixingx.io/role: audit
|
mixingx.io/role: audit
|
||||||
mixingx.io/node-id: audit
|
mixingx.io/node-id: audit
|
||||||
|
annotations:
|
||||||
|
mixingx.io/description: "审计服务"
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app.kubernetes.io/component: audit
|
app.kubernetes.io/component: audit
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ registry: 192.168.1.105:8888/mixingx
|
|||||||
tag: latest
|
tag: latest
|
||||||
timezone: Asia/Shanghai
|
timezone: Asia/Shanghai
|
||||||
|
|
||||||
|
storage:
|
||||||
|
className: local-path
|
||||||
|
|
||||||
sharedInfra:
|
sharedInfra:
|
||||||
postgres:
|
postgres:
|
||||||
image: docker.io/library/postgres:17
|
image: docker.io/library/postgres:17
|
||||||
@@ -18,18 +21,19 @@ audit:
|
|||||||
replicas: 2
|
replicas: 2
|
||||||
database: audit-db
|
database: audit-db
|
||||||
pgStorage: 5Gi
|
pgStorage: 5Gi
|
||||||
# MQTT broker (中心 Audit NanoMQ)
|
# 数据保留月数,按完整自然月清理分区(后端 AUDIT_RETENTION_MONTHS)
|
||||||
|
retentionMonths: 6
|
||||||
|
# JWT 鉴权:后端通过 SSO /api/sso/users/info 间接校验 token,这里配置 SSO base URL
|
||||||
|
jwt:
|
||||||
|
ssoBaseUrl: "http://sso-service:8080"
|
||||||
|
# 中心 Audit Broker(ADR-0048)与 audit 专属 PostgreSQL 随本 chart 发布(ADR-0065)
|
||||||
mqtt:
|
mqtt:
|
||||||
|
image: "emqx/nanomq:0.25.2-2"
|
||||||
brokerHost: "audit-nanomq-service"
|
brokerHost: "audit-nanomq-service"
|
||||||
brokerPort: 1883
|
brokerPort: 1883
|
||||||
managementPort: 8081
|
managementPort: 8081
|
||||||
managementUsername: "admin"
|
managementUsername: "admin"
|
||||||
managementPassword: "public"
|
managementPassword: "public"
|
||||||
# JWT 鉴权(通过 SSO JWKS)
|
|
||||||
jwt:
|
|
||||||
issuer: "mixingx-sso"
|
|
||||||
audience: "mixingx-audit"
|
|
||||||
jwksUri: "http://sso-service:5100/.well-known/jwks.json"
|
|
||||||
# 消费队列/并发配置
|
# 消费队列/并发配置
|
||||||
consume:
|
consume:
|
||||||
queueCapacity: 128
|
queueCapacity: 128
|
||||||
@@ -41,6 +45,9 @@ images:
|
|||||||
audit:
|
audit:
|
||||||
repository: audit
|
repository: audit
|
||||||
tag: ""
|
tag: ""
|
||||||
|
auditWeb:
|
||||||
|
repository: audit-web
|
||||||
|
tag: ""
|
||||||
|
|
||||||
tier:
|
tier:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|||||||
Reference in new issue
Block a user