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           # 最大剔除百分比
相关推荐
阿里云云原生7 小时前
【昨晚 17:00】模力工场联合 HiClaw,聊聊怎么把虾场管明白
云原生
阿里云云原生10 小时前
连登顶会!阿里云多项研究成果大幅提升运维智能精度与效率
云原生
阿里云云原生10 小时前
从养一只虾到开好虾场,HiClaw 规模化养虾的详细解读
云原生
河码匠12 小时前
Kubernests YAML 详细之卷(PV、PVC、StorageClass)
云原生·容器·kubernetes
码上上班13 小时前
k8s控制器,daemonset
云原生·容器·kubernetes
深念Y14 小时前
Docker Desktop 版本与 IDEA 插件兼容性
docker·云原生·容器·api·idea·wsl
llm大模型算法工程师weng15 小时前
AI + Docker + K8s:云原生时代的运维提效实战
运维·人工智能·云原生
步步为营DotNet16 小时前
全面解读C# 14在云原生微服务开发中的创新应用
微服务·云原生·c#
平行云PVT1 天前
数字孪生信创云渲染技术解析:从混合信创到全国产化架构
linux·unity·云原生·ue5·图形渲染·webgl·gpu算力