当前位置:首页 >百科 >聊聊 Envoy 中查看 ServiceEntry 注入信息 这些如何注入的中注入

聊聊 Envoy 中查看 ServiceEntry 注入信息 这些如何注入的中注入

2024-06-01 05:24:35 [百科] 来源:避面尹邢网

聊聊 Envoy 中查看 ServiceEntry 注入信息

作者:梁勇 网络 通信技术 在Istio中提供了ServiceEntry的聊聊配置,将网格外的中注入服务纳入网格管理。将第三方注册中心zookeeper、信息nacos等纳入Istio网格可以通过ServiceEntry纳入Istio的聊聊管理。这些如何注入的中注入,流程是信息怎么样,下面通过示例将整个流程窜起来。聊聊

  [[431019]]

引言

在Istio中提供了ServiceEntry的中注入配置,将网格外的信息服务纳入网格管理。将第三方注册中心zookeeper、聊聊nacos等纳入Istio网格可以通过ServiceEntry纳入Istio的中注入管理。这些如何注入的信息,流程是聊聊怎么样,下面通过示例将整个流程窜起来。中注入

聊聊 Envoy 中查看 ServiceEntry 注入信息 这些如何注入的中注入

一、信息ServiceEntry注入工作原理

ServiceEntry注入的流程图

聊聊 Envoy 中查看 ServiceEntry 注入信息 这些如何注入的中注入

聊聊 Envoy 中查看 ServiceEntry 注入信息 这些如何注入的中注入

备注:注入流程如下

@1 将ServiceEntry注入到kube-apiserver中

@2 Istiod中通过kubeConfigController监听ServiceEntry配置的变化

@3 Istiod将ServiceEntry封装成PushRequest发送给XDSServer

@4 XDSServer转换为xDS格式下发给Envoy

二、Envoy中查看ServiceEntry

1.组织ServiceEntry配置

通过ServiceEntry配置baidu域名,将其作为网格服务的一部分serviceentry.yaml

  1. --- 
  2. apiVersion: networking.istio.io/v1alpha3 
  3. kind: ServiceEntry 
  4. metadata: 
  5.   name: baidu-external 
  6. spec: 
  7.   hosts: 
  8.     - www.baidu.com 
  9.   ports: 
  10.     - number: 80 
  11.       name: HTTP 
  12.       protocol: HTTP 
  13.   resolution: DNS 
  14.   location: MESH_INTERNAL 

2.部署ServiceEntry配置

通过下面命令部署到Kubernetes api server中

  1. kubectl apply -f serviceentry.yaml -n default 
  2. serviceentry.networking.istio.io/baidu-external created 

3.Istio中查看ServiceEntry信息

登陆istiod容器

  1. kubectl -n istio-system exec -it istiod-5c4b9cb6b5-6n68m -- /bin/bash 

通过registryz命令查看,已经注入到istio中。

  1. istio-proxy@istiod-5c4b9cb6b5-6n68m:/$ curl http://127.0.0.1:15014/debug/registryz 
  2.   {  
  3.     "Attributes": {  
  4.       "ServiceRegistry": "External", 
  5.       "Name": "www.baidu.com", 
  6.       "Namespace": "default", 
  7.       "Labels": null, 
  8.       "UID": "", 
  9.       "ExportTo": null, 
  10.       "LabelSelectors": null, 
  11.       "ClusterExternalAddresses": null, 
  12.       "ClusterExternalPorts": null 
  13.     }, 
  14.     "ports": [ 
  15.       {  
  16.         "name": "HTTP", 
  17.         "port": 80, 
  18.         "protocol": "HTTP" 
  19.       } 
  20.     ], 
  21.     "creationTime": "2021-10-14T03:01:24Z", 
  22.     "hostname": "www.baidu.com", 
  23.     "address": "0.0.0.0", 
  24.     "autoAllocatedAddress": "240.240.0.5", 
  25.     "Mutex": { }, 
  26.     "Resolution": 1, 
  27.     "MeshExternal": false 
  28.   }, 
  29.   // ... 

4.在Envoy查看xDS信息

  1. istioctl proxy-config route productpage-v1-6b746f74dc-2c55l -n default -o json 
  2.   //... 
  3.   {  
  4.                   "name": "www.baidu.com:80", 
  5.                   "domains": [ 
  6.                       "www.baidu.com", 
  7.                       "www.baidu.com:80" 
  8.                   ], 
  9.                   "routes": [ 
  10.                       {  
  11.                           "name": "default", 
  12.                           "match": {  
  13.                               "prefix": "/" 
  14.                           }, 
  15.                           "route": {  
  16.                               "cluster": "outbound|80||www.baidu.com", 
  17.                               "timeout": "0s", 
  18.                               "retryPolicy": {  
  19.                                   "retryOn": "connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes", 
  20.                                   "numRetries": 2, 
  21.                                   "retryHostPredicate": [ 
  22.                                       {  
  23.                                           "name": "envoy.retry_host_predicates.previous_hosts" 
  24.                                       } 
  25.                                   ], 
  26.                                   "hostSelectionRetryMaxAttempts": "5", 
  27.                                   "retriableStatusCodes": [ 
  28.                                       503 
  29.                                   ] 
  30.                               }, 
  31.                               "maxStreamDuration": {  
  32.                                   "maxStreamDuration": "0s", 
  33.                                   "grpcTimeoutHeaderMax": "0s" 
  34.                               } 
  35.                           }, 
  36.                           "decorator": {  
  37.                               "operation": "www.baidu.com:80/*" 
  38.                           } 
  39.                       } 
  40.                   ], 
  41.                   "includeRequestAttemptCount": true 
  42.    } 
  43.    // ...          

小结:通过上面的命令追踪,ServiceEntry的示例下发到了数据面Envoy中。

责任编辑:武晓燕 来源: 瓜农老梁 信息EnvoyServiceEntry

(责任编辑:探索)

    推荐文章
    热点阅读