Files
devops/process.md
2025-09-17 17:42:05 +08:00

2.2 KiB
Raw Blame History

openfeign依据consul中的服务找到对应的pod的ipport。蓝绿怎么做

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:

flowchart TD
    subgraph Client Side
        A[HTTP Request] -->|flow 0 percent| B[Blue System (old version)]
        A -->|flow 100 percent| C[Green System (new version)]
    end

    subgraph MySQL Cluster
        D[(MySQL Primary / Cluster)]
    end

    %% Blue system behavior
    B -->|finish old transactions| D
    B -->|use old schema fields| D

    %% Green system behavior
    C -->|handle new requests| D
    C -->|use new schema fields| D

    %% Notes
    subgraph Notes
        N1[Blue system flow 0 but finishes old transactions to ensure data consistency]
        N2[Blue/Green share MySQL, schema must be backward compatible]
        N3[Write operations should be idempotent to avoid conflicts]
    end