天天看點

Istio 代理應用 getaway

為所有主機開放 80 端口

除了istio: ingressgateway選擇器之外,所有配置項的含義均不言自明。

通過使用這個選擇器,我們可以指定哪個 Ingress 網關使用該配置,在我們的場景中,

也就是在 Istio 安裝時的預設 Ingress 網關控制器。

# cat http-gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: http-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
      - "*"

# kubectl create -f http-gateway.yaml
           
網關已準備好接收流量,必須告知它将收到的流量發往何處,Istio使用名為“VirtualService”類型配置流量發往何處。
将一個網關清單配置給VirtualService,然後Istio使用VirtualService配置中定義的路由再配置那些網關.

VirtualService 資源

VirtualService 能夠指導 Ingress 網關如何路由允許進入叢集的請求

URI路徑字首比對

/

的将發往指定目标

注意: 如果有多個virtualservice檔案,後面的會覆寫前面的,是以要把所有的路由資訊都配置到一個virtualservice

# cat web-virtualservice-external.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: web-app
spec:
  hosts:
  - "*"
  gateways:
  - http-gateway
  http:
  - match:
    - uri:
       exact: /   
    route:
    - destination: 
        host: nginx-web 


# kubectl create -f web-virtualservice-external.yaml             
           

或者隻通路 v1 版本

# vim web-virtualservice-external.yaml 
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: http-web
spec:
  hosts:
  - "*"
  gateways:
  - http-gateway
  http:
  - match:
    - uri:
       exact: /
    route:
    - destination:
        host: nginx-web
        port:
          number: 80
        subset: v1 
           
從外部通路

gateway 把指定的URL 告訴 ingress pod處理。 virtualservice對指定URL進行 service 調用

    1. Gateway: Istio Gateway是負責打開k8s上相關Istio的pods(pod!pod!pod!)上的端口并接收主機的流量,是接收流量與路由之間的關鍵連結。
    1. VirtualService: Istio VirtualService是“附加”到Gateway上的,并負責定義Gateway應實作的路由。可以将多個VirtualServices連接配接到Gateway,但不适用于同一個域
### 有時候配置生效并更新 envoy 緩存會耗費一點時間

curl 10.113.2.179:31380/ 
nodeIP:istio-ingressgateway的nodeport/路徑
           

kiali 監控

Istio 代理應用 getaway

jaeger-ui監控

Istio 代理應用 getaway

Istio Service Graph 監控

Istio 代理應用 getaway

繼續閱讀