Clone
架构
wencaiwulue edited this page 2022-02-08 16:17:45 +08:00
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.

链接模式

使用虚拟网卡,添加路由到虚拟网卡,然后在讲收到的流量包通过端口转发建立的隧道,传输到远端流量管理器 pod ,此 pod 去请求要访问的服务,并返回包。

┌─────────────────────┐    ┌──────────┐
│ pod traffic manager ├───►│ ServiceC │
└─────────┌───────────┘    └──────────┘
          │                 │                     cloud
─ ─ ─ ─ ─ ┘─ ─ ─ ─ ─ ─ ─ ─ ─┘─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
          │                 │                     local
     ┌────┘─────┐           │
     │ ServiceB'├───────────┘
     └──────────┘

代理模式

在链接模式的基础上,对 controller 的 pod template spec 注入一个 sidecar使用 iptables 拦截所有入流量,并通过 tunnel 将流量转发到本地。

┌──────────┐    ┌─────────┌──────────┐    ┌──────────┐
│ ServiceA ├───►│ sidecar │ ServiceB │ ┌─►│ ServiceC │
└──────────┘    └────┌────┘──────────┘ │  └──────────┘
                     │                 │
                     │                 │                     cloud
─ ─ ─ ─ ─ ┘─ ─ ─ ─ ─ ┘─ ─ ─ ─ ─ ─ ─ ─ ─┘ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
                     │                 │                     local
                 ┌───┘──────┐          │
                 │ ServiceB'├──────────┘
                 └──────────┘

Mesh 模式

基于代理模式,使用 envoy 作为代理,如果 headers 携带了指定键值对,将会被路由到本地,否则,走原来的业务逻辑。

┌──────────┐    ┌─────────┌────────────┐     ┌──────────┐
│ ServiceA ├───►│ sidecar ├─► ServiceB │─►┌─►│ ServiceC │
└──────────┘    └────┌────┘────────────┘  │  └──────────┘
                     │                    │                     cloud
─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─┘─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
                     │                    │                     local
                header: a=1               │
                 ┌───┘──────┐             │
                 │ ServiceB'├─────────────┘
                 └──────────┘