Files
devops/process.md
2025-09-17 17:41:19 +08:00

80 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

openfeign依据consul中的服务找到对应的pod的ipport。蓝绿怎么做
```mermaid
flowchart TD
subgraph Client Side
A[Spring Boot App with OpenFeign] -->|Call my-service| B[Spring Cloud LoadBalancer]
end
subgraph Consul
B -->|Query my-service instances| C[Consul Service Discovery]
C -->|Return instances with tags/meta| D[Instance List with version info]
end
subgraph K8s Cluster
D -->|Filter version=blue/green| E[Service Selector / LoadBalancer]
subgraph Blue Deployment
E --> F[Pod Blue 1]
E --> G[Pod Blue 2]
end
subgraph Green Deployment
E --> H[Pod Green 1]
E --> I[Pod Green 2]
end
end
%% Optional: Gateway / Ingress for traffic control
subgraph Gateway/Ingress Layer
J[Ingress / Service Mesh] -.-> E
J -->|Route 90% blue, 10% green| F
J -->|Route 90% blue, 10% green| H
end
```
❓ 蓝系统weight 0绿系统100%但蓝系统的kafka还在消费topic被蓝系统消费掉了会不会产生问题
没有问题。如果蓝绿规划为同一消费者组,并且消费是密等的,被谁消费掉无所谓。
💡 最佳实践:
1. 蓝绿切换时,不仅切换 HTTP 流量,还要 优雅下线旧版本 Kafka 消费器
2. 消费逻辑保持幂等,避免蓝绿切换引发重复处理
redis: 共享 Redis + 蓝绿系统写入隔离
mysql:
```mermaid
flowchart TD
subgraph Client Side
A[HTTP 请求] -->|流量 0%| B[蓝系统 (旧版本)]
A -->|流量 100%| C[绿系统 (新版本)]
end
subgraph MySQL Cluster
D[(MySQL 主库/集群)]
end
%% 蓝系统行为
B -->|完成旧事务提交| D
B -->|使用旧 schema 字段| D
%% 绿系统行为
C -->|新请求写入| D
C -->|使用新 schema 字段| D
%% 注释
classDef info fill:#f9f,stroke:#333,stroke-width:1px;
B:::info
C:::info
D:::info
%% 说明
subgraph Notes
N1[蓝系统流量为 0但仍完成旧事务确保数据一致性]
N2[蓝绿系统共用 MySQLSchema 需向后兼容]
N3[写操作幂等,避免重复或冲突]
end
```