istio中如何使用serviceentry引入外部服务

假设需要引入一个外部服务,外部服务ip为10.10.102.90,端口为32033.

引入到istio中后,我想通过域名gindemo.test.ch:9090来访问这个服务。

serviceentry yaml内容如下:

复制代码
apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: gindemo-service-entry
spec:
  addresses:
  - 10.10.102.90
  endpoints:
  - address: 10.10.102.90
    ports:
      http: 32033
  hosts:
  - gindemo.test.ch
  location: MESH_EXTERNAL
  ports:
  - name: http # 注意,这个名字是不能修改的
    number: 9090
    protocol: HTTP
  resolution: STATIC

引入之后,在sidecar中查询clusters,检查istio是否成功发现该服务

访问服务:

结合vs使用:

复制代码
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: gindemo-virtual-service
spec:
  hosts:
  - gindemo.test.ch
  gateways:
  - mesh
  http:
  - match:
    - port: 80 # 注意,这个端口是不能修改的
    route:
    - destination:
        host: gindemo.test.ch
        port:
          number: 9090 # serviceentry中定义的port

结合dr使用:

复制代码
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: random-lb-destination-rule
spec:
  host: gindemo.test.ch                # 外部服务或内部服务的域名
  trafficPolicy:
    loadBalancer:
      simple: ROUND_ROBIN                   # 配置为随机负载均衡策略
    connectionPool:
      http:
        http1MaxPendingRequests: 100   # HTTP 1.x 最大挂起请求数
        maxRequestsPerConnection: 10   # 每个连接的最大请求数
    outlierDetection:
      consecutiveErrors: 5             # 连续 5 次错误后剔除实例
      interval: 10s                    # 检测间隔
      baseEjectionTime: 30s            # 剔除时间
      maxEjectionPercent: 50           # 最大剔除百分比
相关推荐
江畔柳前堤6 小时前
GO01-Go 语言与主流编程语言深度对比
开发语言·人工智能·后端·微服务·云原生·golang·go
探索云原生11 小时前
终于搞懂 Kueue:5 个核心对象一次讲透
linux·docker·ai·云原生·kubernetes
月落星还在13 小时前
Spring MVC 与 Spring Boot:从“手动挡”到“自动驾驶”的进化论,兼谈前后端分离的哲学
spring boot·spring·云原生·mvc
Database_Cool_16 小时前
数据库性能不够用,升级到什么方案好?阿里云 PolarDB(云原生数据库领导者,兼容 MySQL/PostgreSQL/Oracle)平滑升级与百倍弹性
数据库·阿里云·云原生
霸道流氓气质16 小时前
微服务架构核心概念业务示例
微服务·云原生·架构
ai_coder_ai17 小时前
编写自动化脚本,在自己后端服务中使用云原生Baas服务进行数据库相关操作
数据库·云原生·自动化
AOwhisky17 小时前
Python 学习笔记(第六期)——函数:定义、参数传递与作用域
笔记·python·学习·云原生·运维开发·函数·参数传递
小小龙学IT18 小时前
Tigris:下一代无服务器数据库
数据库·云原生·serverless
ai_coder_ai20 小时前
论模型驱动分析方法及应用
微服务·云原生·架构
Hiyajo pray20 小时前
云原生场景下:sdn 访问控制优化方案
云原生