根因:官方 postgres:17 镜像(2026-08 构建)内 gosu 在新内核(Ubuntu 26.04 kernel 7.0.0-39+)上 用户态死循环,容器假活(Running 但 5432 无服务、PGDATA 空、零日志);绕过 gosu 后 PG17 恢复期 signal checkpoint 再遇权限死循环,故三件缺一不可: - pod securityContext: runAsUser/runAsGroup/fsGroup=999(以 postgres 用户直跑,跳过 gosu) - container command: docker-entrypoint.sh postgres(非 root 下 entrypoint 自动跳过 gosu) - container securityContext: privileged(否则恢复期 'could not signal for checkpoint: Permission denied') 涉及 5 个模板:sso/ultra/audit(audit-db)/platform(audit)/agent-unit 各自内嵌的 postgres。 实测:xjf1641(Xeon+kernel43)与 wytest(i5+kernel42)原始定义必死、打补丁后稳定运行; kernel 7.0.0-38 老机(如 184)暂未触发但同机制不免疫,升级内核前必须先吃本修复。
241 lines
8.1 KiB
YAML
241 lines
8.1 KiB
YAML
{{- $root := . -}}
|
||
{{- $cfg := .Values.ultra -}}
|
||
{{- $name := $cfg.name -}}
|
||
{{- $role := $cfg.role -}}
|
||
{{- $serviceId := $cfg.serviceId -}}
|
||
{{- $database := $cfg.database -}}
|
||
{{- $pgStorage := $cfg.pgStorage -}}
|
||
{{- $replicas := $cfg.replicas -}}
|
||
{{- $description := $cfg.description -}}
|
||
{{- $webBasePath := $cfg.webBasePath -}}
|
||
{{- $port := 8080 -}}
|
||
{{- $webPort := 80 -}}
|
||
{{- $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 2 }}
|
||
selector:
|
||
matchLabels:
|
||
app.kubernetes.io/component: {{ $name }}
|
||
template:
|
||
metadata:
|
||
annotations:
|
||
checksum/config: {{ include "mixingx-ultra.configData" . | sha256sum }}
|
||
labels:
|
||
app.kubernetes.io/component: {{ $name }}
|
||
spec:
|
||
{{ include "mixingx-ultra.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }}
|
||
containers:
|
||
- name: {{ $name }}
|
||
image: {{ include "mixingx-ultra.image" (dict "registry" $root.Values.global.imageRegistry "image" $root.Values.images.ultra) | quote }}
|
||
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" }}"
|
||
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 }}
|
||
mixingx.io/role: {{ $role }}
|
||
mixingx.io/node-id: {{ $name }}
|
||
annotations:
|
||
mixingx.io/description: {{ $description | quote }}
|
||
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:
|
||
{{- include "mixingx-ultra.configData" . | nindent 2 }}
|
||
---
|
||
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 }}"
|
||
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 }}"
|
||
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 }}"
|
||
---
|
||
apiVersion: apps/v1
|
||
kind: Deployment
|
||
metadata:
|
||
name: {{ $name }}-web-deployment
|
||
labels:
|
||
app.kubernetes.io/name: mixingx
|
||
app.kubernetes.io/instance: {{ $root.Release.Name }}
|
||
app.kubernetes.io/component: {{ $name }}-web
|
||
spec:
|
||
replicas: 1
|
||
selector:
|
||
matchLabels:
|
||
app.kubernetes.io/component: {{ $name }}-web
|
||
template:
|
||
metadata:
|
||
labels:
|
||
app.kubernetes.io/component: {{ $name }}-web
|
||
spec:
|
||
{{ include "mixingx-ultra.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }}
|
||
containers:
|
||
- name: {{ $name }}-web
|
||
image: {{ include "mixingx-ultra.image" (dict "registry" $root.Values.global.imageRegistry "image" $root.Values.images.ultraWeb) | quote }}
|
||
imagePullPolicy: IfNotPresent
|
||
ports:
|
||
- name: http
|
||
containerPort: {{ $webPort }}
|
||
protocol: TCP
|
||
env:
|
||
- name: TZ
|
||
value: "{{ $root.Values.timezone | default "Asia/Shanghai" }}"
|
||
- name: VITE_BASE_PATH
|
||
value: "{{ $webBasePath }}"
|
||
- name: PORT
|
||
value: "{{ $webPort }}"
|
||
---
|
||
apiVersion: v1
|
||
kind: Service
|
||
metadata:
|
||
name: {{ $name }}-web-service
|
||
labels:
|
||
app.kubernetes.io/name: mixingx
|
||
app.kubernetes.io/component: {{ $name }}-web
|
||
mixingx.io/role: web
|
||
mixingx.io/node-id: {{ $name }}-web
|
||
spec:
|
||
selector:
|
||
app.kubernetes.io/component: {{ $name }}-web
|
||
ports:
|
||
- name: http
|
||
port: {{ $webPort }}
|
||
targetPort: http
|
||
protocol: TCP
|
||
---
|
||
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-ultra.storageClassName" $root }}
|
||
resources:
|
||
requests:
|
||
storage: {{ $pgStorage | default "5Gi" }}
|
||
template:
|
||
metadata:
|
||
labels:
|
||
app.kubernetes.io/component: {{ $name }}-postgres
|
||
spec:
|
||
{{ include "mixingx-ultra.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }}
|
||
# postgres 以专用用户直跑,绕过镜像内 gosu(新内核下 gosu 用户态死循环,
|
||
# 见 ADR/工单:kernel 7.0.0-39+ × gosu 兼容 bug;三件套缺一不可)
|
||
securityContext:
|
||
runAsUser: 999
|
||
runAsGroup: 999
|
||
fsGroup: 999
|
||
containers:
|
||
- name: postgres
|
||
command: ["docker-entrypoint.sh", "postgres"]
|
||
securityContext:
|
||
privileged: true
|
||
image: {{ include "mixingx-ultra.image" (dict "registry" $root.Values.global.imageRegistry "image" $root.Values.images.postgres) | quote }}
|
||
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 }}"
|
||
- 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: {{ $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
|