diff --git a/README.md b/README.md index 552f879..e49e158 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,22 @@ helm template ci-edge release-charts/mixingx-edge-unit `mixingx-deploy` 的 ApplicationSet 按 unit chart 逐个发布,每个 edge/agent 一个独立 Helm release。详见 `mixingx-deploy/`。 +## PostgreSQL on K3s + +PostgreSQL StatefulSets use the Debian image's UID/GID 999 and run the image +entrypoint directly. This skips gosu while preserving database initialization +and startup on the existing data volume. The readiness probe uses +`pg_isready` over TCP so the container is Ready only after PostgreSQL accepts +connections, including after recovery. + +Only the PostgreSQL container uses `privileged: true` as a temporary workaround +for checkpoint signal failures observed on affected Ubuntu 26.04 / K3s nodes. +The namespace's admission policy must permit privileged containers. The +[containerd signal-denial report](https://github.com/containerd/containerd/issues/14485) +describes the same checkpoint error with AppArmor. Check the host kernel log +for an AppArmor signal denial and validate initialization and recovery with the +corrected runtime or profile before removing privileged mode. + ## 关联文档 - hub [AGENTS.md](https://gitee.com/mixing-tech/mixingx.hub) — 全项目指南 diff --git a/release-charts/mixingx-agent-unit/templates/unit.yaml b/release-charts/mixingx-agent-unit/templates/unit.yaml index 714ecc6..d196d2c 100644 --- a/release-charts/mixingx-agent-unit/templates/unit.yaml +++ b/release-charts/mixingx-agent-unit/templates/unit.yaml @@ -207,6 +207,11 @@ spec: labels: app.kubernetes.io/component: {{ $name }}-postgres spec: + securityContext: + # Run the image entrypoint as postgres so it does not invoke gosu. + runAsUser: 999 + runAsGroup: 999 + fsGroup: 999 {{ include "mixingx-unit.followerScheduling" . | nindent 6 }} {{- with $.Values.imagePullSecrets }} imagePullSecrets: @@ -216,6 +221,10 @@ spec: - name: postgres image: {{ .Values.images.postgres.repository }}:{{ .Values.images.postgres.tag | default "latest" }} imagePullPolicy: IfNotPresent + command: ["docker-entrypoint.sh", "postgres"] + securityContext: + # Temporary compatibility workaround for checkpoint signal failures on affected k3s nodes. + privileged: true env: - name: POSTGRES_PASSWORD value: "{{ .Values.sharedInfra.postgres.password }}" @@ -229,6 +238,15 @@ spec: - name: tcp containerPort: {{ .Values.ports.postgres }} protocol: TCP + readinessProbe: + exec: + command: + - sh + - -ec + - >- + exec pg_isready -q -h 127.0.0.1 -p {{ .Values.ports.postgres }} -U "$POSTGRES_USER" -d "$POSTGRES_DB" + periodSeconds: 5 + timeoutSeconds: 3 volumeMounts: - name: data mountPath: /var/lib/postgresql/data diff --git a/release-charts/mixingx-audit/templates/audit-db.yaml b/release-charts/mixingx-audit/templates/audit-db.yaml index 309e996..b54a4a7 100644 --- a/release-charts/mixingx-audit/templates/audit-db.yaml +++ b/release-charts/mixingx-audit/templates/audit-db.yaml @@ -31,6 +31,11 @@ spec: labels: app.kubernetes.io/component: {{ .Values.audit.database }}-postgres spec: + securityContext: + # Run the image entrypoint as postgres so it does not invoke gosu. + runAsUser: 999 + runAsGroup: 999 + fsGroup: 999 {{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }} {{- with $.Values.imagePullSecrets }} imagePullSecrets: @@ -40,6 +45,10 @@ spec: - name: postgres image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }} imagePullPolicy: IfNotPresent + command: ["docker-entrypoint.sh", "postgres"] + securityContext: + # Temporary compatibility workaround for checkpoint signal failures on affected k3s nodes. + privileged: true env: - name: POSTGRES_PASSWORD value: "{{ $root.Values.sharedInfra.postgres.password }}" @@ -53,6 +62,15 @@ spec: - name: tcp containerPort: {{ $root.Values.sharedInfra.postgres.port }} protocol: TCP + readinessProbe: + exec: + command: + - sh + - -ec + - >- + exec pg_isready -q -h 127.0.0.1 -p {{ $root.Values.sharedInfra.postgres.port }} -U "$POSTGRES_USER" -d "$POSTGRES_DB" + periodSeconds: 5 + timeoutSeconds: 3 volumeMounts: - name: data mountPath: /var/lib/postgresql/data diff --git a/release-charts/mixingx-platform/templates/_workloads.tpl b/release-charts/mixingx-platform/templates/_workloads.tpl index d955645..ad4ff5f 100644 --- a/release-charts/mixingx-platform/templates/_workloads.tpl +++ b/release-charts/mixingx-platform/templates/_workloads.tpl @@ -231,6 +231,11 @@ spec: labels: app.kubernetes.io/component: {{ .name }}-postgres spec: + securityContext: + # Run the image entrypoint as postgres so it does not invoke gosu. + runAsUser: 999 + runAsGroup: 999 + fsGroup: 999 {{ include "mixingx-platform.tierAffinity" (dict "role" .tierRole "root" $root) | nindent 6 }} {{- with $root.Values.imagePullSecrets }} imagePullSecrets: @@ -240,6 +245,10 @@ spec: - name: postgres image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }} imagePullPolicy: IfNotPresent + command: ["docker-entrypoint.sh", "postgres"] + securityContext: + # Temporary compatibility workaround for checkpoint signal failures on affected k3s nodes. + privileged: true env: - name: POSTGRES_PASSWORD value: "{{ $root.Values.sharedInfra.postgres.password }}" @@ -253,6 +262,15 @@ spec: - name: tcp containerPort: {{ $root.Values.sharedInfra.postgres.port }} protocol: TCP + readinessProbe: + exec: + command: + - sh + - -ec + - >- + exec pg_isready -q -h 127.0.0.1 -p {{ $root.Values.sharedInfra.postgres.port }} -U "$POSTGRES_USER" -d "$POSTGRES_DB" + periodSeconds: 5 + timeoutSeconds: 3 volumeMounts: - name: data mountPath: /var/lib/postgresql/data diff --git a/release-charts/mixingx-platform/templates/audit.yaml b/release-charts/mixingx-platform/templates/audit.yaml index 08a93da..bee37bf 100644 --- a/release-charts/mixingx-platform/templates/audit.yaml +++ b/release-charts/mixingx-platform/templates/audit.yaml @@ -213,6 +213,11 @@ spec: labels: app.kubernetes.io/component: {{ .Values.audit.database }}-postgres spec: + securityContext: + # Run the image entrypoint as postgres so it does not invoke gosu. + runAsUser: 999 + runAsGroup: 999 + fsGroup: 999 {{ include "mixingx-platform.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }} {{- with $.Values.imagePullSecrets }} imagePullSecrets: @@ -222,6 +227,10 @@ spec: - name: postgres image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }} imagePullPolicy: IfNotPresent + command: ["docker-entrypoint.sh", "postgres"] + securityContext: + # Temporary compatibility workaround for checkpoint signal failures on affected k3s nodes. + privileged: true env: - name: POSTGRES_PASSWORD value: "{{ $root.Values.sharedInfra.postgres.password }}" @@ -235,6 +244,15 @@ spec: - name: tcp containerPort: {{ $root.Values.sharedInfra.postgres.port }} protocol: TCP + readinessProbe: + exec: + command: + - sh + - -ec + - >- + exec pg_isready -q -h 127.0.0.1 -p {{ $root.Values.sharedInfra.postgres.port }} -U "$POSTGRES_USER" -d "$POSTGRES_DB" + periodSeconds: 5 + timeoutSeconds: 3 volumeMounts: - name: data mountPath: /var/lib/postgresql/data diff --git a/release-charts/mixingx-sso/templates/sso.yaml b/release-charts/mixingx-sso/templates/sso.yaml index 8741ca1..f1155ba 100644 --- a/release-charts/mixingx-sso/templates/sso.yaml +++ b/release-charts/mixingx-sso/templates/sso.yaml @@ -197,6 +197,11 @@ spec: labels: app.kubernetes.io/component: {{ $name }}-postgres spec: + securityContext: + # Run the image entrypoint as postgres so it does not invoke gosu. + runAsUser: 999 + runAsGroup: 999 + fsGroup: 999 {{ include "mixingx-sso.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }} {{- with $.Values.imagePullSecrets }} imagePullSecrets: @@ -206,6 +211,10 @@ spec: - name: postgres image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }} imagePullPolicy: IfNotPresent + command: ["docker-entrypoint.sh", "postgres"] + securityContext: + # Temporary compatibility workaround for checkpoint signal failures on affected k3s nodes. + privileged: true env: - name: POSTGRES_PASSWORD value: "{{ $root.Values.sharedInfra.postgres.password }}" @@ -219,6 +228,15 @@ spec: - name: tcp containerPort: {{ $root.Values.sharedInfra.postgres.port }} protocol: TCP + readinessProbe: + exec: + command: + - sh + - -ec + - >- + exec pg_isready -q -h 127.0.0.1 -p {{ $root.Values.sharedInfra.postgres.port }} -U "$POSTGRES_USER" -d "$POSTGRES_DB" + periodSeconds: 5 + timeoutSeconds: 3 volumeMounts: - name: data mountPath: /var/lib/postgresql/data diff --git a/release-charts/mixingx-ultra/templates/ultra.yaml b/release-charts/mixingx-ultra/templates/ultra.yaml index cd3850b..eb7fa6b 100644 --- a/release-charts/mixingx-ultra/templates/ultra.yaml +++ b/release-charts/mixingx-ultra/templates/ultra.yaml @@ -200,6 +200,11 @@ spec: labels: app.kubernetes.io/component: {{ $name }}-postgres spec: + securityContext: + # Run the image entrypoint as postgres so it does not invoke gosu. + runAsUser: 999 + runAsGroup: 999 + fsGroup: 999 {{ include "mixingx-ultra.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }} {{- with $.Values.imagePullSecrets }} imagePullSecrets: @@ -209,6 +214,10 @@ spec: - name: postgres image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }} imagePullPolicy: IfNotPresent + command: ["docker-entrypoint.sh", "postgres"] + securityContext: + # Temporary compatibility workaround for checkpoint signal failures on affected k3s nodes. + privileged: true env: - name: POSTGRES_PASSWORD value: "{{ $root.Values.sharedInfra.postgres.password }}" @@ -222,6 +231,15 @@ spec: - name: tcp containerPort: {{ $root.Values.sharedInfra.postgres.port }} protocol: TCP + readinessProbe: + exec: + command: + - sh + - -ec + - >- + exec pg_isready -q -h 127.0.0.1 -p {{ $root.Values.sharedInfra.postgres.port }} -U "$POSTGRES_USER" -d "$POSTGRES_DB" + periodSeconds: 5 + timeoutSeconds: 3 volumeMounts: - name: data mountPath: /var/lib/postgresql/data