当前位置:网站首页>Istio微服务治理网格流量管理核心资源控制器详解
Istio微服务治理网格流量管理核心资源控制器详解
2022-06-27 12:38:00 【Jiangxl~】
Istio微服务治理网格流量管理核心资源控制器详解
文章目录
1.Istio流量管理核心资源控制器
Istio常用的流量管理资源有以下四种:
- Gateway(网关资源)
- VirtualService(虚拟服务资源)
- DestinationRule(目标规则资源)
- ServiceEntry(服务入口资源)
Istio中对于流量的转发、访问控制、灰度发布等等功能都是通过编写这四种资源编排文件来实现的。
2.Gateway网关资源
2.1.Gateway资源概念
Gateway网关资源主要是为网格内的服务提供一个对外访问的入口,类似于Ingress资源,将网格内的应用程序发布在互联网环境。
Gateway网关资源需要配置VirtualService资源才能完成应用程序对外暴露的规则配置信息,Gateway与VirtualService定义的转发规则最终会配置在Istio的Ingressgateway服务中。
Gateway网关资源可以管理进出口的流量,将请求转发至特定的应用程序,根据流入流出的方向可以分为以下两种:
- IngressGateway:主要负责接收外部的流量请求,然后将流量转发到网格中的某个应用程序上。
- EngressGateway:网格内部的服务需要访问外部的应用程序。
Gateway的流量转发示意图如下图所示。
2.2.Gateway资源清单文件
apiVersion: networking.istio.io/v1alpha3
kind: Gateway #资源类型为Gateway
metadata:
name: httpbin-gateway #资源的名称
spec:
selector: #定义选择器
istio: ingressgateway #关联istio的ingressgateway
servers: #定义服务列表
- port: #定义服务使用的端口号
number: 80 #端口号为80
name: http #端口的名称
protocol: HTTP #端口的协议
hosts: #允许进入的主机,也可以是单个域名
- "*"
3.VirtualService虚拟服务资源
3.1.VirtualService资源概念
VirtualService资源主要是用于定义流量的路由规则,根据满足的条件将流量转发至对应的Pod资源,VirtualService需要与Gateway资源关联使用,Gateway资源相当于配置了监听的端口,类似于Nginx中的Server配置块,而VirtualService主要是将流量请求转发至提供服务的Service资源上,相当于Nginx中的Location配置块,VirtualService资源会将转发信息配置在Istio的IngressGateway中。
流量请求会先到达IngressGateway,根据配置的VirtualService转发规则,将请求转发至提供服务的Service资源上。
VirtualService资源可以配置DestinationRule资源做一些流量控制、灰度发布等等功能。
VirtualService资源是Istio中非常重要的资源,只要在网格中部署应用程序,一定会创建VirtualService资源。
3.2.VirtualService资源清单文件
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService #控制器类型为VirtualService
metadata:
name: httpbin #控制器名称
spec:
hosts: #定义主机信息,可以是一个域名
- "*"
gateways: #关联对应的gateways资源
- httpbin-gateway
http: #定义http流量路由有序列表规则
- route: #默认规则,可以重定向或者转发流量
- destination: #定义流量转发的规则
host: httpbin #这里的host是将流量转发到哪一个Service资源,填写Service资源的名称
port: #填写Service资源的端口
number: 8000
4.DestinationRule目标规则资源
4.1.DestinationRule资源概念
DestinationRule资源的功能非常丰富,主要是针对流量做一些处理操作和定义虚拟服务的路由地址,可以配合VirtualService资源实现流量的转发控制、灰度发布等等,可以根据支持的策略,将应用程序的Pod资源进行分组,将不同的流量转发到不同的Pod资源组,来实现程序的灰度发布。
DestinationRule支持多种的负载均衡策略:随机、权重、最小请求数等。
4.2.DestinationRule资源清单文件
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule #定义资源的类型为DestinationRule
metadata:
name: reviews #定义资源的名称
spec:
host: reviews
trafficPolicy:
tls:
mode: istio_MUTUAL
subsets: #定义子集也就是各种路由规则
- name: v1 #规则名称
labels: #Pod标签
version: v1
- name: v2
labels:
version: v2
- name: v3
labels:
version: v3
5.ServiceEntry服务入口资源
ServiceEntry资源主要作用就是让Istio网格中的应用程序去连接集群外部的应用程序,ServiceEntry的配置信息会保存在EngressGateway中。
边栏推荐
猜你喜欢

JMETER连接DM8

Make learning pointer easier (1)

MySQL learning 1: installing MySQL

uni-app开发微信小程序动态渲染页面,动态改变页面组件模块顺序

script defer async模式

Uniapp drop-down layer selection box effect demo (sorting)

Dm8: Dameng database - lock timeout

阿里一个面试题:使用两个线程,交替输出字母和数字

Ali an interview question: use two threads to output letters and numbers alternately

全球最快下载工具 XDM
随机推荐
ZABBIX supports nail alarm
让学指针变得更简单(一)
The browser enters the URL address, and what happens to the page rendering
Microservice splitting
C语言 函数指针与回调函数
执行 npm 指令失败,提示ssh: ... Permission denied
Bluetooth health management device based on stm32
二叉树的三种遍历方式
如何下载带有超链接的图片
全志A13折腾备忘
TCP 流控问题两则
application.properties 的配置信息
Use of message queues
【TcaplusDB知识库】TcaplusDB-tcapsvrmgr工具介绍(三)
OpenFeign服务接口调用
Principle of printf indefinite length parameter
An interesting experiment of netmask
【粉丝福利】今天给大家介绍一个白捡钱的方法-可转债,本人亲自验证,每年每人能获利1500元
对象序列化
Three traversal methods of binary tree