Compare commits

...
Author SHA1 Message Date
王野 ef0e2b5ce1 release: bump chart version to v1.0.43 2026-09-28 05:44:36 +00:00
ximenchuifeng e6ada86374 release: bump chart version to v1.0.42 2026-09-24 06:39:09 +00:00
ximenchuifeng 33908b6955 release: bump chart version to v1.0.41 2026-09-24 03:22:55 +00:00
ximenchuifeng f623c56853 release: bump chart version to v1.0.40 2026-09-24 02:57:06 +00:00
ximenchuifeng 1a1847ba7e release: bump chart version to v1.0.39 2026-09-24 02:04:52 +00:00
薛佳帆 c698fe14cc release: bump chart version to v1.0.38 2026-09-23 07:15:32 +00:00
薛佳帆 ee378168c0 release: bump chart version to v1.0.37 2026-09-23 01:56:11 +00:00
薛佳帆 41ccb587a9 release: bump chart version to v1.0.36 2026-09-23 01:55:39 +00:00
王野 84ddff1776 release: bump chart version to v1.0.35 2026-09-22 01:47:43 +00:00
王野 02583981cb release: bump chart version to v1.0.34 2026-09-22 01:46:49 +00:00
薛佳帆 bfec34fc70 release: bump chart version to v1.0.33 2026-09-21 11:32:03 +00:00
薛佳帆 b42271b704 release: bump chart version to v1.0.32 2026-09-21 11:30:49 +00:00
王野 3decc0f1a2 release: bump chart version to v1.0.31 2026-09-21 08:49:40 +00:00
王野 3bc2c6a1b4 release: bump chart version to v1.0.30 2026-09-21 06:35:25 +00:00
王野 1632267279 release: bump chart version to v1.0.29 2026-09-21 06:32:55 +00:00
薛佳帆 51123401a1 release: bump chart version to v1.0.28 2026-09-20 08:28:10 +00:00
王野 04e0105b91 release: bump chart version to v1.0.27 2026-09-20 02:37:24 +00:00
ximenchuifeng 3c5dff3857 release: bump chart version to v1.0.26 2026-09-18 05:49:34 +00:00
ximenchuifeng cf0cf6080f release: bump chart version to v1.0.25 2026-09-18 05:42:39 +00:00
薛佳帆 e5bf7090b4 release: bump chart version to v1.0.24 2026-09-17 09:00:20 +00:00
ximenchuifeng 943b045cad release: bump chart version to v1.0.23 2026-09-15 10:51:15 +00:00
薛佳帆 e988974374 release: bump chart version to v1.0.22 2026-09-15 09:54:26 +00:00
ximenchuifeng 224afb71f1 release: bump chart version to v1.0.21 2026-09-15 09:36:52 +00:00
王野 981be3e23f release: bump chart version to v1.0.20 2026-09-15 08:01:20 +00:00
薛佳帆 4613388d0c chore: 删除 provision/rollback-host 迁移脚本——主机已全面由 NM 托管且 networkd 已 mask,迁移工具不再需要;rollback 依赖 networkd 接管原配置,mask 状态下执行反而会导致接口失联 2026-09-15 10:09:17 +08:00
ximenchuifeng 2ba8f83f2e release: bump chart version to v1.0.19 2026-09-14 09:52:19 +00:00
ximenchuifeng 0ece6b12b2 release: bump chart version to v1.0.18 2026-09-14 07:00:23 +00:00
薛佳帆 b6c35f28e3 feat(network-agent): headless Service 打 mixingx.io/role=node-id 标签 —— 纳入 Gateway K8s 服务发现,生成 /api/network/** 透传路由;注释说明前端弹窗改经 Gateway 同源转发 2026-09-14 14:37:08 +08:00
mx-ops d4b84bb886 fix(network-agent): daemonset 补渲染 imagePullSecrets
ACR 私仓交付后 DaemonSet 无拉取凭据,匿名拉取报 insufficient_scope。
对齐其余 10 个 chart 的标准写法,消费 _common/registry.yaml 提供的 imagePullSecrets。
2026-09-10 08:43:57 +00:00
薛佳帆 05a476d932 feat: provision 写入 NM keep-configuration=no——禁止开机收编 initramfs(dracut 遗留 DHCP)抢配的连接,强制按 autoconnect-priority 选路激活静态档案;initrd 的 DHCP 租约以副地址共存(双 IP:静态主+DHCP 副兜底);rollback 对称移除 2026-09-10 16:21:42 +08:00
薛佳帆 9035f9eb96 release: bump chart version to v1.0.17 2026-09-10 08:02:26 +00:00
薛佳帆 869754606e release: bump chart version to v1.0.16 2026-09-10 08:01:59 +00:00
薛佳帆 405eef034a feat(network-agent): 挂载宿主机状态目录 /var/lib/mixingx/network-agent(DirectoryOrCreate)——网卡别名 aliases.json 持久化,节点重启/Pod 重建均保留;chart 1.0.16 2026-09-10 09:47:34 +08:00
王野 9b3a61eb49 release: bump chart version to v1.0.15 2026-09-08 11:25:07 +00:00
ximenchuifeng 322411955e release: bump chart version to v1.0.14 2026-09-08 11:08:11 +00:00
ximenchuifeng 4716a40c3a release: bump chart version to v1.0.13 2026-09-08 11:06:21 +00:00
ximenchuifeng 9ab9b5c97e release: bump chart version to v1.0.12 2026-09-08 11:05:17 +00:00
王野 6707dbe28f release: bump chart version to v1.0.11 2026-09-08 10:57:34 +00:00
ximenchuifeng 8b70d43953 release: bump chart version to v1.0.10 2026-09-08 10:48:09 +00:00
ximenchuifeng 70c85011db release: bump chart version to v1.0.9 2026-09-08 10:28:34 +00:00
王野 34e108dbbc release: bump chart version to v1.0.8 2026-09-08 10:05:38 +00:00
薛佳帆 4395e900e9 refactor(network-agent): 移除 NET_ADMIN capability 与 nm-run 挂载——agent 已无 ip addr del 等网络写操作(切静态清残留动态地址逻辑删除,networkd 将在宿主机 mask),特权动作全部经 D-Bus 由主机 NM 执行;/run/NetworkManager 源码未使用一并移除;chart 1.0.7 2026-09-08 16:20:53 +08:00
ximenchuifeng 0aea949b49 release: bump chart version to v1.0.7 2026-09-08 08:07:59 +00:00
王野 798735a0a8 release: bump chart version to v1.0.6 2026-09-08 07:16:08 +00:00
ximenchuifeng 5e9b92f507 release: bump chart version to v1.0.5 2026-09-08 07:02:59 +00:00
ximenchuifeng b21fb1ac92 release: bump chart version to v1.0.4 2026-09-08 06:58:41 +00:00
ximenchuifeng f2e6683a44 release: bump chart version to v1.0.3 2026-09-08 04:55:52 +00:00
ximenchuifeng c4f962d120 release: bump chart version to v1.0.2 2026-09-08 04:53:47 +00:00
薛佳帆 352aa78a8f Merge branch 'develop/v.1.0.1' 2026-09-07 15:48:19 +08:00
薛佳帆 e5f1ba44c8 Merge branch 'develop/v.1.0.1' 2026-09-07 09:40:13 +08:00
王野 4e517797e1 feat(mixingx-agent-unit): 简化PostgreSQL配置并移除角色预置逻辑
- 将PostgreSQL配置简化为单一用户名和密码模式,移除了管理员用户和应用用户的分离机制
- 移除了复杂的PostgreSQL角色预置SQL文件和相关的initContainer逻辑
- 直接通过连接字符串设置idle_in_transaction_session_timeout参数
- 更新版本号从1.0.2到1.0.3
- 移除了对预创建PostgreSQL凭证Secret的依赖
2026-09-05 15:18:59 +08:00
王野 5bc1b52721 Merge branch 'develop/v.1.0.1'
# Conflicts:
#	release-charts/mixingx-agent-unit/Chart.yaml
#	release-charts/mixingx-agent-unit/templates/unit.yaml
2026-09-04 22:37:59 +08:00
薛佳帆 90d8838e15 Merge branch 'develop/v.1.0.1' 2026-09-04 17:24:13 +08:00
薛佳帆 2e7d079f65 Merge branch 'develop/v.1.0.1' 2026-09-04 15:39:35 +08:00
ximenchuifeng a567579ab2 chore(delivery): busybox/alpine 修正为 ACR 实存 tag 并标 optional(2026-08-38 实盘盘点) 2026-08-22 15:06:18 +08:00
ximenchuifeng 3433a6d945 chore(delivery): mqttx-web 已推 ACR 2026-08-22 14:44:05 +08:00
ximenchuifeng befbfee653 release: bump chart version to v1.0.1 2026-08-22 05:49:53 +00:00
ximenchuifeng 07f22f5eb4 chore(delivery): nanomq 已补推 ACR,清单标记翻绿(D2 完成) 2026-08-22 13:24:24 +08:00
ximenchuifeng 601151bfae feat(delivery): 全 chart 支持 imagePullSecrets(默认空,内网零变化)+ 交付镜像清单
- 10 个 chart values 顶层加 imagePullSecrets: [](ADR-0066)
- 27 处 Pod spec 注入 with 块;platform _workloads.tpl 用 $root 上下文
- 默认渲染与改动前 bit 级一致(helm template 验证);注入测试 10/10 通过
- delivery/image-manifest.yaml: 第三方镜像 ACR 核对清单(nanomq 为当前缺口)
2026-08-22 13:06:46 +08:00
46 changed files with 212 additions and 394 deletions

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# 交付镜像清单(Delivery Image Manifest)— ADR-0066
#
# 用途:release 前核对 ACR 上第三方镜像齐备(发布流水线 Step 2 读取,缺失即 fail fast)。
# 规则:
# - acr 路径统一收进 library/*(显式引用不依赖上游路径对齐)
# - pushed: false = 尚未推到 ACR 的缺口,release 前必须补推(cr_temp_user 临时 token 手工作业)
# - optional: true = 客户默认不部署,缺了不阻塞
#
# 业务镜像(mixingx/*)不在本清单:它们由发布流水线从交付基线 retag 产出,天然齐备。
thirdParty:
# ── 平台核心依赖(缺一不可) ──
- { upstream: docker.io/library/postgres:17, acr: library/postgres:17, pushed: true }
- { upstream: docker.io/library/redis:8.6, acr: library/redis:8.6, pushed: true }
- { upstream: docker.io/library/rabbitmq:4.3-management, acr: library/rabbitmq:4.3-management, pushed: true }
# ── edge 单元 + audit broker 硬依赖 ──
- { upstream: docker.io/emqx/nanomq:0.25.2-2, acr: library/nanomq:0.25.2-2, pushed: true } # D2 已补推(2026-08-22)
# ── 工具类(现场无组件直接依赖,备查;tag 以 ACR 实存为准,2026-08-22 盘点) ──
- { upstream: docker.io/library/busybox:1.36, acr: library/busybox:1.36, pushed: true, optional: true }
- { upstream: docker.io/library/alpine:3.19, acr: library/alpine:3.19, pushed: true, optional: true }
# ── 可选(客户默认不部署) ──
- { upstream: docker.io/emqx/mqttx-web:latest, acr: library/mqttx-web:latest, pushed: true, optional: true } # mxlexus 已部署(2026-08-22)
- { upstream: docker.io/library/mongo:7.0, acr: library/mongo:7.0, pushed: true, optional: true } # v2 audit 已去 mongo,存量备用
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-agent-unit
description: "One MixingX agent unit release: agent backend, agent web, and agent PostgreSQL."
type: application
version: 0.1.1
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
+5 -7
View File
@@ -6,12 +6,11 @@ Deploys one agent site as one Helm release:
- `agent-web-<site>` frontend
- `agent-<site>-postgres` StatefulSet and retained PVC
The release requires a pre-created PostgreSQL credentials Secret. By default its
name is `agent-<site>-postgres-credentials`; the required keys are
`admin-password`, `app-password`, and `connection-string`. The Agent connection
string must use `sharedInfra.postgres.appUsername`, while the init container uses
the administrator credential only to idempotently provision the non-superuser
application role and its database-local idle transaction timeout.
Agent PostgreSQL sessions set `idle_in_transaction_session_timeout` through the
connection string. The default is `60s`, configurable with
`sharedInfra.postgres.idleInTransactionSessionTimeout`. This is a database-side
safety net for leaked idle transactions and does not change database users,
passwords, roles, or the PostgreSQL StatefulSet credential model.
Example:
@@ -21,6 +20,5 @@ helm upgrade --install mixingx-agent-workshop-a ./charts/mixingx-agent-unit \
--set site=workshop-a \
--set nodeName=agent-node-01 \
--set storage.className=longhorn \
--set sharedInfra.postgres.appUsername=agent_workshop_a \
--set tag=2026.07.02-abc1234
```
@@ -1,99 +0,0 @@
\set ON_ERROR_STOP on
\getenv agent_username AGENT_DB_USERNAME
\getenv agent_password AGENT_DB_PASSWORD
\getenv database_name POSTGRESQL_DATABASENAME
\getenv idle_timeout IDLE_IN_TRANSACTION_SESSION_TIMEOUT
SELECT format(
'CREATE ROLE %I LOGIN PASSWORD %L NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS',
:'agent_username',
:'agent_password')
WHERE NOT EXISTS (
SELECT 1
FROM pg_roles
WHERE rolname = :'agent_username')
\gexec
SELECT format(
'ALTER ROLE %I WITH LOGIN PASSWORD %L NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS',
:'agent_username',
:'agent_password')
\gexec
SELECT format('GRANT CONNECT ON DATABASE %I TO %I', :'database_name', :'agent_username')
\gexec
SELECT format('ALTER DATABASE %I OWNER TO %I', :'database_name', :'agent_username')
\gexec
SELECT format('ALTER SCHEMA public OWNER TO %I', :'agent_username')
\gexec
SELECT format('GRANT ALL ON SCHEMA public TO %I', :'agent_username')
\gexec
-- Existing installations may have objects created by the former postgres application login.
-- Transfer only user objects in public; extension-owned objects remain with their extension owner.
SELECT format(
'ALTER %s %I.%I OWNER TO %I',
CASE c.relkind
WHEN 'r' THEN 'TABLE'
WHEN 'p' THEN 'TABLE'
WHEN 'S' THEN 'SEQUENCE'
WHEN 'v' THEN 'VIEW'
WHEN 'm' THEN 'MATERIALIZED VIEW'
WHEN 'f' THEN 'FOREIGN TABLE'
END,
n.nspname,
c.relname,
:'agent_username')
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = 'public'
AND c.relkind IN ('r', 'p', 'S', 'v', 'm', 'f')
AND pg_get_userbyid(c.relowner) <> :'agent_username'
AND NOT EXISTS (
SELECT 1
FROM pg_depend d
WHERE d.classid = 'pg_class'::regclass
AND d.objid = c.oid
AND d.deptype = 'e')
\gexec
SELECT format(
'ALTER %s %I.%I(%s) OWNER TO %I',
CASE p.prokind
WHEN 'p' THEN 'PROCEDURE'
ELSE 'FUNCTION'
END,
n.nspname,
p.proname,
pg_get_function_identity_arguments(p.oid),
:'agent_username')
FROM pg_proc p
JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE n.nspname = 'public'
AND p.prokind IN ('f', 'p', 'w')
AND pg_get_userbyid(p.proowner) <> :'agent_username'
AND NOT EXISTS (
SELECT 1
FROM pg_depend d
WHERE d.classid = 'pg_proc'::regclass
AND d.objid = p.oid
AND d.deptype = 'e')
\gexec
SELECT format(
'ALTER ROLE %I IN DATABASE %I SET idle_in_transaction_session_timeout TO %L',
:'agent_username',
:'database_name',
:'idle_timeout')
\gexec
-- Startup migrations run as the database owner. Keep active migration and maintenance work
-- unbounded here; only idle transactions receive the safety timeout.
SELECT format('ALTER ROLE %I IN DATABASE %I RESET statement_timeout', :'agent_username', :'database_name')
\gexec
SELECT format('ALTER ROLE %I IN DATABASE %I RESET lock_timeout', :'agent_username', :'database_name')
\gexec
@@ -14,10 +14,6 @@
{{- .Values.serviceId | default (include "mixingx-unit.name" .) -}}
{{- end -}}
{{- define "mixingx-unit.postgresCredentialsSecretName" -}}
{{- .Values.sharedInfra.postgres.credentialsSecret.name | default (printf "%s-postgres-credentials" (include "mixingx-unit.name" .)) -}}
{{- end -}}
{{- define "mixingx-unit.basePath" -}}
{{- printf "/%s-%s" .Values.role (.Values.site | toString) -}}
{{- end -}}
@@ -63,8 +59,7 @@ REDIS_HOST: "{{ .Values.sharedInfra.redis.host }}"
REDIS_PORT: "{{ .Values.sharedInfra.redis.port }}"
POSTGRESQL_HOST: "{{ $pgHost }}"
POSTGRESQL_PORT: "{{ .Values.sharedInfra.postgres.port }}"
POSTGRESQL_USERNAME: "{{ .Values.sharedInfra.postgres.appUsername }}"
POSTGRESQL_DATABASENAME: "{{ include "mixingx-unit.database" . }}"
POSTGRESQL_USERNAME: "{{ .Values.sharedInfra.postgres.username }}"
MESSAGING_HOST: "{{ .Values.sharedInfra.rabbitmq.host }}"
MESSAGING_PORT: "{{ .Values.sharedInfra.rabbitmq.port }}"
MESSAGING_USERNAME: "{{ .Values.sharedInfra.rabbitmq.username }}"
@@ -1,12 +0,0 @@
{{- $name := include "mixingx-unit.name" . -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $name }}-postgres-role-provisioning
labels:
app.kubernetes.io/name: mixingx
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: {{ $name }}-postgres
data:
provision-agent-role.sql: |
{{ .Files.Get "files/provision-agent-role.sql" | nindent 4 }}
@@ -4,7 +4,6 @@
{{- $serviceId := include "mixingx-unit.serviceId" . -}}
{{- $basePath := include "mixingx-unit.basePath" . -}}
{{- $pgHost := printf "%s-postgres-service" $name -}}
{{- $pgCredentialsSecretName := include "mixingx-unit.postgresCredentialsSecretName" . -}}
---
apiVersion: apps/v1
kind: Deployment
@@ -25,58 +24,12 @@ spec:
app.kubernetes.io/component: {{ $name }}
annotations:
checksum/config: {{ include "mixingx-unit.backendConfigData" . | sha256sum }}
checksum/postgres-role-sql: {{ .Files.Get "files/provision-agent-role.sql" | sha256sum }}
spec:
{{ include "mixingx-unit.backendScheduling" . | nindent 6 }}
initContainers:
- name: provision-postgres-role
image: {{ .Values.images.postgres.repository }}:{{ .Values.images.postgres.tag | default "latest" }}
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-ec"]
args:
- |
attempt=0
until pg_isready --host="$POSTGRESQL_HOST" --port="$POSTGRESQL_PORT" --username="$POSTGRES_ADMIN_USERNAME" --dbname="$POSTGRESQL_DATABASENAME"; do
attempt=$((attempt + 1))
if [ "$attempt" -ge 60 ]; then
echo "PostgreSQL did not become ready within 120 seconds" >&2
exit 1
fi
sleep 2
done
exec psql \
--host="$POSTGRESQL_HOST" \
--port="$POSTGRESQL_PORT" \
--username="$POSTGRES_ADMIN_USERNAME" \
--dbname="$POSTGRESQL_DATABASENAME" \
--file=/opt/mixingx/postgres/provision-agent-role.sql
env:
- name: POSTGRESQL_HOST
value: "{{ $pgHost }}"
- name: POSTGRESQL_PORT
value: "{{ .Values.sharedInfra.postgres.port }}"
- name: POSTGRESQL_DATABASENAME
value: "{{ $database }}"
- name: POSTGRES_ADMIN_USERNAME
value: "{{ .Values.sharedInfra.postgres.adminUsername }}"
- name: AGENT_DB_USERNAME
value: "{{ .Values.sharedInfra.postgres.appUsername }}"
- name: IDLE_IN_TRANSACTION_SESSION_TIMEOUT
value: "{{ .Values.sharedInfra.postgres.idleInTransactionSessionTimeout }}"
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ $pgCredentialsSecretName }}
key: {{ .Values.sharedInfra.postgres.credentialsSecret.adminPasswordKey }}
- name: AGENT_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ $pgCredentialsSecretName }}
key: {{ .Values.sharedInfra.postgres.credentialsSecret.appPasswordKey }}
volumeMounts:
- name: postgres-role-provisioning
mountPath: /opt/mixingx/postgres
readOnly: true
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $name }}
{{ $backendImg := .Values.images.backend }}
@@ -97,16 +50,6 @@ spec:
env:
- name: TZ
value: "{{ .Values.timezone | default "Asia/Shanghai" }}"
- name: ConnectionStrings__PostgreSQL
valueFrom:
secretKeyRef:
name: {{ $pgCredentialsSecretName }}
key: {{ .Values.sharedInfra.postgres.credentialsSecret.connectionStringKey }}
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ $pgCredentialsSecretName }}
key: {{ .Values.sharedInfra.postgres.credentialsSecret.appPasswordKey }}
livenessProbe:
httpGet:
path: /health
@@ -123,10 +66,6 @@ spec:
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 8
volumes:
- name: postgres-role-provisioning
configMap:
name: {{ $name }}-postgres-role-provisioning
---
apiVersion: v1
kind: Service
@@ -164,6 +103,10 @@ stringData:
ConnectionStrings__redis: "{{ .Values.sharedInfra.redis.host }}:{{ .Values.sharedInfra.redis.port }},password={{ .Values.sharedInfra.redis.password }}"
REDIS_PASSWORD: "{{ .Values.sharedInfra.redis.password }}"
REDIS_URI: "redis://:{{ .Values.sharedInfra.redis.password }}@{{ .Values.sharedInfra.redis.host }}:{{ .Values.sharedInfra.redis.port }}"
ConnectionStrings__PostgreSQL: "Host={{ $pgHost }};Port={{ .Values.sharedInfra.postgres.port }};Username={{ .Values.sharedInfra.postgres.username }};Password={{ .Values.sharedInfra.postgres.password }};Database={{ $database }};Options=-c idle_in_transaction_session_timeout={{ .Values.sharedInfra.postgres.idleInTransactionSessionTimeout }}"
POSTGRESQL_PASSWORD: "{{ .Values.sharedInfra.postgres.password }}"
POSTGRESQL_URI: "postgresql://{{ .Values.sharedInfra.postgres.username }}:{{ .Values.sharedInfra.postgres.password }}@{{ $pgHost }}:{{ .Values.sharedInfra.postgres.port }}/{{ $database }}"
POSTGRESQL_DATABASENAME: "{{ $database }}"
ConnectionStrings__messaging: "amqp://{{ .Values.sharedInfra.rabbitmq.username }}:{{ .Values.sharedInfra.rabbitmq.password }}@{{ .Values.sharedInfra.rabbitmq.host }}:{{ .Values.sharedInfra.rabbitmq.port }}"
MESSAGING_PASSWORD: "{{ .Values.sharedInfra.rabbitmq.password }}"
MESSAGING_URI: "amqp://{{ .Values.sharedInfra.rabbitmq.username }}:{{ .Values.sharedInfra.rabbitmq.password }}@{{ .Values.sharedInfra.rabbitmq.host }}:{{ .Values.sharedInfra.rabbitmq.port }}"
@@ -191,6 +134,10 @@ spec:
app.kubernetes.io/component: {{ $webName }}
spec:
{{ include "mixingx-unit.followerScheduling" . | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $webName }}
{{ $frontendImg := .Values.images.frontend }}
@@ -261,20 +208,21 @@ spec:
app.kubernetes.io/component: {{ $name }}-postgres
spec:
{{ include "mixingx-unit.followerScheduling" . | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: postgres
image: {{ .Values.images.postgres.repository }}:{{ .Values.images.postgres.tag | default "latest" }}
imagePullPolicy: IfNotPresent
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ $pgCredentialsSecretName }}
key: {{ .Values.sharedInfra.postgres.credentialsSecret.adminPasswordKey }}
value: "{{ .Values.sharedInfra.postgres.password }}"
- name: POSTGRES_DB
value: "{{ $database }}"
- name: POSTGRES_USER
value: "{{ .Values.sharedInfra.postgres.adminUsername }}"
value: "{{ .Values.sharedInfra.postgres.username }}"
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
ports:
@@ -1,6 +1,9 @@
registry: 192.168.1.105:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
role: agent
site: "0"
@@ -42,16 +45,10 @@ sharedInfra:
host: ultra-service
port: 8080
postgres:
adminUsername: postgres
appUsername: agent_runtime
username: postgres
password: "Admin12345"
port: 5432
idleInTransactionSessionTimeout: 60s
credentialsSecret:
# Leave empty to use <role>-<site>-postgres-credentials.
name: ""
adminPasswordKey: admin-password
appPasswordKey: app-password
connectionStringKey: connection-string
redis:
host: redis-service
port: 6379
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-audit
description: MixingX audit service.
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -32,6 +32,10 @@ spec:
app.kubernetes.io/component: {{ .Values.audit.database }}-postgres
spec:
{{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: postgres
image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }}
@@ -22,6 +22,10 @@ spec:
app.kubernetes.io/component: audit-nanomq
spec:
{{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: nanomq
image: {{ .Values.audit.mqtt.image | default "emqx/nanomq:0.25.2-2" }}
@@ -20,6 +20,10 @@ spec:
app.kubernetes.io/component: audit-web
spec:
{{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: audit-web
image: "{{ .Values.registry }}/{{ .Values.images.auditWeb.repository | default "audit-web" }}:{{ .Values.images.auditWeb.tag | default .Values.tag | default "latest" }}"
@@ -19,6 +19,10 @@ spec:
app.kubernetes.io/component: audit
spec:
{{ include "mixingx-audit.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: audit
image: "{{ .Values.registry }}/{{ .Values.images.audit.repository | default "audit" }}:{{ .Values.images.audit.tag | default .Values.tag | default "latest" }}"
+3
View File
@@ -1,6 +1,9 @@
registry: 192.168.1.105:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
storage:
className: local-path
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-edge-unit
description: "One MixingX edge unit release with durable local revision storage."
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -23,6 +23,10 @@ spec:
app.kubernetes.io/component: {{ $brokerName }}
spec:
{{ include "mixingx-unit.backendScheduling" . | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: nanomq
image: "{{ .Values.mqtt.image.repository }}:{{ .Values.mqtt.image.tag }}"
@@ -55,6 +55,10 @@ spec:
secret:
secretName: {{ required "edgeSecrets.mounts[].secretName is required" $secret.secretName | quote }}
{{- end }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $name }}
{{ $backendImg := .Values.images.backend }}
@@ -167,6 +171,10 @@ spec:
app.kubernetes.io/component: {{ $webName }}
spec:
{{ include "mixingx-unit.followerScheduling" . | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $webName }}
{{ $frontendImg := .Values.images.frontend }}
@@ -1,6 +1,9 @@
registry: 192.168.1.105:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
role: edge
site: "0"
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-gateway
description: MixingX gateway service, RBAC, and root ingress.
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -26,6 +26,10 @@ spec:
serviceAccountName: gateway-sa
{{- end }}
{{ include "mixingx-gateway.tierAffinity" (dict "role" "gateway" "root" $) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: gateway
image: {{ .Values.registry }}/{{ $gatewayImage.repository | default "gateway" }}:{{ $gatewayImage.tag | default .Values.tag | default "latest" }}
@@ -1,6 +1,9 @@
registry: 192.168.1.119:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
storage:
className: local-path
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-infra
description: MixingX shared infrastructure services (Redis, MongoDB, RabbitMQ).
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -31,6 +31,10 @@ spec:
app.kubernetes.io/component: {{ .name }}
spec:
{{ include "mixingx-infra.tierAffinity" (dict "role" "sharedDatastores" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .name }}
image: {{ .image }}
+3
View File
@@ -1,6 +1,9 @@
registry: 192.168.1.105:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
storage:
className: local-path
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-mqttx
description: MixingX MQTTX Web — 浏览器端 MQTT 客户端,用于监控/调试各 Edge 的 NanoMQ broker。
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -19,6 +19,10 @@ spec:
labels:
app.kubernetes.io/component: {{ $name }}
spec:
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $name }}
image: "{{ .Values.mqttx.image.repository }}:{{ .Values.mqttx.image.tag | default "latest" }}"
+3
View File
@@ -10,6 +10,9 @@
# Ingress:demo 环境有 *.mixingx.local DNS,用 host 暴露;无 DNS 的现场改用 NodePort。
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
mqttx:
name: mqttx
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-network-agent
description: "MixingX network console agent: 每节点常驻,提供主机网口(IP/掩码/网关/DNS)与 WiFi 的可视化配置 API。"
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -29,6 +29,10 @@ spec:
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: network-agent
image: {{ .Values.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}
@@ -51,13 +55,10 @@ spec:
- name: K3S_RESTART_ON_IP_CHANGE
value: {{ .Values.k3sRestartOnIpChange | quote }}
securityContext:
# 只需 root + D-Bus socket,无需 privileged
# NET_ADMIN: 清除切换静态后残留的动态地址(ip addr del 需要此能力)
# 只需 root + D-Bus socket,无需 privileged 与额外 capability:
# nmcli 经 D-Bus 操作主机 NM,特权动作(改 IP/路由)全部由 NM 进程执行
runAsUser: 0
allowPrivilegeEscalation: false
capabilities:
add:
- NET_ADMIN
livenessProbe:
httpGet:
path: /api/network/health
@@ -80,15 +81,15 @@ spec:
# 主机 system bus: nmcli 与 systemd 重启都走它
- name: dbus
mountPath: /run/dbus/system_bus_socket
- name: nm-run
mountPath: /run/NetworkManager
readOnly: true
# 网卡别名持久化: aliases.json 落宿主机,重启/重建 Pod 均保留
- name: alias-store
mountPath: /var/lib/mixingx/network-agent
volumes:
- name: dbus
hostPath:
path: /run/dbus/system_bus_socket
type: Socket
- name: nm-run
- name: alias-store
hostPath:
path: /run/NetworkManager
path: /var/lib/mixingx/network-agent
type: DirectoryOrCreate
@@ -1,6 +1,8 @@
# Headless 诊断服务: DNS network-agent 返回各节点 agent 的全部地址。
# 注意: 每个 agent 只管理自己所在节点,不要用普通 ClusterIP Service 访问
# (会在节点间随机负载均衡导致操作到错误的主机)。前端弹窗始终直连节点 IP。
# mixingx.io/role 标签让 Gateway 发现该服务并生成 /api/network/** 透传路由,
# 前端网络设置弹窗经 Gateway 同源转发访问(消除跨域)。
apiVersion: v1
kind: Service
metadata:
@@ -8,6 +10,8 @@ metadata:
labels:
app.kubernetes.io/name: mixingx
app.kubernetes.io/component: network-agent
mixingx.io/role: network-agent
mixingx.io/node-id: network-agent
spec:
clusterIP: None
selector:
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-platform
description: MixingX central platform services without customer edge/agent instances.
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -25,6 +25,10 @@ spec:
serviceAccountName: gateway-sa
{{- end }}
{{ include "mixingx-platform.tierAffinity" (dict "role" .role "root" $root) | nindent 6 }}
{{- with $root.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .name }}
image: {{ $root.Values.registry }}/{{ .image }}:{{ $root.Values.tag | default "latest" }}
@@ -156,6 +160,10 @@ spec:
app.kubernetes.io/component: {{ .name }}
spec:
{{ include "mixingx-platform.tierAffinity" (dict "role" .tierRole "root" $root) | nindent 6 }}
{{- with $root.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .name }}
image: {{ $root.Values.registry }}/{{ .image }}:{{ $root.Values.tag | default "latest" }}
@@ -224,6 +232,10 @@ spec:
app.kubernetes.io/component: {{ .name }}-postgres
spec:
{{ include "mixingx-platform.tierAffinity" (dict "role" .tierRole "root" $root) | nindent 6 }}
{{- with $root.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: postgres
image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }}
@@ -20,6 +20,10 @@ spec:
app.kubernetes.io/component: audit
spec:
{{ include "mixingx-platform.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: audit
image: "{{ .Values.registry }}/{{ .Values.audit.image }}:{{ .Values.tag | default "latest" }}"
@@ -141,6 +145,10 @@ spec:
app.kubernetes.io/component: {{ .Values.audit.webName }}
spec:
{{ include "mixingx-platform.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Values.audit.webName }}
image: "{{ .Values.registry }}/{{ .Values.audit.webImage }}:{{ .Values.tag | default "latest" }}"
@@ -206,6 +214,10 @@ spec:
app.kubernetes.io/component: {{ .Values.audit.database }}-postgres
spec:
{{ include "mixingx-platform.tierAffinity" (dict "role" "audit" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: postgres
image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }}
@@ -31,6 +31,10 @@ spec:
app.kubernetes.io/component: {{ .name }}
spec:
{{ include "mixingx-platform.tierAffinity" (dict "role" "sharedDatastores" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .name }}
image: {{ .image }}
@@ -1,6 +1,9 @@
registry: 192.168.1.105:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
storage:
className: local-path
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-protocol-server-unit
description: Deploy one MixingX edge protocol test server instance.
type: application
version: 0.1.0
appVersion: "1.0.0"
version: 1.0.43
appVersion: "1.0.43"
@@ -24,6 +24,10 @@ spec:
{{ toYaml . | nindent 8 }}
{{- end }}
{{- $proto := index .Values.images.protocol .Values.type }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: protocol-server
image: {{ .Values.registry }}/{{ $proto.repository | default .Values.image }}:{{ $proto.tag | default .Values.tag | default "latest" }}
@@ -1,6 +1,9 @@
registry: 192.168.1.105:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
# Legacy image override (kept for backward compatibility).
type: opcua
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-sso
description: MixingX SSO standalone release (backend, web, and PostgreSQL).
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -28,6 +28,10 @@ spec:
app.kubernetes.io/component: {{ $name }}
spec:
{{ include "mixingx-sso.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $name }}
image: {{ $root.Values.registry }}/{{ $root.Values.images.sso.repository | default "sso" }}:{{ $root.Values.images.sso.tag | default $root.Values.tag | default "latest" }}
@@ -126,6 +130,10 @@ spec:
app.kubernetes.io/component: {{ $webName }}
spec:
{{ include "mixingx-sso.tierAffinity" (dict "role" "web" "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $webName }}
image: {{ $root.Values.registry }}/{{ $root.Values.images.ssoWeb.repository | default "sso-web" }}:{{ $root.Values.images.ssoWeb.tag | default $root.Values.tag | default "latest" }}
@@ -190,6 +198,10 @@ spec:
app.kubernetes.io/component: {{ $name }}-postgres
spec:
{{ include "mixingx-sso.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: postgres
image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }}
+3
View File
@@ -1,6 +1,9 @@
registry: 192.168.1.105:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
storage:
className: local-path
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: mixingx-ultra
description: "MixingX Ultra dashboard standalone release: ultra backend, ultra web, and ultra PostgreSQL."
type: application
version: 0.1.0
appVersion: "1.0.1"
version: 1.0.43
appVersion: "1.0.43"
@@ -33,6 +33,10 @@ spec:
app.kubernetes.io/component: {{ $name }}
spec:
{{ include "mixingx-ultra.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $name }}
image: {{ $root.Values.registry }}/{{ $root.Values.images.ultra.repository | default "ultra" }}:{{ $root.Values.images.ultra.tag | default $root.Values.tag | default "latest" }}
@@ -129,6 +133,10 @@ spec:
app.kubernetes.io/component: {{ $name }}-web
spec:
{{ include "mixingx-ultra.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ $name }}-web
image: {{ $root.Values.registry }}/{{ $root.Values.images.ultraWeb.repository | default "ultra-web" }}:{{ $root.Values.images.ultraWeb.tag | default $root.Values.tag | default "latest" }}
@@ -193,6 +201,10 @@ spec:
app.kubernetes.io/component: {{ $name }}-postgres
spec:
{{ include "mixingx-ultra.tierAffinity" (dict "role" $role "root" $root) | nindent 6 }}
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: postgres
image: {{ $root.Values.sharedInfra.postgres.image | default "docker.io/library/postgres:17" }}
+3
View File
@@ -1,6 +1,9 @@
registry: 192.168.1.105:8888/mixingx
tag: latest
timezone: Asia/Shanghai
# 客户环境由 environments/_common 注入 imagePullSecrets(ADR-0066);内网留空=匿名拉取,行为不变
imagePullSecrets: []
storage:
className: local-path
-112
View File
@@ -1,112 +0,0 @@
#!/usr/bin/env bash
# ============================================================================
# provision-host.sh — MixingX network-agent 主机初始化 (Ubuntu Server 20.04+)
#
# 职责(幂等,可重复执行):
# 1. 安装并启动 NetworkManager(服务器版默认未装)
# 2. 读取主网口当前网络参数,预创建等值静态 NM 连接(切换前后地址不变,不断网)
# 3. 创建低优先级 DHCP 救援连接(静态配错时的主机侧兜底)
# 4. 禁用 cloud-init 网络管理,netplan renderer 切换为 NetworkManager
# 5. rfkill 解锁无线网卡
# 6. 安装 polkit 放行规则(容器内 root 调用 NM/systemd D-Bus)
#
# 用法: sudo bash provision-host.sh
# 回滚: sudo bash rollback-host.sh
# 备份: /var/backups/mixingx-netconsole/
# ============================================================================
set -euo pipefail
BACKUP_DIR=/var/backups/mixingx-netconsole
log() { echo -e "\033[32m[mixingx]\033[0m $*"; }
die() { echo -e "\033[31m[mixingx] 错误: $*\033[0m" >&2; exit 1; }
[[ $EUID -eq 0 ]] || die "请用 root 运行: sudo bash $0"
command -v ip >/dev/null 2>&1 || die "缺少 ip 命令"
mkdir -p "$BACKUP_DIR"
# ── 1. 安装 NetworkManager ────────────────────────────────────────────────
if ! command -v nmcli >/dev/null 2>&1; then
log "安装 NetworkManager ..."
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq network-manager
fi
# 关闭 NM 自动建连(未配置网卡自动 DHCP),避免与现有 networkd 抢接口
mkdir -p /etc/NetworkManager/conf.d
cat > /etc/NetworkManager/conf.d/99-mixingx.conf <<'EOF'
[main]
no-auto-default=*
EOF
systemctl enable --now NetworkManager >/dev/null 2>&1 || true
# ── 2. 识别主网口并读取当前参数 ───────────────────────────────────────────
PRIMARY_IF=$(ip -4 route show default | awk '{print $5; exit}')
[[ -n "${PRIMARY_IF:-}" ]] || die "未找到默认路由网卡(主机当前无网络?)"
PRIMARY_TYPE=$(ip link show "$PRIMARY_IF" | grep -o 'link/[a-z]*' | head -1)
CUR_ADDR=$(ip -4 addr show dev "$PRIMARY_IF" | awk '/inet /{print $2; exit}') # x.x.x.x/前缀
CUR_GW=$(ip -4 route show default | awk '{print $3; exit}')
CUR_DNS4=$(grep -h '^nameserver' /run/systemd/resolve/resolv.conf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf 2>/dev/null \
| awk '{print $2}' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' | sort -u | tr '\n' ' ')
log "主网口 $PRIMARY_IF 当前: 地址=$CUR_ADDR 网关=$CUR_GW DNS4=${CUR_DNS4:-<无>}"
# ── 3. 救援连接(仅以太网主口;WiFi 主口跳过——救援 DHCP 对 WiFi 无意义) ────
if [[ "$PRIMARY_TYPE" == "ethernet"* ]]; then
if ! nmcli connection show "rescue-dhcp" >/dev/null 2>&1; then
log "创建救援 DHCP 连接 rescue-dhcp (autoconnect-priority -100)"
nmcli connection add type ethernet ifname "$PRIMARY_IF" con-name "rescue-dhcp" \
ipv4.method auto \
connection.autoconnect yes \
connection.autoconnect-priority -100 >/dev/null
fi
fi
# ── 4. 全局切换 netplan renderer → NetworkManager ────────────────────────
# 不删除原 netplan 配置(ethernet/wifi 定义、SSID/PSK 原样保留),
# netplan 会把原有连接定义自动渲染为等值的 NM profiles,无缝接管
if [[ ! -f /etc/netplan/90-mixingx-nm.yaml ]]; then
log "备份原 netplan 配置 → $BACKUP_DIR/netplan/"
mkdir -p "$BACKUP_DIR/netplan"
cp -a /etc/netplan/*.yaml "$BACKUP_DIR/netplan/" 2>/dev/null || true
log "禁用 cloud-init 网络管理"
mkdir -p /etc/cloud/cloud.cfg.d
echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
log "写入全局 renderer=NetworkManager"
cat > /etc/netplan/90-mixingx-nm.yaml <<'EOF'
network:
version: 2
renderer: NetworkManager
EOF
chmod 600 /etc/netplan/90-mixingx-nm.yaml
fi
log "应用 netplan (交给 NetworkManager 托管)..."
netplan apply
# ── 5. 无线解锁 + polkit 放行 ─────────────────────────────────────────────
rfkill unblock all 2>/dev/null || true
if command -v pkexec >/dev/null 2>&1 || dpkg -s policykit-1 >/dev/null 2>&1; then
mkdir -p /etc/polkit-1/localauthority/50-local.d
cat > /etc/polkit-1/localauthority/50-local.d/49-mixingx-network-agent.pkla <<'EOF'
[MixingX Network Agent]
Identity=unix-user:root
Action=org.freedesktop.NetworkManager.*;org.freedesktop.systemd1.*
ResultAny=yes
ResultInactive=yes
ResultActive=yes
EOF
fi
# ── 6. 校验 ───────────────────────────────────────────────────────────────
sleep 3
log "当前设备状态:"
nmcli -g DEVICE,TYPE,STATE,CONNECTION device status
log "主网口地址: $(ip -4 addr show dev "$PRIMARY_IF" | awk '/inet /{print $2}')"
log "完成。后续用 k3s 弹窗或 nmcli 管理;回滚执行 rollback-host.sh"
-48
View File
@@ -1,48 +0,0 @@
#!/usr/bin/env bash
# ============================================================================
# rollback-host.sh — provision-host.sh 的反向操作
#
# 职责:
# 1. 恢复原 netplan 配置(从 /var/backups/mixingx-netconsole/netplan/)
# 2. 恢复 cloud-init 网络管理
# 3. 停用 NetworkManager 托管(服务禁用,连接配置保留)
# 4. 移除 polkit 放行规则
#
# 用法: sudo bash rollback-host.sh
# ============================================================================
set -euo pipefail
BACKUP_DIR=/var/backups/mixingx-netconsole
log() { echo -e "\033[32m[mixingx]\033[0m $*"; }
die() { echo -e "\033[31m[mixingx] 错误: $*\033[0m" >&2; exit 1; }
[[ $EUID -eq 0 ]] || die "请用 root 运行: sudo bash $0"
# ── 1. 恢复 netplan ───────────────────────────────────────────────────────
if [[ -d "$BACKUP_DIR/netplan" ]] && ls "$BACKUP_DIR/netplan"/*.yaml >/dev/null 2>&1; then
log "恢复备份的 netplan 配置"
rm -f /etc/netplan/90-mixingx-nm.yaml
cp -a "$BACKUP_DIR/netplan"/*.yaml /etc/netplan/
else
log "无备份,仅移除 NM renderer 配置(回退到 renderer 默认)"
rm -f /etc/netplan/90-mixingx-nm.yaml
fi
# ── 2. 恢复 cloud-init 网络管理 ───────────────────────────────────────────
rm -f /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
log "应用恢复的 netplan ..."
netplan apply
# ── 3. 停用 NetworkManager ────────────────────────────────────────────────
log "停用并禁用 NetworkManager"
systemctl disable --now NetworkManager >/dev/null 2>&1 || true
# ── 4. 移除 polkit 规则 / NM 覆盖配置 ─────────────────────────────────────
rm -f /etc/polkit-1/localauthority/50-local.d/49-mixingx-network-agent.pkla
rm -f /etc/NetworkManager/conf.d/99-mixingx.conf
sleep 3
ip -4 addr show | awk '/inet /{print " " $2 " @ " $NF}'
log "回滚完成。NM 连接配置保留在 /etc/NetworkManager/system-connections/ (可手工清理)"