当前位置:网站首页>How to Integrate Your Service Registry with Istio?
How to Integrate Your Service Registry with Istio?
2022-08-01 12:01:00 【赵化冰】
Microservice is a powerful software architecture to escalate innovations, and many businesses have been adopting microservice for a long time. However, the transition from monolith to microservice comes with costs. Fundamentally, microservices are distributed systems, often in large scales, which bring the burden of networking such as service discovery, retry, circuit breaker, as well as the observability such as metrics, logging, and distributed tracing.
Istio helps microservices to offloads these common concerns to a dedicated infrastructure layer, so the microservices themselves can shift the burden of microservices to Istio, and focus on their own business logic. With all the promising benefits, more and more microservices projects begin to consider migrating their own microservices infrastructure to Istio.
Istio depends on Kubernetes for service discovery, which means you need to deploy your microservices in Kubernetes clusters and use Kubernetes service for discovery before you can offload service communication to Istio. However, many existing microservices projects are still using Consul, Eureka, or other vendor-specific service discovery rather than the Kubernetes service discovery.
How can we quickly integrate these existing microservices projects with Istio at minimal modifications? In this post, I will first explain the service registry mechanism of Istio, and then propose several possible options to integrate third-party service discovery with Istio.
Istio Service Model
First, let’s take a look at the service model inside Istio. In the Istio control plane, Pilot is responsible for managing the service within the service mesh. However, Pilot doesn’t handle service discovery by itself. Pilot populates its internal service registry with services from two kinds of data sources.
Figure 1. Istio service model and data sources
As shown in figure 1, there are two data sources for the Pilot service model:
从上图中可以得知, Pilot 中管理的服务数据有两处数据来源:
- –Service Registry–: A third party service registry. Theoretically, any service registry could be plugged into Pilot via some adapter codes, but only Kubernetes API Server and Consul Catalog are natively supported at the time of this writing.
- –Config Storage–: ServiceEntry and WorkloadEntry are two kinds of Istio configuration resources, which can also be used to add external services into the mesh.
Consul Integration
In the beginning, Istio mainly focused on Kubernetes environments. Although Consul and Eureka registries were also available in Istio 1.0, these codes were basically prototypes, with some bugs and performance issues.
As our team uses Consul for service discovery in our project, we have been trying to solve these bugs and improve the stability and performance of Consul integration since Itsio 1.0. All the fixes have been pushed to Istio and merged into late releases.
- Use watching instead of polling to get update from Consul catalog #17881
- Fix: Consul high CPU usage (#15509) #15510
- Avoid unnecessary service change events(#11971) #12148
- Use ServiceMeta to convey the protocol and other service properties #9713
To connect Consul to Pilot, you just need to specify the registry type and address of the Consul in pilot-discovery command:
--registries Consul``` ```--consulserverURL http://$consul-ip:$port
Other Service Registries
Although some initial Eureka adapter codes appeared in 1.0, they have been completely removed in later releases. Istio now only natively supports Kubernetes and Consul service registry. For those who are using Eureka or other service registries, there are three possible ways to import services in these registries to Istio.
Figure 2. Three ways to integrate third-party service registries with Istio
Figure 2 shows the three ways, colored in red, blue, and green, respectively, to integrate service registries with Istio.
Service Registry Adapter
Like the red arrows show, we can write a custom service registry adapter. The custom adapter gets services and service instances from the third-party service registry, converts them to the standard Pilot service resources, and feeds them to the service controller. The custom adapter needs to implement Pilot serviceregistry.Instance go interface. The implementation codes would be similar to the Consul Service Registry shipped with Pilot. In order to write a custom service registry adapter, you need to know Pilot source code very well, because the adapter needs to interact with the internal Pilot service model via various non-public APIs. Besides, the custom adapter codes need to be compiled along with Istio source codes to get your own special Pilotd binary. So the major problem of this approach is the coupling of your codes and Istio codes, which may cause some pains when upgrading Istio.
MCP Server
Blue arrows show the second way: writing your own MCP server to populate Pilot service model with the services from your service registry. The MCP Server fetches services and service instances from the service registry, converts them into ServiceEntry and WorkloadEntry Istio resources, and pushes them to the Pilot MCP config Controller via the MCP protocol.
In this way, the MCP server is a standalone process, so source code level coupling is avoided. You need to set the address of the MCP Server in configSources parameter of the global mesh options. One thing I’d like to mention is that Istio 1.6 doesn’t support using multiple types of Config controllers together for some unknown reason, implying that you also have to use Galley, the Istio build-in MCP Server, to obtain other configurations instead of directly connecting to Kubernetes API Server.
configSources:
- address:istio-galley.istio-system.svc:9901
- address:${your-coustom-mcp-server}:9901
Since 1.5 release, most of Galley’s functionalities have been moved into Istiod, and Galley is disabled by default. It’s highly likely that Galley will be gradually abandoned in the future, so enabling Galley in production seems not a good idea — you will have to move it out of your deployment, sooner or later.
In addition to this, according to this MCP over XDS proposal, Istio community is discussing replacing the current MCP wire protocol with XDSv3/UDPA. The communication mechanism between the MCP server and Pilot is likely to change in later releases.
A Standalone Service to Watch Service Registry and Create ServiceEntry and WorkloadEntry
This approach is shown by the green arrows. All we need to do is writing a standalone service that watches the service registry and pushes the services into Kubernetes API Server in the form of ServiceEntry and WorkloadEntry resources. Then the Kube Config Controller will pull these resources from Kubernetes API Server and push them to Pilot service model.
This approach only depends on two APIs, the service registry watch API and the Kubernetes API server API, both of them are relatively stable.
Key Takeaway
In this post, we discussed how to integrate third-party service registries with Istio. If you are using Consul, you just need to set the registry type to Consul and specify Consul address in the Pilot-discovery command parameters. For other service registries, there’re three options available: service registry adapter, MCP Server, or a standalone service to push ServiceEntry and WorkloadEntry to Kubernetes API server.
You’re free to choose any one of these approaches for your own microservice project. IMHO, since the first and second approaches have some obvious issues, it makes more sense to start with the third one and consider moving to the MCP server approach after Galley and MCP architecture are stable.
边栏推荐
- 一篇文章,带你详细了解华为认证体系证书(1)
- leetcode/submatrix element sum
- C#/VB.NET 将PPT或PPTX转换为图像
- pandas connects to the oracle database and pulls the data in the table into the dataframe, filters all the data from the current time (sysdate) to one hour ago (filters the range data of one hour)
- How to use DevExpress controls to draw flowcharts?After reading this article, you will understand!
- bat倒计时代码
- R语言诊断ARIMA模型:forecast包构建了一个ARIMA模型、使用checkresiduals函数诊断ARIMA模型、并进行结果解读(拟合较差的ARIMA模型具有的特点)
- R语言ggplot2可视化:使用ggpubr包的geom_exec函数执行geom_*函数(没有任何参数需要放置在aes中)
- 达梦更换正式授权dm.key
- JS 中的 undefined 和 null 的区别
猜你喜欢
Apex installation error
Dameng replaces the officially authorized dm.key
一篇文章,带你详细了解华为认证体系证书(1)
用户体验 | 如何度量用户体验 ?
Flutter Widget 如何启用和屏蔽点击事件
Pytest e-commerce project combat (below)
[Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
重磅消息 | Authing 实现与西门子低代码平台的集成
稀疏表示--学习笔记
判断JS数据类型的四种方法
随机推荐
MNIST是什么(plist是什么意思)
Why Metropolis–Hastings Works
数字化转型实践:世界级2B数字化营销的方法框架
[Nodejs] fs module of node
石头科技打造硬核品牌力 持续出海拓展全球市场
阿里云官方 Redis 开发规范
一文带你读懂云原生、微服务与高可用
Istio Meetup China:全栈服务网格 - Aeraki 助你在 Istio 服务网格中管理任何七层流量
mysql进阶(二十二)MySQL错误之Incorrect string value中文字符输入错误问题分析
爱可可AI前沿推介(8.1)
Find objects with the same property value Cumulative number Summarize
Qt get all files in a folder
(ES6以上以及TS) Map对象转数组
R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化密度图、使用stat_central_tendency函数在密度中添加均值竖线并自定义线条类型
Aeraki Mesh became CNCF sandbox project
2022 Go生态圈 rpc 框架 Benchmark
Qt获取文件夹下所有文件
Beyond Compare 4 试用期到期
Aeraki Mesh 正式成为 CNCF 沙箱项目
关于亚马逊测评,你了解多少?