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           # 最大剔除百分比
相关推荐
returnthem1 小时前
Docker学习笔记
云原生·eureka
岁岁种桃花儿3 小时前
kubenetes从入门到上天系列第十五篇:Kubernetes的持久化存储PC和PVC
云原生·容器·kubernetes
数据知道3 小时前
云原生MongoDB:容器化部署与Kubernetes集成详细步骤
mongodb·云原生·kubernetes
无级程序员3 小时前
k8s v1.35配置gateway, istio通过metalb vip访问
kubernetes·gateway·istio
还在忙碌的吴小二13 小时前
k8s是啥?
云原生·容器·kubernetes
zhen2414 小时前
K8s Service
云原生·容器·kubernetes
sbjdhjd16 小时前
RHCE | Web 服务器与 Nginx 全栈详解
linux·nginx·http·云原生·oracle·架构·web
qhqh31018 小时前
K8S的PV、PVC和storageClass的相关概念及实验
云原生·容器·kubernetes
小峰编程1 天前
二进制安装Nginx——详细
linux·运维·服务器·nginx·云原生
AC赳赳老秦1 天前
2026多智能体协同趋势:DeepSeek搭建多智能体工作流,实现复杂任务自动化
人工智能·python·microsoft·云原生·virtualenv·量子计算·deepseek