7f78e6d543bba54d5caf76eee358afae7eba60c8
\346\234\211\350\276\271\350\275\246\345\215\207\347\272\247\344\270\272\346\227\240\350\276\271\350\275\246\346\214\207\345\274\225.md
... | ... | @@ -1 +1,175 @@ |
1 | -### 1,获取边车路由信息 |
|
... | ... | \ No newline at end of file |
0 | + |
|
1 | + |
|
2 | +# 分布式系统升级技术指引文档 |
|
3 | +--- |
|
4 | + |
|
5 | +## 一、路由信息迁移规范 |
|
6 | +### 1.1 边车路由提取 |
|
7 | +1. **服务访问** |
|
8 | + ```bash |
|
9 | + kubectl -n {namespace} get svc redis-stack # 确认NodePort端口(默认8001) |
|
10 | + ``` |
|
11 | +2. **数据查询** |
|
12 | + 通过RedisInsight执行查询指令: |
|
13 | + ```redis |
|
14 | + SCAN 0 MATCH *statestore||app_key* # 获取全量路由键 |
|
15 | + ``` |
|
16 | +3. **格式转换** |
|
17 | + 使用平台提供的`route-converter`工具进行数据迁移: |
|
18 | + ```bash |
|
19 | + ./converter --input=redis_export.json --output=new_arch_routes.yaml |
|
20 | + ``` |
|
21 | + |
|
22 | +--- |
|
23 | + |
|
24 | +## 二、配置管理标准化 |
|
25 | +### 2.1 命名规范重构 |
|
26 | +| 原配置项 | 新标准配置项 | 变更类型 | |
|
27 | +|-------------------|------------------|----------------| |
|
28 | +| snest-nginx | iidp-nginx | 强制重建 | |
|
29 | +| snest-app | iidp-app | 配置迁移 | |
|
30 | + |
|
31 | +### 2.2 网关配置新增(gw.yaml) |
|
32 | +```yaml |
|
33 | +apiVersion: v1 |
|
34 | +kind: ConfigMap |
|
35 | +metadata: |
|
36 | + name: iidp-gw-config |
|
37 | + namespace: {target_namespace} |
|
38 | +data: |
|
39 | + routing-policy: | |
|
40 | + # 核心路由策略 |
|
41 | + engine.store.meta.mode=CLOUD |
|
42 | + engine.run.mode=DISTRIBUTED_V2 |
|
43 | + image-config: | |
|
44 | + app.install.image=registry.iidp.cn/core/gateway:v3.2.1 |
|
45 | +``` |
|
46 | + |
|
47 | +### 2.3 应用配置迁移 |
|
48 | +1. **配置文件继承** |
|
49 | + ```bash |
|
50 | + kubectl get cm snest-app -o yaml > iidp-app.yaml |
|
51 | + sed -i 's/snest-app/iidp-app/g' iidp-app.yaml |
|
52 | + ``` |
|
53 | +2. **关键参数注入** |
|
54 | + 在`application-dev.properties`追加: |
|
55 | + ```properties |
|
56 | + # 分布式模式配置 |
|
57 | + cluster.node.ttl=300s |
|
58 | + service.discovery.interval=30s |
|
59 | + ``` |
|
60 | + |
|
61 | +--- |
|
62 | + |
|
63 | +## 三、服务声明更新流程 |
|
64 | +### 3.1 服务依赖声明 |
|
65 | +```yaml |
|
66 | +# iidp-core-services.yaml |
|
67 | +apiVersion: iidp.io/v1beta1 |
|
68 | +kind: ServiceDefinition |
|
69 | +spec: |
|
70 | + components: |
|
71 | + - name: iidp |
|
72 | + dependencies: "" |
|
73 | + installedApps: |
|
74 | + - newSdkApp.master |
|
75 | + - oppmApp.master |
|
76 | + - sf-auto-interface-app.master |
|
77 | + - name: iiot |
|
78 | + dependencies: |
|
79 | + - iiot_apiAdapter.master |
|
80 | + - iiot_base.master |
|
81 | + installedApps: |
|
82 | + - iiot_project.master |
|
83 | + - iiot_access.master |
|
84 | +``` |
|
85 | + |
|
86 | +### 3.2 版本控制策略 |
|
87 | +1. 使用GitOps进行配置版本管理 |
|
88 | +2. 每次变更需生成新的`configVersion`标签 |
|
89 | + ```yaml |
|
90 | + metadata: |
|
91 | + annotations: |
|
92 | + iidp.com/configVersion: 20250318-01 |
|
93 | + ``` |
|
94 | + |
|
95 | +--- |
|
96 | + |
|
97 | +## 四、网关部署验证 |
|
98 | +### 4.1 滚动更新操作 |
|
99 | +```bash |
|
100 | +kubectl scale deployment nginx --replicas=0 # 停止旧网关 |
|
101 | +kubectl apply -f gw.yaml --dry-run=server # 预校验配置 |
|
102 | +``` |
|
103 | + |
|
104 | +### 4.2 存储优化配置 |
|
105 | +```yaml |
|
106 | +volumes: |
|
107 | + - name: uds-socket |
|
108 | + emptyDir: |
|
109 | + medium: Memory # 启用内存存储提升性能 |
|
110 | +``` |
|
111 | + |
|
112 | +### 4.3 连通性验证 |
|
113 | +```bash |
|
114 | +# 路由信息验证 |
|
115 | +curl -sS localhost:8060/route | jq . # 预期包含所有注册应用 |
|
116 | +# 服务映射检查 |
|
117 | +curl -sS localhost:8060/svc2app | grep "mbm-main.master" |
|
118 | +# 端点健康状态 |
|
119 | +curl -sS localhost:8060/endpoints | jq '.[].status' |
|
120 | +``` |
|
121 | + |
|
122 | +--- |
|
123 | + |
|
124 | +## 五、业务POD迁移方案 |
|
125 | +### 5.1 停机迁移步骤 |
|
126 | +1. **前置操作** |
|
127 | + ```bash |
|
128 | + kubectl scale deployment {service} --replicas=0 |
|
129 | + ``` |
|
130 | +2. **配置清理** |
|
131 | + 删除旧版dapr注解: |
|
132 | + ```yaml |
|
133 | + annotations: |
|
134 | + - dapr.io/enabled: "false" # 禁用遗留sidecar |
|
135 | + ``` |
|
136 | + |
|
137 | +### 5.2 启动验证标准 |
|
138 | +1. **日志监控关键点** |
|
139 | + ```bash |
|
140 | + kubectl logs -f {pod_name} | grep -E "IIDP_ENGINE_READY|CLUSTER_SYNC_COMPLETED" |
|
141 | + ``` |
|
142 | +2. **就绪探针配置** |
|
143 | + ```yaml |
|
144 | + readinessProbe: |
|
145 | + httpGet: |
|
146 | + path: /healthz |
|
147 | + port: 8080 |
|
148 | + initialDelaySeconds: 20 |
|
149 | + ``` |
|
150 | + |
|
151 | +--- |
|
152 | + |
|
153 | +## 六、回退与监控方案 |
|
154 | +### 6.1 快速回退机制 |
|
155 | +```bash |
|
156 | +# 配置回滚命令 |
|
157 | +kubectl rollout undo deployment/iidp-nginx --to-revision=3 |
|
158 | +``` |
|
159 | + |
|
160 | +### 6.2 监控指标阈值 |
|
161 | +| 指标名称 | 告警阈值 | 检测频率 | |
|
162 | +|-------------------------|----------------|----------| |
|
163 | +| 路由同步延迟 | >500ms | 10s | |
|
164 | +| 节点心跳丢失率 | >5% (持续1min)| 30s | |
|
165 | + |
|
166 | +--- |
|
167 | + |
|
168 | +**升级验证清单** |
|
169 | +✅ 所有配置项已按`iidp-`前缀标准化 |
|
170 | +✅ 网关路由接口返回完整服务拓扑 |
|
171 | +✅ 业务POD启动后输出IIDP BANNER |
|
172 | +✅ 旧版sidecar组件已完全移除 |
|
173 | + |
|
174 | +> 注:本方案参考了系统升级文档规范和Kubernetes最佳实践,建议在预发布环境完成全量验证后执行生产环境变更。升级过程中如遇异常,可通过`kubectl describe configmap/iidp-app`检查配置注入状态。 |
|
... | ... | \ No newline at end of file |