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
相关推荐
没有bug.的程序员14 小时前
Service Mesh 与 Spring Cloud 共存方案:双体系治理、平滑迁移与风险控制实战指南
云原生·springcloud·流量治理·混合架构·servicemesh·微服务迁移·技术演进
一只鱼丸yo14 小时前
从单体到微服务:一次真实迁移实战
微服务·云原生·架构
2501_9399090516 小时前
k8s基础与安装部署
云原生·容器·kubernetes
掘金-我是哪吒19 小时前
Kafka配套的Zookeeper启动脚本
分布式·zookeeper·云原生·kafka
IT 行者19 小时前
微服务架构选型指南:中小型软件公司的理性思考
微服务·云原生·架构
Chan1620 小时前
微服务 - Higress网关
java·spring boot·微服务·云原生·面试·架构·intellij-idea
没有bug.的程序员21 小时前
Serverless 架构深度解析:FaaS/BaaS、冷启动困境与场景适配指南
云原生·架构·serverless·架构设计·冷启动·baas·faas
一条咸鱼_SaltyFish1 天前
[Day13] 微服务架构下的共享基础库设计:contract-common 模块实践
开发语言·人工智能·微服务·云原生·架构·ai编程
原神启动11 天前
K8S(七)—— Kubernetes Pod 基础概念与实战配置
云原生·容器·kubernetes
牛奔1 天前
Docker 容器无法停止的排障与解决全过程
运维·docker·云原生·容器·eureka