Skip to content
wencaiwulue edited this page Feb 8, 2022 · 3 revisions

链接模式

使用虚拟网卡,添加路由到虚拟网卡,然后在讲收到的流量包通过端口转发建立的隧道,传输到远端流量管理器 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'├─────────────┘
                 └──────────┘
Clone this wiki locally