feat: CI/CD 全链路(Drone pipeline + Helm chart + Dockerfile)
重大变更:
- .drone.yml: 4 步 pipeline(submodule init → build 12 镜像 → helm deploy → verify)
- mixingx-chart/: 手写 Helm chart(模式 3,替代 aspire publish)
- 独立 postgres(每服务一个,不再共享)
- 四胞胎架构(agent/edge: 后端+前端+DB podAffinity 同节点)
- pgAdmin(在 K3s 内,管理所有 postgres)
- Aspire Dashboard(OTLP 遥测接收端)
- Dockerfile: 全部服务已补齐(含 gateway/audit 新增)
- apphost.cs: opcua mock publish 模式改 AddDockerfile
- patch-persistence.sh: emptyDir → PVC patch(备用)
submodule 指针更新:
- mixingx.sso: Dockerfile 精准 COPY
- mixingx.edge: opcua Dockerfile 新增
- eau.ultra: MigrateAsync 无条件执行
- mixingx.audit: Dockerfile 新增
- mixingx.gateway: Dockerfile 新增
镜像 tag 规则: {分支}-{时间戳}-[{tag}]
This commit is contained in:
commit
f69c4161b5
19 files changed
+975
No files matched your search
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: mixingx
|
||||
description: MixingX 全栈部署 Helm Chart(替代 Aspire publish)
|
||||
type: application
|
||||
version: 1.0.0
|
||||
appVersion: "1.0.1"
|
||||
@@ -0,0 +1,153 @@
|
||||
{{/*
|
||||
公共模板:后端 Deployment + Service + ConfigMap + Secret
|
||||
连接串指向独立 postgres({name}-postgres-service)
|
||||
|
||||
参数:
|
||||
name - 服务名
|
||||
image - 镜像名
|
||||
port - 端口(默认 8080)
|
||||
role - mixingx.io/role
|
||||
replicas - 副本数(默认 1)
|
||||
serviceId - 业务身份(可选)
|
||||
database - 数据库名(有则生成 PG 连接串,指向 {name}-postgres-service)
|
||||
rbac - 是否需要 serviceAccount(只有 gateway)
|
||||
root - $ (root context)
|
||||
*/}}
|
||||
{{- define "mixingx.backend" -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $port := .port | default 8080 -}}
|
||||
{{- $pgHost := printf "%s-postgres-service" .name -}}
|
||||
---
|
||||
# Deployment: {{ .name }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .name }}-deployment
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/instance: {{ $root.Release.Name }}
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
spec:
|
||||
replicas: {{ .replicas | default 1 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
spec:
|
||||
{{- if .rbac }}
|
||||
serviceAccountName: gateway-sa
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ .name }}
|
||||
image: {{ $root.Values.registry }}/{{ .image }}:{{ $root.Values.tag | default "latest" }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ $port }}
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: {{ .name }}-config
|
||||
- secretRef:
|
||||
name: {{ .name }}-secrets
|
||||
{{- if .rbac }}
|
||||
env:
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
{{- end }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 30
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /alive
|
||||
port: http
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
|
||||
---
|
||||
# Service: {{ .name }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .name }}-service
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
{{- if and .role (ne .role "gateway") }}
|
||||
mixingx.io/role: {{ .role }}
|
||||
mixingx.io/node-id: {{ .name }}
|
||||
{{- end }}
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ $port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
|
||||
---
|
||||
# ConfigMap: {{ .name }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ .name }}-config
|
||||
data:
|
||||
HTTP_PORTS: "{{ $port }}"
|
||||
REDIS_HOST: "{{ $root.Values.sharedInfra.redis.host }}"
|
||||
REDIS_PORT: "{{ $root.Values.sharedInfra.redis.port }}"
|
||||
POSTGRESQL_HOST: "{{ $pgHost }}"
|
||||
POSTGRESQL_PORT: "{{ $root.Values.sharedInfra.postgres.port }}"
|
||||
POSTGRESQL_USERNAME: "{{ $root.Values.sharedInfra.postgres.username }}"
|
||||
MESSAGING_HOST: "{{ $root.Values.sharedInfra.rabbitmq.host }}"
|
||||
MESSAGING_PORT: "{{ $root.Values.sharedInfra.rabbitmq.port }}"
|
||||
MESSAGING_USERNAME: "{{ $root.Values.sharedInfra.rabbitmq.username }}"
|
||||
{{- if not .rbac }}
|
||||
services__gateway__http__0: "http://gateway-service:8080"
|
||||
{{- end }}
|
||||
{{- if .serviceId }}
|
||||
{{- if hasPrefix "agent" .name }}
|
||||
AGENT_SERVICE_ID: "{{ .serviceId }}"
|
||||
{{- else if hasPrefix "edge" .name }}
|
||||
EDGE_SERVICE_ID: "{{ .serviceId }}"
|
||||
{{- else if hasPrefix "sso" .name }}
|
||||
SSO_SERVICE_ID: "{{ .serviceId }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: "{{ $root.Values.sharedInfra.otlp.endpoint }}"
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: "{{ $root.Values.sharedInfra.otlp.protocol }}"
|
||||
OTEL_SERVICE_NAME: "{{ .name }}"
|
||||
ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
|
||||
|
||||
---
|
||||
# Secret: {{ .name }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ .name }}-secrets
|
||||
type: Opaque
|
||||
stringData:
|
||||
ConnectionStrings__redis: "{{ $root.Values.sharedInfra.redis.host }}:{{ $root.Values.sharedInfra.redis.port }},password={{ $root.Values.sharedInfra.redis.password }}"
|
||||
REDIS_PASSWORD: "{{ $root.Values.sharedInfra.redis.password }}"
|
||||
REDIS_URI: "redis://:{{ $root.Values.sharedInfra.redis.password }}@{{ $root.Values.sharedInfra.redis.host }}:{{ $root.Values.sharedInfra.redis.port }}"
|
||||
{{- if .database }}
|
||||
ConnectionStrings__PostgreSQL: "Host={{ $pgHost }};Port={{ $root.Values.sharedInfra.postgres.port }};Username={{ $root.Values.sharedInfra.postgres.username }};Password={{ $root.Values.sharedInfra.postgres.password }};Database={{ .database }}"
|
||||
POSTGRESQL_PASSWORD: "{{ $root.Values.sharedInfra.postgres.password }}"
|
||||
POSTGRESQL_URI: "postgresql://{{ $root.Values.sharedInfra.postgres.username }}:{{ $root.Values.sharedInfra.postgres.password }}@{{ $pgHost }}:{{ $root.Values.sharedInfra.postgres.port }}/{{ .database }}"
|
||||
POSTGRESQL_DATABASENAME: "{{ .database }}"
|
||||
{{- end }}
|
||||
ConnectionStrings__messaging: "amqp://{{ $root.Values.sharedInfra.rabbitmq.username }}:{{ $root.Values.sharedInfra.rabbitmq.password }}@{{ $root.Values.sharedInfra.rabbitmq.host }}:{{ $root.Values.sharedInfra.rabbitmq.port }}"
|
||||
MESSAGING_PASSWORD: "{{ $root.Values.sharedInfra.rabbitmq.password }}"
|
||||
MESSAGING_URI: "amqp://{{ $root.Values.sharedInfra.rabbitmq.username }}:{{ $root.Values.sharedInfra.rabbitmq.password }}@{{ $root.Values.sharedInfra.rabbitmq.host }}:{{ $root.Values.sharedInfra.rabbitmq.port }}"
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,79 @@
|
||||
{{/*
|
||||
公共模板:前端 Deployment + Service
|
||||
可选 podAffinity(四胞胎用:前端和后端同节点)
|
||||
|
||||
参数:
|
||||
name - 服务名(agent-web-0 / sso-web ...)
|
||||
image - 镜像名
|
||||
port - 端口(默认 80)
|
||||
basePath - vite base path
|
||||
affinity - 要亲和的目标服务名(如 "agent-0"),空则不配亲和
|
||||
root - $ (root context)
|
||||
*/}}
|
||||
{{- define "mixingx.frontend" -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $port := .port | default 80 -}}
|
||||
---
|
||||
# Deployment: {{ .name }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .name }}-deployment
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/instance: {{ $root.Release.Name }}
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
spec:
|
||||
{{- if .affinity }}
|
||||
# 四胞胎:前端必须和后端同节点
|
||||
affinity:
|
||||
podAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
- labelSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: {{ .affinity }}
|
||||
topologyKey: kubernetes.io/hostname
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ .name }}
|
||||
image: {{ $root.Values.registry }}/{{ .image }}:{{ $root.Values.tag | default "latest" }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ $port }}
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: VITE_BASE_PATH
|
||||
value: "{{ .basePath }}"
|
||||
- name: PORT
|
||||
value: "{{ $port }}"
|
||||
|
||||
---
|
||||
# Service: {{ .name }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .name }}-service
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
mixingx.io/role: web
|
||||
mixingx.io/node-id: {{ .name }}
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ $port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,30 @@
|
||||
{{/*
|
||||
完整镜像名: registry/image:tag
|
||||
用法: {{ include "mixingx.image" (dict "image" .image "Values" $.Values) }}
|
||||
或: {{ include "mixingx.image" . }}(range 内,. 有 image 字段,但需传 Values)
|
||||
*/}}
|
||||
{{- define "mixingx.image" -}}
|
||||
{{ required "registry is required" .Values.registry }}/{{ required "image is required" .image }}:{{ .Values.tag | default "latest" }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
标准标签(所有资源共用)
|
||||
用法: {{ include "mixingx.labels" (dict "name" "sso" "Release" $.Release) }}
|
||||
*/}}
|
||||
{{- define "mixingx.labels" -}}
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Service 的 mixingx.io 标签(gateway 服务发现用)
|
||||
只在 role 不为空且不为 "gateway" 时打
|
||||
*/}}
|
||||
{{- define "mixingx.discoveryLabels" -}}
|
||||
{{- if and .role (ne .role "gateway") }}
|
||||
mixingx.io/role: {{ .role }}
|
||||
mixingx.io/node-id: {{ .name }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,89 @@
|
||||
{{/*
|
||||
公共模板:生成独立 postgres StatefulSet + Service + PVC
|
||||
每个有 DB 的服务(agent/edge/sso/ultra)各自一个
|
||||
|
||||
参数:
|
||||
name - 服务名(agent-0 / sso ...)
|
||||
database - 数据库名(agent-db-0 / sso-db)
|
||||
pgStorage - PVC 容量(默认 5Gi)
|
||||
affinity - 是否需要和后端同节点(四胞胎用 true)
|
||||
root - $ (root context)
|
||||
*/}}
|
||||
{{- define "mixingx.postgres" -}}
|
||||
{{- $root := .root -}}
|
||||
---
|
||||
# StatefulSet: {{ .name }}-postgres
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ .name }}-postgres
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: {{ .name }}-postgres
|
||||
spec:
|
||||
serviceName: {{ .name }}-postgres-service
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: {{ .name }}-postgres
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .pgStorage | default "5Gi" }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: {{ .name }}-postgres
|
||||
spec:
|
||||
{{- if .affinity }}
|
||||
# 四胞胎:postgres 必须和后端 Pod 同节点
|
||||
affinity:
|
||||
podAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
- labelSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
topologyKey: kubernetes.io/hostname
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: postgres
|
||||
image: docker.io/library/postgres:17
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD
|
||||
value: "{{ $root.Values.sharedInfra.postgres.password }}"
|
||||
- name: POSTGRES_DB
|
||||
value: "{{ .database }}"
|
||||
- name: POSTGRES_USER
|
||||
value: "{{ $root.Values.sharedInfra.postgres.username }}"
|
||||
ports:
|
||||
- name: tcp
|
||||
containerPort: {{ $root.Values.sharedInfra.postgres.port }}
|
||||
protocol: TCP
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
|
||||
---
|
||||
# Service: {{ .name }}-postgres-service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .name }}-postgres-service
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: {{ .name }}-postgres
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/component: {{ .name }}-postgres
|
||||
ports:
|
||||
- name: tcp
|
||||
port: {{ $root.Values.sharedInfra.postgres.port }}
|
||||
targetPort: tcp
|
||||
protocol: TCP
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,26 @@
|
||||
{{/*
|
||||
业务 Ingress — 所有流量 → gateway-service
|
||||
浏览器访问 app.mixingx.local → Traefik → gateway → 各后端/前端
|
||||
*/}}
|
||||
{{- if .Values.ingress.enabled }}
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: app-ingress
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: web
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: {{ .Values.ingress.domain }}
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ .Values.ingress.gatewayService }}
|
||||
port:
|
||||
number: {{ .Values.ingress.gatewayPort }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,62 @@
|
||||
{{- 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 1 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: audit
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: audit
|
||||
spec:
|
||||
containers:
|
||||
- name: audit
|
||||
image: "{{ .Values.registry }}/{{ .Values.audit.image }}:{{ .Values.tag | default "latest" }}"
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.audit.port }}
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: MONGODB_URI
|
||||
value: "mongodb://{{ .Values.sharedInfra.mongo.username }}:{{ .Values.sharedInfra.mongo.password }}@{{ .Values.sharedInfra.mongo.host }}:{{ .Values.sharedInfra.mongo.port }}"
|
||||
- name: MONGODB_DATABASE
|
||||
value: "{{ .Values.sharedInfra.mongo.database }}"
|
||||
- name: RABBITMQ_URI
|
||||
value: "amqp://{{ .Values.sharedInfra.rabbitmq.username }}:{{ .Values.sharedInfra.rabbitmq.password }}@{{ .Values.sharedInfra.rabbitmq.host }}:{{ .Values.sharedInfra.rabbitmq.port }}"
|
||||
- name: PORT
|
||||
value: "{{ .Values.audit.port }}"
|
||||
- name: HOST
|
||||
value: "0.0.0.0"
|
||||
- name: OTEL_EXPORTER_OTLP_ENDPOINT
|
||||
value: "{{ .Values.sharedInfra.otlp.endpoint }}"
|
||||
- name: OTEL_SERVICE_NAME
|
||||
value: "audit"
|
||||
---
|
||||
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
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/component: audit
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .Values.audit.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
@@ -0,0 +1 @@
|
||||
{{ include "mixingx.backend" (dict "name" "gateway" "image" "gateway" "role" "gateway" "replicas" 2 "rbac" true "root" $) }}
|
||||
@@ -0,0 +1,67 @@
|
||||
{{/*
|
||||
Aspire Dashboard — OTLP 遥测数据接收端
|
||||
所有后端的 OTEL_EXPORTER_OTLP_ENDPOINT 指向这里的 :18889
|
||||
也是可视化日志/追踪/指标的 Web 界面(:18888)
|
||||
*/}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: k8s-dashboard-deployment
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: k8s-dashboard
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: k8s-dashboard
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: k8s-dashboard
|
||||
spec:
|
||||
containers:
|
||||
- name: k8s-dashboard
|
||||
image: mcr.microsoft.com/dotnet/nightly/aspire-dashboard:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 18888
|
||||
protocol: TCP
|
||||
- name: otlp-grpc
|
||||
containerPort: 18889
|
||||
protocol: TCP
|
||||
- name: otlp-http
|
||||
containerPort: 18890
|
||||
protocol: TCP
|
||||
# Dashboard 无状态,数据在内存(重启清空,不影响业务)
|
||||
resources:
|
||||
requests:
|
||||
memory: 256Mi
|
||||
limits:
|
||||
memory: 512Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: k8s-dashboard-service
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: k8s-dashboard
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/component: k8s-dashboard
|
||||
ports:
|
||||
- name: http
|
||||
port: 18888
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
- name: otlp-grpc
|
||||
port: 18889
|
||||
targetPort: otlp-grpc
|
||||
protocol: TCP
|
||||
- name: otlp-http
|
||||
port: 18890
|
||||
targetPort: otlp-http
|
||||
protocol: TCP
|
||||
@@ -0,0 +1,36 @@
|
||||
{{/*
|
||||
Gateway K8s 服务发现 RBAC
|
||||
gateway 需要读 Service 列表(查 mixingx.io/role 标签)来发现 agent/edge 等
|
||||
*/}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: gateway-sa
|
||||
labels:
|
||||
app.kubernetes.io/component: gateway
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: gateway-service-reader
|
||||
labels:
|
||||
app.kubernetes.io/component: gateway
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["services"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: gateway-service-reader-binding
|
||||
labels:
|
||||
app.kubernetes.io/component: gateway
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: gateway-service-reader
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: gateway-sa
|
||||
@@ -0,0 +1,12 @@
|
||||
{{/*
|
||||
agent-0 四胞胎:后端 + 前端 + 独立 postgres(三者 podAffinity 同节点)
|
||||
*/}}
|
||||
{{- $root := $ }}
|
||||
# 1. 后端
|
||||
{{ include "mixingx.backend" (dict "name" "agent-0" "image" "agent" "role" "agent" "serviceId" "agent-0" "database" "agent-db-0" "root" $root) }}
|
||||
|
||||
# 2. 前端(亲和到 agent-0)
|
||||
{{ include "mixingx.frontend" (dict "name" "agent-web-0" "image" "agent-web" "basePath" "/agent-0/" "affinity" "agent-0" "root" $root) }}
|
||||
|
||||
# 3. 独立 postgres(亲和到 agent-0)
|
||||
{{ include "mixingx.postgres" (dict "name" "agent-0" "database" "agent-db-0" "pgStorage" "5Gi" "affinity" true "root" $root) }}
|
||||
@@ -0,0 +1,12 @@
|
||||
{{/*
|
||||
edge-0 四胞胎:后端 + 前端 + 独立 postgres(三者 podAffinity 同节点)
|
||||
*/}}
|
||||
{{- $root := $ }}
|
||||
# 1. 后端
|
||||
{{ include "mixingx.backend" (dict "name" "edge-0" "image" "edge" "role" "edge" "serviceId" "edge-0" "database" "edge-db-0" "root" $root) }}
|
||||
|
||||
# 2. 前端(亲和到 edge-0)
|
||||
{{ include "mixingx.frontend" (dict "name" "edge-web-0" "image" "edge-web" "basePath" "/edge-0/" "affinity" "edge-0" "root" $root) }}
|
||||
|
||||
# 3. 独立 postgres(亲和到 edge-0)
|
||||
{{ include "mixingx.postgres" (dict "name" "edge-0" "database" "edge-db-0" "pgStorage" "5Gi" "affinity" true "root" $root) }}
|
||||
@@ -0,0 +1,54 @@
|
||||
{{/*
|
||||
协议模拟器模板 — 遍历 mocks 列表
|
||||
每个生成: Deployment + Service
|
||||
*/}}
|
||||
{{- range .Values.mocks }}
|
||||
{{- $root := $ }}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .name }}-deployment
|
||||
labels:
|
||||
{{- include "mixingx.labels" (dict "name" .name "Release" $root.Release) | nindent 4 }}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .name }}
|
||||
image: {{ $root.Values.registry }}/{{ .image }}:{{ $root.Values.tag | default "latest" }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
{{- if .scene }}
|
||||
args:
|
||||
- "--port"
|
||||
- "{{ .port }}"
|
||||
- "--scene"
|
||||
- "{{ .scene }}"
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp
|
||||
containerPort: {{ .port }}
|
||||
protocol: TCP
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .name }}-service
|
||||
labels:
|
||||
{{- include "mixingx.labels" (dict "name" .name "Release" $root.Release) | nindent 4 }}
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
ports:
|
||||
- name: tcp
|
||||
port: {{ .port }}
|
||||
targetPort: tcp
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
@@ -0,0 +1,79 @@
|
||||
{{/*
|
||||
pgAdmin — 在 K3s 内,用 ClusterIP 直连所有 postgres Pod
|
||||
宿主的 pgAdmin(5050)是开发用的,这个是测试环境用的
|
||||
*/}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: pgadmin-deployment
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: pgadmin
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: pgadmin
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: pgadmin
|
||||
spec:
|
||||
containers:
|
||||
- name: pgadmin
|
||||
image: dpage/pgadmin4:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: PGADMIN_DEFAULT_EMAIL
|
||||
value: "admin@mixingx.local"
|
||||
- name: PGADMIN_DEFAULT_PASSWORD
|
||||
value: "Admin12345"
|
||||
- name: PGADMIN_CONFIG_SERVER_MODE
|
||||
value: "False"
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
protocol: TCP
|
||||
resources:
|
||||
requests:
|
||||
memory: 128Mi
|
||||
limits:
|
||||
memory: 256Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: pgadmin-service
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: pgadmin
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/component: pgadmin
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
---
|
||||
# Ingress:走 pgadmin.mixingx.local 域名(和宿主的 pgAdmin 分开)
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: pgadmin-k8s-ingress
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: web
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: pgadmin-k8s.mixingx.local
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: pgadmin-service
|
||||
port:
|
||||
number: 80
|
||||
@@ -0,0 +1,89 @@
|
||||
{{/*
|
||||
共享数据层:redis + mongo + rabbitmq
|
||||
所有服务连同一个(StatefulSet + PVC 持久化)
|
||||
postgres 不在这里 — 每个服务有独立的 postgres(见 _postgres.tpl)
|
||||
*/}}
|
||||
{{- range .Values.sharedDatastores }}
|
||||
{{- $root := $ }}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ .name }}-statefulset
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
spec:
|
||||
serviceName: {{ .name }}-service
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .storage }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .name }}
|
||||
image: {{ .image }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: tcp
|
||||
containerPort: {{ .port }}
|
||||
protocol: TCP
|
||||
{{- if eq .name "redis" }}
|
||||
command: ["/bin/sh"]
|
||||
args:
|
||||
- "-c"
|
||||
- "redis-server --requirepass {{ $root.Values.sharedInfra.redis.password }} --save 60 1"
|
||||
{{- end }}
|
||||
{{- if eq .name "mongo" }}
|
||||
env:
|
||||
- name: MONGO_INITDB_ROOT_USERNAME
|
||||
value: "{{ $root.Values.sharedInfra.mongo.username }}"
|
||||
- name: MONGO_INITDB_ROOT_PASSWORD
|
||||
value: "{{ $root.Values.sharedInfra.mongo.password }}"
|
||||
{{- end }}
|
||||
{{- if eq .name "messaging" }}
|
||||
env:
|
||||
- name: RABBITMQ_DEFAULT_USER
|
||||
value: "{{ $root.Values.sharedInfra.rabbitmq.username }}"
|
||||
- name: RABBITMQ_DEFAULT_PASS
|
||||
value: "{{ $root.Values.sharedInfra.rabbitmq.password }}"
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: {{ .mountPath }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .name }}-service
|
||||
labels:
|
||||
app.kubernetes.io/name: mixingx
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
spec:
|
||||
selector:
|
||||
app.kubernetes.io/component: {{ .name }}
|
||||
ports:
|
||||
- name: tcp
|
||||
port: {{ .port }}
|
||||
targetPort: tcp
|
||||
protocol: TCP
|
||||
{{- if eq .name "messaging" }}
|
||||
- name: management
|
||||
port: 15672
|
||||
targetPort: 15672
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,12 @@
|
||||
{{/*
|
||||
sso:后端(×2 副本) + 前端 + 独立 postgres(无亲和)
|
||||
*/}}
|
||||
{{- $root := $ }}
|
||||
# 1. 后端(×2)
|
||||
{{ include "mixingx.backend" (dict "name" "sso" "image" "sso" "role" "sso" "replicas" 2 "serviceId" "sso" "database" "sso-db" "root" $root) }}
|
||||
|
||||
# 2. 前端(无亲和)
|
||||
{{ include "mixingx.frontend" (dict "name" "sso-web" "image" "sso-web" "basePath" "/sso/" "root" $root) }}
|
||||
|
||||
# 3. 独立 postgres(无亲和)
|
||||
{{ include "mixingx.postgres" (dict "name" "sso" "database" "sso-db" "pgStorage" "10Gi" "affinity" false "root" $root) }}
|
||||
@@ -0,0 +1,12 @@
|
||||
{{/*
|
||||
ultra:后端(×2 副本) + 前端 + 独立 postgres(无亲和)
|
||||
*/}}
|
||||
{{- $root := $ }}
|
||||
# 1. 后端(×2)
|
||||
{{ include "mixingx.backend" (dict "name" "ultra" "image" "ultra" "role" "ultra" "replicas" 2 "database" "ultra-db" "root" $root) }}
|
||||
|
||||
# 2. 前端
|
||||
{{ include "mixingx.frontend" (dict "name" "ultra-web" "image" "ultra-web" "basePath" "/ultra/" "root" $root) }}
|
||||
|
||||
# 3. 独立 postgres
|
||||
{{ include "mixingx.postgres" (dict "name" "ultra" "database" "ultra-db" "pgStorage" "10Gi" "affinity" false "root" $root) }}
|
||||
@@ -0,0 +1,15 @@
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# 105 生产环境 values(覆盖 values.yaml 的默认值)
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
registry: 192.168.1.105:8888/mixingx
|
||||
|
||||
infra:
|
||||
postgres:
|
||||
password: "Admin12345" # 105 实际密码
|
||||
redis:
|
||||
password: "Admin12345"
|
||||
mongo:
|
||||
password: "Admin12345"
|
||||
|
||||
tag: latest
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# MixingX Helm Chart — values
|
||||
# 架构:独立 DB + 四胞胎(agent/edge podAffinity) + 共享基础设施
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
||||
# ── 全局 ──
|
||||
registry: 192.168.1.105:8888/mixingx
|
||||
tag: latest
|
||||
|
||||
# ── 共享基础设施(所有服务连同一个) ──
|
||||
sharedInfra:
|
||||
postgres: # postgres 连接参数(每个独立 postgres 共用)
|
||||
username: postgres
|
||||
password: "Admin12345"
|
||||
port: 5432
|
||||
redis:
|
||||
host: redis-service
|
||||
port: 6379
|
||||
password: "Admin12345"
|
||||
rabbitmq:
|
||||
host: messaging-service
|
||||
port: 5672
|
||||
username: guest
|
||||
password: guest
|
||||
mongo:
|
||||
host: mongo-service
|
||||
port: 27017
|
||||
username: admin
|
||||
password: "Admin12345"
|
||||
database: mixingx_audit
|
||||
otlp:
|
||||
endpoint: http://k8s-dashboard-service:18889
|
||||
protocol: grpc
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# 类型 A:四胞胎(agent/edge)— 后端+前端+独立DB,podAffinity 同节点
|
||||
# 每个实例生成:后端 Deployment + 前端 Deployment + 独立 postgres StatefulSet
|
||||
# 默认各 1 个,以后按需加(加一行 values + helm upgrade)
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
instances:
|
||||
- name: agent-0
|
||||
image: agent
|
||||
role: agent
|
||||
webImage: agent-web
|
||||
webBasePath: /agent-0/
|
||||
serviceId: agent-0
|
||||
database: agent-db-0
|
||||
pgStorage: 5Gi
|
||||
affinity: true # 前端和 DB 必须和后端同节点
|
||||
|
||||
- name: edge-0
|
||||
image: edge
|
||||
role: edge
|
||||
webImage: edge-web
|
||||
webBasePath: /edge-0/
|
||||
serviceId: edge-0
|
||||
database: edge-db-0
|
||||
pgStorage: 5Gi
|
||||
affinity: true
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# 类型 B:独立不亲和(sso/ultra)— 后端+前端+独立DB,无亲和,多副本
|
||||
# 固定数量,不动态添加
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
standalones:
|
||||
- name: sso
|
||||
image: sso
|
||||
role: sso
|
||||
webImage: sso-web
|
||||
webBasePath: /sso/
|
||||
serviceId: sso
|
||||
database: sso-db
|
||||
pgStorage: 10Gi
|
||||
replicas: 2
|
||||
affinity: false
|
||||
|
||||
- name: ultra
|
||||
image: ultra
|
||||
role: ultra
|
||||
webImage: ultra-web
|
||||
webBasePath: /ultra/
|
||||
database: ultra-db
|
||||
pgStorage: 10Gi
|
||||
replicas: 2
|
||||
affinity: false
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# 类型 C/D:无独立 DB 的服务
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
gateway:
|
||||
image: gateway
|
||||
port: 8080
|
||||
replicas: 2
|
||||
rbac: true # serviceAccountName: gateway-sa
|
||||
|
||||
audit:
|
||||
enabled: true
|
||||
image: audit
|
||||
port: 5600
|
||||
replicas: 2
|
||||
|
||||
# ── 共享数据层(非 postgres) ──
|
||||
sharedDatastores:
|
||||
- name: redis
|
||||
image: docker.io/library/redis:8.6
|
||||
port: 6379
|
||||
storage: 2Gi
|
||||
mountPath: /data
|
||||
- name: mongo
|
||||
image: docker.io/library/mongo:8.3
|
||||
port: 27017
|
||||
storage: 5Gi
|
||||
mountPath: /data/db
|
||||
- name: messaging
|
||||
image: docker.io/library/rabbitmq:4.3-management
|
||||
port: 5672
|
||||
storage: 2Gi
|
||||
mountPath: /var/lib/rabbitmq
|
||||
|
||||
# ── 协议模拟器(测试环境) ──
|
||||
mocks:
|
||||
- name: opcua-peripheral
|
||||
image: opcua
|
||||
port: 25006
|
||||
scene: /scenes/opcua/peripheral-plc.json
|
||||
- name: opcua-trimming
|
||||
image: opcua
|
||||
port: 25008
|
||||
scene: /scenes/opcua/trimming-machine.json
|
||||
- name: opcua-meter
|
||||
image: opcua
|
||||
port: 25010
|
||||
scene: /scenes/opcua/meter.json
|
||||
- name: s7-diecast
|
||||
image: s7-diecast
|
||||
port: 11021
|
||||
|
||||
# ── Ingress ──
|
||||
ingress:
|
||||
enabled: true
|
||||
domain: app.mixingx.local
|
||||
Reference in new issue
Block a user