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           # 最大剔除百分比
相关推荐
有毒的教程17 小时前
Kubernetes进阶实战教程(生产落地完整版)
云原生·容器·kubernetes
秋播19 小时前
rancher 部署statefulset mariadb 10.5
云原生
至乐活着1 天前
Spring Boot 3.x核心特性深度解析:拥抱Java 17与云原生时代
spring boot·云原生·graalvm·java 17·虚拟线程
FJW0208141 天前
阿里云RDS数据库账号创建案例
云原生
leijiwen1 天前
Bsin-PaaS(毕昇)——LinkLifeVerse OS 的产业智能工程底座
云原生·云计算·paas
her_heart2 天前
ChatGPT 5.6 实战:用 AI 做云成本治理,从账单复盘到 K8s 优化
人工智能·云原生·chatgpt·kubernetes·测试用例
DolphinScheduler社区2 天前
Apache DolphinScheduler 6 月治理优化,补齐调度运维全链路细节
大数据·运维·云原生·apache·海豚调度
AOwhisky3 天前
Python 学习笔记(第三期)——流程控制:条件判断与循环结构
运维·笔记·python·学习·云原生·流程控制·循环
Waay3 天前
Linux 三个核心环境变量配置文件、作用域、生效方式完整梳理
linux·运维·学习·云原生·容器