前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Mesh4# Envoy中查看ServiceEntry注入信息

Mesh4# Envoy中查看ServiceEntry注入信息

作者头像
瓜农老梁
发布2021-10-27 11:17:14
6660
发布2021-10-27 11:17:14
举报
文章被收录于专栏:瓜农老梁

引言

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

一、ServiceEntry注入工作原理

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

代码语言:javascript
复制
---
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: baidu-external
spec:
  hosts:
    - www.baidu.com
  ports:
    - number: 80
      name: HTTP
      protocol: HTTP
  resolution: DNS
  location: MESH_INTERNAL

2.部署ServiceEntry配置

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

代码语言:javascript
复制
kubectl apply -f serviceentry.yaml -n default
serviceentry.networking.istio.io/baidu-external created

3.Istio中查看ServiceEntry信息

登陆istiod容器

代码语言:javascript
复制
kubectl -n istio-system exec -it istiod-5c4b9cb6b5-6n68m -- /bin/bash

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

代码语言:javascript
复制
istio-proxy@istiod-5c4b9cb6b5-6n68m:/$ curl http://127.0.0.1:15014/debug/registryz
[
  {
    "Attributes": {
      "ServiceRegistry": "External",
      "Name": "www.baidu.com",
      "Namespace": "default",
      "Labels": null,
      "UID": "",
      "ExportTo": null,
      "LabelSelectors": null,
      "ClusterExternalAddresses": null,
      "ClusterExternalPorts": null
    },
    "ports": [
      {
        "name": "HTTP",
        "port": 80,
        "protocol": "HTTP"
      }
    ],
    "creationTime": "2021-10-14T03:01:24Z",
    "hostname": "www.baidu.com",
    "address": "0.0.0.0",
    "autoAllocatedAddress": "240.240.0.5",
    "Mutex": {},
    "Resolution": 1,
    "MeshExternal": false
  },
  // ...
]

4.在Envoy查看xDS信息

代码语言:javascript
复制
istioctl proxy-config route productpage-v1-6b746f74dc-2c55l -n default -o json
[
  //...
  {
                  "name": "www.baidu.com:80",
                  "domains": [
                      "www.baidu.com",
                      "www.baidu.com:80"
                  ],
                  "routes": [
                      {
                          "name": "default",
                          "match": {
                              "prefix": "/"
                          },
                          "route": {
                              "cluster": "outbound|80||www.baidu.com",
                              "timeout": "0s",
                              "retryPolicy": {
                                  "retryOn": "connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes",
                                  "numRetries": 2,
                                  "retryHostPredicate": [
                                      {
                                          "name": "envoy.retry_host_predicates.previous_hosts"
                                      }
                                  ],
                                  "hostSelectionRetryMaxAttempts": "5",
                                  "retriableStatusCodes": [
                                      503
                                  ]
                              },
                              "maxStreamDuration": {
                                  "maxStreamDuration": "0s",
                                  "grpcTimeoutHeaderMax": "0s"
                              }
                          },
                          "decorator": {
                              "operation": "www.baidu.com:80/*"
                          }
                      }
                  ],
                  "includeRequestAttemptCount": true
   }
   // ...         
]

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

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2021-10-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 瓜农老梁 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
服务网格
服务网格(Tencent Cloud Mesh, TCM),一致、可靠、透明的云原生应用通信网络管控基础平台。全面兼容 Istio,集成腾讯云基础设施,提供全托管服务化的支撑能力保障网格生命周期管理。IaaS 组网与监控组件开箱即用,跨集群、异构应用一致发现管理加速云原生迁移。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档