Pages - Menu

2022年2月28日 星期一

[isito] 鏡像流量 mirror

前言

測試新版本的好用法,
可以不用怕影響線上服務,
前提是,你要有istio 😆

正文

最近在測試 istio的鏡像流量,
想要針對舊的 websocket 做鏡像將流量導到新版的websocket上面。

實測的結果,websocket不能用。
但http能夠使用,這是由於 istio的鏡像流量是 『 fire and forget'

但websocket 是需要交握後,才能持續進行下面的步驟。
所以導致連線無法建立,但 RESTful的請求,是沒問題的。

先決條件,
2個deployment,分別叫 A 跟 B,
label 使用 version:v1 以及 version: v2 做區別
1個 service ,分別指到這2個deployment

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ws-qa
  namespace: istio
spec:
  hosts:
    - www.abc.com
    - yabo-ws-qa
  gateways:
    - istio-system/istio-gateway-external
    - istio-system/istio-gateway-internal     
  http:
  - match:
      - uri:
          regex: ^/ws/.*
    route:
      - destination:
          host: ws-qa
          subset: v1
          port:
            number: 80
        weight: 100
    mirror:
        host: ws-qa
        subset: v2
    mirrorPercentage: 
        value: 100.0
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
 name: ws-qa
 namespace: istio
spec:
 host: ws-qa
 subsets:
 - labels:
     version: v1
   name: v1
 - labels:
     version: v2
   name: v2         

用任一的壓測軟體,呼叫本來的網站,就會得到下圖的數據。
v2是鏡像流量,流量過去後就不會管是否回應。



ref.

沒有留言:

張貼留言