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           # 最大剔除百分比
相关推荐
CJY6217 小时前
k8spod管理
云原生·容器·kubernetes
2601_962218477 小时前
万象生鲜系统区块链溯源技术帮助生鲜企业搭建食品安全数字化体系
大数据·运维·微服务·云原生·架构
Henry-SAP12 小时前
SAP独立需求与相关需求的区别解析
人工智能·云原生·sap·erp
GGG76614 小时前
Python 运维自动化:psutil+IPy 系统与网络信息采集深度实战
运维·python·云原生·pip
w2005122415 小时前
Pod管理
linux·服务器·云原生·容器·k8s·podman
sryyd_0217 小时前
Kubernetes Pod 管理从入门到实战:命令、YAML 与生命周期全解析
云原生·容器·kubernetes
2601_9622186117 小时前
万象生鲜系统全链路溯源一码查询技术实现食材来源可查
分布式·微服务·云原生·架构
2601_9622184718 小时前
万象生鲜系统跨仓调拨算法助力生鲜企业供应链数字化协同运营
大数据·运维·微服务·云原生·架构
智购科技无人售货机工厂19 小时前
2026自动售货机防拆机物理安全设计:从安全螺丝到结构互锁的工程实践~YH
android·网络·驱动开发·python·单片机·安全·云原生
2601_9622184719 小时前
万象生鲜系统多仓协同同步技术支撑生鲜企业多仓模式数字化转型
大数据·运维·微服务·云原生·架构