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
相关推荐
工具罗某人1 小时前
CentOS7安装docker
docker·云原生·centos
北欧人写代码8 小时前
K8s 限制节点内存使用率,内存不足时自动驱逐POD
云原生·容器·kubernetes
塔能物联运维9 小时前
K8s IoT设备自动扩缩容实战
物联网·云原生·容器·kubernetes
工具罗某人11 小时前
docker快速部署启动gitlab
git·docker·云原生·eureka
飞舞花下1 天前
微服务架构栈
微服务·云原生·架构
垂金烟柳1 天前
使用 sealos 部署 k8s
云原生·容器·kubernetes
java1234_小锋1 天前
Zookeeper集群数据是如何同步的?
分布式·zookeeper·云原生
沛沛老爹1 天前
Web开发者实战A2A智能体交互协议:从Web API到AI Agent通信新范式
java·前端·人工智能·云原生·aigc·交互·发展趋势
Wilson Chen1 天前
从“手搓”到云原生:某 B2B 平台服装 AI 搜索架构演进实战
人工智能·云原生·架构
Elastic 中国社区官方博客2 天前
使用 Elastic Cloud Serverless 扩展批量索引
大数据·运维·数据库·elasticsearch·搜索引擎·云原生·serverless