istio中serviceentry结合egressgateway的使用

假设有一个外部服务,外部服务ip为:10.10.102.90,其中32033为v1版本,32034为v2版本。

现在需要把这个服务引入到istio中,并且需要配置所有访问该服务的流量都通过egressgateway转发出去。

serviceentry

复制代码
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: gin-service-entry
spec:
  endpoints:
  - address: 10.10.102.90
    labels:
      version: v1
    ports:
      http: 32033
  - address: 10.10.102.90
    labels:
      version: v2
    ports:
      http: 32034
  hosts:
  - gin.test.ch
  location: MESH_EXTERNAL
  ports:
  - name: http
    number: 80
    protocol: HTTP
  resolution: STATIC

gateway

复制代码
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: gin-egressgateway
spec:
  selector:
    istio: egressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - gin.test.ch

dr

复制代码
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: egressgateway-for-gin
  namespace: istio-system
spec:
  host: istio-egressgateway-1-19-6.istio-system.svc.cluster.local
  subsets:
  - name: gin

vs

复制代码
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: direct-gin-through-egress-gateway
spec:
  gateways:
  - gin-egressgateway
  - mesh
  hosts:
  - gin.test.ch
  http:
  - match:
    - gateways:
      - mesh
      port: 80
    route:
    - destination:
        host: istio-egressgateway-1-19-6.istio-system.svc.cluster.local
        port:
          number: 80
        subset: gin
      weight: 100
  - match:
    - gateways:
      - gin-egressgateway
      port: 80
    route:
    - destination:
        host: gin.test.ch
        port:
          number: 80
      weight: 100
相关推荐
周壮2 小时前
01 一探究竟:从架构的演变看微服务化架构
微服务·云原生·架构
周壮2 小时前
04 服务治理:Nacos 如何实现微服务服务治理
微服务·云原生·架构
雨落秋垣3 小时前
简单的在宝塔面板的Docker环境中为网站同时启用IPv6支持
云原生·eureka
努力搬砖的咸鱼9 小时前
Kubernetes 核心对象详解:Pod、Deployment、Service
微服务·云原生·容器·架构·kubernetes
Chan1610 小时前
【 微服务SpringCloud | 方案设计 】
java·spring boot·微服务·云原生·架构·intellij-idea
Dobby_0511 小时前
【Log】Loki 架构与组件全解析
云原生·loki·可观测
hanyi_qwe11 小时前
Kubernetes 集群调度 【K8S (五)】
云原生·容器·kubernetes
-dcr12 小时前
53.k8s的pod管理
云原生·容器·kubernetes
無森~13 小时前
ZooKeeper
分布式·zookeeper·云原生
Chan1614 小时前
【 微服务SpringCloud | 模块拆分 】
java·数据结构·spring boot·微服务·云原生·架构·intellij-idea