当前位置:网站首页>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中。
边栏推荐
- Size end byte order
- Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
- Sword finger offer 04 Find in 2D array
- uniapp下拉弹层选择框效果demo(整理)
- It is so simple to remove the payment restrictions on VIP, YuQue and Zhihu in Baidu Library
- 今天运气不错
- 如何修改 node_modules 里的文件
- ACL 2022 | TAMT proposed by Chinese Academy of Sciences: TAMT: search for a portable Bert subnet through downstream task independent mask training
- Uniapp drop-down layer selection box effect demo (sorting)
- How to open an account for CSI 500 stock index futures, what are the regular domestic stock index futures platforms, and where is the safest place to open an account?
猜你喜欢

ACL 2022 | 中科院提出TAMT:TAMT:通过下游任务无关掩码训练搜索可迁移的BERT子网络

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

微服务之配置管理中心

Database Series: MySQL index optimization and performance improvement summary (comprehensive version)

Secyun won the "2022 AI analysis · it operation and maintenance vendor panorama report" as the representative vendor of intelligent operation and maintenance aiops Market

MySQL learning 1: installing MySQL

AI for Science: scientific research paradigm, open source platform and industrial form

Quanzhi A13 tossing memo

Word text box page feed

TCP 流控问题两则
随机推荐
清楚的自我定位
Win10彻底永久关闭自动更新的步骤
PyCharm汉化
关于枚举类的两种用法
How to close windows defender Security Center
A brief talk on cordola tree
如何修改 node_modules 里的文件
数据库的复习总结
l六月集训(第27天) —— 图
How to modify a node_ Files in modules
Viewpager2 usage record
Steps for win10 to completely and permanently turn off automatic updates
application.properties 的配置信息
浅谈珂朵莉树
自定义多线程基类threading.Event
诗歌一首看看
GCC compiling dynamic and static libraries
Thymeleaf的相关知识
浏览器输入url地址,到页面渲染发生了什么
application. Configuration information of properties