首页 > 其他分享 >Istio ServiceEntry

Istio ServiceEntry

时间:2022-10-26 16:13:39浏览次数:60  
标签:ServiceEntry networking name Istio istio io spec

ServiceEntry介绍

  • ServiceEntry用于将未能自动添加至网格中的服务,以手动形式添加至网格中,以使得网格内的自动发现机制能够访问或路由到这些服务
    • 未能自动添加至网格中的服务

      • 网格外部的服务

      • 位于网格内部但自身并未注册于平台注册表的服务手动添加至Istio的内部的服务注册表中

    • ServiceEntry本身用于描述要引入的外部服务的属性,包括服务的DNS名称、IP地址、端口、协议和相关的端点;

  • 提示:类似于Gateway引入的流量需要由VirtualService进行路由,发往由ServiceEntry引入的服务的流量,还需要由DestinationRule定义其分发机制

ServiceEntry

ServiceEntry配置示例

示例一

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: external-svc-https
spec:
  hosts:
  - api.dropboxapi.com
  - www.googleapis.com
  - api.facebook.com
  location: MESH_EXTERNAL
  ports:
  - number: 443
    name: https
    protocol: TLS
  resolution: DNS

示例二

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: external-svc-mongocluster
spec:
  hosts:
  - mymongodb.somedomain # not used
  addresses:
  - 192.192.192.192/24 # VIPs
  ports:
  - number: 27018
    name: mongodb
    protocol: MONGO
  location: MESH_INTERNAL
  resolution: STATIC
  endpoints:
  - address: 2.2.2.2
  - address: 3.3.3.3
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: mtls-mongocluster
spec:
  host: mymongodb.somedomain
  trafficPolicy:
    tls:
      mode: MUTUAL
      clientCertificate: /etc/certs/myclientcert.pem
      privateKey: /etc/certs/client_private_key.pem
      caCertificates: /etc/certs/rootcacerts.pem

示例三

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: external-svc-redirect
spec:
  hosts:
  - wikipedia.org
  - "*.wikipedia.org"
  location: MESH_EXTERNAL
  ports:
  - number: 443
    name: https
    protocol: TLS
  resolution: NONE
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: tls-routing
spec:
  hosts:
  - wikipedia.org
  - "*.wikipedia.org"
  tls:
  - match:
    - sniHosts:
      - wikipedia.org
      - "*.wikipedia.org"
    route:
    - destination:
        host: internal-egress-firewall.ns1.svc.cluster.local

示例四

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: external-svc-httpbin
  namespace : egress
spec:
  hosts:
  - example.com
  exportTo:
  - "."
  location: MESH_EXTERNAL
  ports:
  - number: 80
    name: http
    protocol: HTTP
  resolution: DNS
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
 name: istio-egressgateway
 namespace: istio-system
spec:
 selector:
   istio: egressgateway
 servers:
 - port:
     number: 80
     name: http
     protocol: HTTP
   hosts:
   - "*"
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: gateway-routing
  namespace: egress
spec:
  hosts:
  - example.com
  exportTo:
  - "*"
  gateways:
  - mesh
  - istio-egressgateway
  http:
  - match:
    - port: 80
      gateways:
      - mesh
    route:
    - destination:
        host: istio-egressgateway.istio-system.svc.cluster.local
  - match:
    - port: 80
      gateways:
      - istio-egressgateway
    route:
    - destination:
        host: example.com

参考文档

https://istio.io/latest/zh/docs/reference/config/networking/service-entry/

标签:ServiceEntry,networking,name,Istio,istio,io,spec
From: https://www.cnblogs.com/wangguishe/p/16828751.html

相关文章

  • Istio gateway
    Gateway配置要点Gateway定义运行在网格边缘的负载均衡器,负责接收入站或出站的HTTP/TCP连接主要定义应该暴露到网格外部的端口、要使用的协议类型、以及SNI配置等......
  • Istio DestinationRule
    DestinationRule配置要点DestinationRule用于配置路由完成之后的应用于服务的流量策略,即配置如何将流量调度至上游端点,同时也是为VirtualService的Destination指定的目标......
  • istio部署demoapp应用 (六)基于权重的流量分割
    架构图virtualservice-demoapp.yamlapiVersion:networking.istio.io/v1beta1kind:VirtualServicemetadata:name:demoappspec:hosts:-demoapphttp:......
  • istio部署demoapp应用 (四) Ingress-gateway暴露demoapp
    proxy-gateway.yamlapiVersion:networking.istio.io/v1beta1kind:Gatewaymetadata:name:proxy-gatewaynamespace:istio-systemspec:selector:app:i......
  • istio部署demoapp多版本应用示例
    环境说明frontend(proxy):前端应用,会请求后端的demoappservice:proxydemoapp:后端应用同时部署两个版本 部署demoappv1.0deploy-demoapp-v10.yamla......
  • istio部署后端单版本应用示例
    环境说明frontend(proxy):前端应用,会请求后端的demoappservice:proxydemoapp:后端应用service:demoappv10访问流程clientpod--->(EgressListener......
  • Istio流量治理基础
    流量治理Istio的流量路由规则使运维人员可以轻松控制服务之间的流量和API调用Istio简化了诸如断路器,超时和重试之类的服务级别属性的配置,并使其易于设置重要任务(A/B测......
  • 大厂Istio基础与实践 云原生“薪”能力合集,一线大厂实战
    大厂Istio基础与实践云原生“薪”能力合集,一线大厂实战导言:上一篇章给大家介绍了服务治理方案ServiceMesh(服务网格)产生的背景、逻辑架构、应用场景。本篇将要介绍的......
  • 安装istio和部署bookinfo项目
    一istio安装1.1下载安装​​https://istio.io/latest/docs/setup/getting-started/​​安装前提:你的服务器必须可以连接外网需要下载谷歌镜像#下载cd/usr/local/curl......
  • Istio常用命令
    Istio使用帮助#istioctl--helpIstioconfigurationcommandlineutilityforserviceoperatorstodebuganddiagnosetheirIstiomesh.Usage:istioctl[comm......