Tasks 10-11: podAffinity+nodeAffinity 合并到同一 affinity 块; audit/shared-infra 走 tier;Chart.yaml 1.1.0→1.2.0。
91 lines
2.5 KiB
YAML
91 lines
2.5 KiB
YAML
{{/*
|
|
共享数据层: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:
|
|
{{ include "mixingx.tierAffinity" (dict "role" "sharedDatastores" "root" $root) }}
|
|
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 }}
|