{{- define "mixingx-platform.backend" -}} {{- $root := .root -}} {{- $port := .port | default 8080 -}} {{- $pgHost := printf "%s-postgres-service" .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 }} {{ include "mixingx-platform.tierAffinity" (dict "role" .role "root" $root) | nindent 6 }} 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 env: - name: TZ value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}" {{- if .rbac }} - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace {{- end }} livenessProbe: httpGet: path: /health port: http initialDelaySeconds: 120 periodSeconds: 30 timeoutSeconds: 15 failureThreshold: 12 readinessProbe: httpGet: path: /alive port: http initialDelaySeconds: 60 periodSeconds: 30 timeoutSeconds: 10 failureThreshold: 8 --- 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 }} {{- if and .role (ne .role "gateway") .description }} annotations: mixingx.io/description: {{ .description | quote }} {{- end }} spec: selector: app.kubernetes.io/component: {{ .name }} ports: - name: http port: {{ $port }} targetPort: http protocol: TCP --- 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 }} {{ upper .role }}_SERVICE_ID: "{{ .serviceId }}" {{- 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" --- 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 -}} {{- define "mixingx-platform.frontend" -}} {{- $root := .root -}} {{- $port := .port | default 80 -}} --- 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: {{ include "mixingx-platform.tierAffinity" (dict "role" .tierRole "root" $root) | nindent 6 }} containers: - name: {{ .name }} image: {{ $root.Values.registry }}/{{ .image }}:{{ $root.Values.tag | default "latest" }} imagePullPolicy: IfNotPresent ports: - name: http containerPort: {{ $port }} protocol: TCP env: - name: TZ value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}" - name: VITE_BASE_PATH value: "{{ .basePath }}" - name: PORT value: "{{ $port }}" --- 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 -}} {{- define "mixingx-platform.postgres" -}} {{- $root := .root -}} --- 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 annotations: helm.sh/resource-policy: keep spec: accessModes: ["ReadWriteOnce"] storageClassName: {{ include "mixingx-platform.storageClassName" $root }} resources: requests: storage: {{ .pgStorage | default "5Gi" }} template: metadata: labels: app.kubernetes.io/component: {{ .name }}-postgres spec: {{ include "mixingx-platform.tierAffinity" (dict "role" .tierRole "root" $root) | nindent 6 }} 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 --- 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 -}}