(openspec 变更 edge-agent-error-audit-retention;配套后端 AUDIT_ERROR_RETENTION_MONTHS) - values.yaml: audit.errorRetentionMonths 默认 3(操作流水 retentionMonths=6 不变) - templates/audit.yaml: deployment 透传 AUDIT_ERROR_RETENTION_MONTHS 注: 版本号 bump 随发布流程另行执行。
140 lines
5.1 KiB
YAML
140 lines
5.1 KiB
YAML
{{- if .Values.audit.enabled }}
|
|
{{- $root := $ }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: audit-deployment
|
|
labels:
|
|
app.kubernetes.io/name: mixingx
|
|
app.kubernetes.io/component: audit
|
|
spec:
|
|
replicas: {{ .Values.audit.replicas | default 2 }}
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/component: audit
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/component: audit
|
|
spec:
|
|
{{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
|
|
{{- with $.Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
containers:
|
|
- name: audit
|
|
image: "{{ .Values.registry }}/{{ .Values.images.audit.repository | default "audit" }}:{{ .Values.images.audit.tag | default .Values.tag | default "latest" }}"
|
|
imagePullPolicy: IfNotPresent
|
|
ports:
|
|
- name: http
|
|
containerPort: {{ .Values.audit.port }}
|
|
protocol: TCP
|
|
env:
|
|
- name: TZ
|
|
value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}"
|
|
- name: PORT
|
|
value: "{{ .Values.audit.port }}"
|
|
- name: HOST
|
|
value: "0.0.0.0"
|
|
# PostgreSQL — 凭据通过 Secret 注入
|
|
- name: AUDIT_PG_URI
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: audit-secrets
|
|
key: AUDIT_PG_URI
|
|
- name: AUDIT_PG_TIMEZONE
|
|
value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}"
|
|
# 数据保留月数(按自然月清理分区;operations 表)
|
|
- name: AUDIT_RETENTION_MONTHS
|
|
value: "{{ .Values.audit.retentionMonths | default 6 }}"
|
|
# 错误流水独立保留月数(errors 表,分表独立清除)
|
|
- name: AUDIT_ERROR_RETENTION_MONTHS
|
|
value: "{{ .Values.audit.errorRetentionMonths | default 3 }}"
|
|
# MQTT broker
|
|
- name: AUDIT_MQTT_BROKER_URL
|
|
value: "mqtt://{{ .Values.audit.mqtt.brokerHost }}:{{ .Values.audit.mqtt.brokerPort }}"
|
|
# POD_NAME 供 config.ts 自动生成 mixingx-audit-sub-{podName} clientId
|
|
- name: POD_NAME
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.name
|
|
- name: AUDIT_MQTT_SHARED_GROUP
|
|
value: "mixingx-audit"
|
|
# NanoMQ 管理 API — 凭据通过 Secret 注入
|
|
- name: AUDIT_MQTT_MANAGEMENT_URL
|
|
value: "http://{{ .Values.audit.mqtt.brokerHost }}:{{ .Values.audit.mqtt.managementPort }}"
|
|
- name: AUDIT_MQTT_MANAGEMENT_USERNAME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: audit-secrets
|
|
key: AUDIT_MQTT_MANAGEMENT_USERNAME
|
|
- name: AUDIT_MQTT_MANAGEMENT_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: audit-secrets
|
|
key: AUDIT_MQTT_MANAGEMENT_PASSWORD
|
|
# 消费队列/并发
|
|
- name: AUDIT_CONSUME_QUEUE_CAPACITY
|
|
value: "{{ .Values.audit.consume.queueCapacity }}"
|
|
- name: AUDIT_CONSUME_QUEUE_MAX_WAIT_MS
|
|
value: "{{ .Values.audit.consume.queueMaxWaitMs }}"
|
|
- name: AUDIT_DB_WRITE_TIMEOUT_MS
|
|
value: "{{ .Values.audit.consume.dbWriteTimeoutMs }}"
|
|
- name: AUDIT_CONSUME_CONCURRENCY
|
|
value: "{{ .Values.audit.consume.concurrency }}"
|
|
# JWT 鉴权:变量名沿用 JWT_JWKS_URI(代码契约),实际语义是 SSO base URL,
|
|
# 后端用它拼 /api/sso/users/info 间接校验 token
|
|
- name: JWT_JWKS_URI
|
|
value: "{{ .Values.audit.jwt.ssoBaseUrl }}"
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health/live
|
|
port: http
|
|
initialDelaySeconds: 15
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health/ready
|
|
port: http
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: audit-service
|
|
labels:
|
|
app.kubernetes.io/name: mixingx
|
|
app.kubernetes.io/component: audit
|
|
mixingx.io/role: audit
|
|
mixingx.io/node-id: audit
|
|
annotations:
|
|
mixingx.io/description: "审计服务"
|
|
spec:
|
|
selector:
|
|
app.kubernetes.io/component: audit
|
|
ports:
|
|
- name: http
|
|
port: {{ .Values.audit.port }}
|
|
targetPort: http
|
|
protocol: TCP
|
|
---
|
|
# ===== Audit Secrets =====
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: audit-secrets
|
|
labels:
|
|
app.kubernetes.io/name: mixingx
|
|
app.kubernetes.io/component: audit
|
|
type: Opaque
|
|
stringData:
|
|
AUDIT_PG_URI: "postgresql://{{ $root.Values.sharedInfra.postgres.username }}:{{ $root.Values.sharedInfra.postgres.password }}@{{ .Values.audit.database }}-postgres-service:{{ $root.Values.sharedInfra.postgres.port }}/{{ .Values.audit.database }}"
|
|
AUDIT_MQTT_MANAGEMENT_USERNAME: "{{ .Values.audit.mqtt.managementUsername }}"
|
|
AUDIT_MQTT_MANAGEMENT_PASSWORD: "{{ .Values.audit.mqtt.managementPassword }}"
|
|
{{- end }}
|