CN112422683A - API gateway service high-availability implementation method under K8S environment - Google Patents
API gateway service high-availability implementation method under K8S environment Download PDFInfo
- Publication number
- CN112422683A CN112422683A CN202011298644.5A CN202011298644A CN112422683A CN 112422683 A CN112422683 A CN 112422683A CN 202011298644 A CN202011298644 A CN 202011298644A CN 112422683 A CN112422683 A CN 112422683A
- Authority
- CN
- China
- Prior art keywords
- service
- gateway
- api
- implementation method
- gateway service
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/66—Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/08—Configuration management of networks or network elements
- H04L41/0803—Configuration setting
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/08—Configuration management of networks or network elements
- H04L41/0803—Configuration setting
- H04L41/0813—Configuration setting characterised by the conditions triggering a change of settings
- H04L41/082—Configuration setting characterised by the conditions triggering a change of settings the condition being updates or upgrades of network functionality
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/02—Network architectures or network communication protocols for network security for separating internal from external traffic, e.g. firewalls
- H04L63/0209—Architectural arrangements, e.g. perimeter networks or demilitarized zones
- H04L63/0218—Distributed architectures, e.g. distributed firewalls
Abstract
The invention discloses a high-availability implementation method of API gateway service in a K8S environment, and belongs to the technical field of API gateways. The API gateway service high-availability implementation method under the K8S environment realizes multiple service requirements by compiling the user-defined service plug-in, reasonably configures the master user by analyzing the service to achieve full use of resources, and performs dynamic expansion and contraction capacity of a distributed instance by monitoring the performance use state to realize the distributed gateway service shared by multiple master users and multiple sub-users. The API gateway service high-availability implementation method under the K8S environment can realize service instance technology isolation among the main users and isolation among the main users, ensures the safety of single gateway service, and has good popularization and application values.
Description
Technical Field
The invention relates to the technical field of API gateways, and particularly provides a method for realizing high availability of API gateway services in a K8S environment.
Background
With the continuous development of the cloud and native technology, new dynamic environments such as public cloud, private cloud, hybrid cloud and the like are continuously upgraded, the establishment and operation of elastically expandable applications become basic attributes of services, the defects of the traditional architecture become more obvious, and the software service for establishing the cloud and native technology becomes more important. The traditional gateway service faces the problems of unpredictability, poor expansibility, waterfall development, slow recovery and the like, and needs to be further improved.
Disclosure of Invention
The technical task of the invention is to provide a high-availability implementation method of API gateway service in K8S environment, which can realize technical isolation of service instances among main users, isolation among main users and guarantee the safety of single gateway service.
In order to achieve the purpose, the invention provides the following technical scheme:
a high-availability implementation method for API gateway services in a K8S environment is characterized in that a user-defined service plug-in is compiled to achieve various service requirements, a master user is reasonably configured by analyzing services to achieve full use of resources, dynamic expansion and contraction of a distributed instance are performed by monitoring a performance use state, and distributed gateway services shared by multiple master users and multiple sub-users are isolated.
Preferably, the method for realizing the high availability of the API gateway service in the K8S environment specifically includes the following steps:
s1, deploying nginx-ingress service in the cluster as an external unified entrance of the gateway service;
s2, configuring the ingress resource of K8S, and leading the flow into different gateway routing service instances through nginx-ingress;
s3, configuring a node selector in the deployment by the gateway instance to select a node corresponding to the label for scheduling;
s4, identifying a group of gateway service instances by a master user specified by a service according to the service requirement by a gateway routing API (application programming interface), and shunting the request to the gateway service instances of different master users by the API through nginx-ingress;
s5, the gateway configuration storage design conforms to a general design mode of cloud native services, and the ETCD component is used for storage;
and S6, triggering the gateway service to update without stopping in the K8S environment.
Preferably, in step S2, the gateway instance configures an HPA automatic capacity expansion mechanism, sets a critical value of the memory and the CPU, and automatically expands the pod number of the service instance exceeding the critical value, thereby implementing dynamic capacity expansion based on the service traffic peak and valley.
Preferably, the threshold for memory and CPU is set at 80%.
Preferably, in step S3, configuring multiple nodes, and performing balanced scheduling on the gateway pod between the nodes through two links of preselection and optimization, so as to reasonably utilize node resources and ensure that when a single node is hung, the gateway instances on other nodes continue to serve.
Preferably, in step S4, the master user API is implemented to provide gateway routing services by an exclusive shared instance, and a plurality of common users provide services by using a shared gateway instance.
Preferably, in step S5, the service instances acquire corresponding API gateway configurations through different label identifications.
Preferably, in step S6, each group of instances is configured to default to two copies, only a part of the copies are updated at a time in the updating process, and after the updating process succeeds, more copies are updated, so that the updating of all copies is completed.
The implementation method for API gateway service high availability under the K8S environment realizes service instance distribution based on ECTD configuration resource unified management; based on a self-development configuration management module, realizing configuration hot update of a gateway service instance; and based on real-time resource monitoring, updating the gateway service version by the management background and automatically triggering the rolling update of the gateway service instance. And classifying and storing the gateway API resources by using the ConfigMap resources in the ETCD, and classifying and splitting the configured resources based on the optimal resource unit storage capacity of the ConfigMap. And the self-developed configuration management Controller manages the configuration resources corresponding to the master user through preset environment variables, updates through the configuration version number, and triggers the hot update of the service instance after the configuration version number is matched with the plurality of the split ConfigMap resources. Based on the real-time monitoring of the service instance resources, the information of the mirror image version of the current service instance is recorded, the version difference is automatically detected by updating the gateway service instance mirror image version number of the management background, and the gateway service instance of the old version is updated in a rolling manner.
Compared with the prior art, the API gateway service high-availability implementation method under the K8S environment has the following outstanding beneficial effects: the API gateway service high-availability implementation method under the K8S environment realizes a distributed gateway example and performs load balancing on request traffic; service instance technology isolation among main users and isolation among the main users are realized, and the safety of single gateway service is ensured; the cluster ecology realizes that the number of service instances is dynamically adjusted based on the size of service flow, and the service capability of gateway service is ensured; the configuration file is mounted in the virtual resource, so that automatic recovery after abnormal service is realized, and manual operation and maintenance are not needed; by upgrading the latest mirror image version in the management background, the mirror image of the gateway service instance is automatically updated without stopping, and the method has good popularization and application values.
Detailed Description
The high availability implementation method of the API gateway service in the K8S environment of the present invention will be described in further detail with reference to the following embodiments.
Examples
The API gateway service high-availability implementation method under the K8S environment realizes multiple service requirements by compiling the user-defined service plug-in, reasonably configures the master user by analyzing the service to achieve full use of resources, and performs dynamic expansion and contraction capacity of a distributed instance by monitoring the performance use state to realize the distributed gateway service shared by multiple master users and multiple sub-users.
The specific implementation method for the API gateway service high availability under the K8S environment specifically includes the following steps:
s1, deploying nginx-ingress service in the cluster as a unified entrance for gateway service to the outside.
S2, configuring the ingress resource of K8S, and leading the traffic into different gateway routing service instances through nginx-ingress.
In this step, the gateway instance configures an HPA automatic capacity expansion mechanism, sets the critical value of the memory and the CPU to be 80%, and automatically expands the pod number of the service instance exceeding the critical value, thereby implementing dynamic capacity expansion based on the service traffic peak valley.
S3, the gateway instance configures the node selector in the deployment to select the node corresponding to the label for scheduling.
The method comprises the steps of configuring a plurality of nodes, carrying out balanced scheduling on the gateway pod between the nodes through two links of preselection and optimization, reasonably utilizing node resources, ensuring that when a single node is hung up, gateway instances on other nodes continue to serve, not influencing gateway functions, and realizing high availability of the API gateway in a distributed mode.
And S4, the gateway routing API uses the main user specified by the service to identify a group of gateway service instances according to the service requirement, and the API branches the request into the gateway service instances of different main users through nginx-ingress.
The gateway routing service is provided by the independent shared instance through the main user API, and the service is provided by a plurality of common users through the shared gateway instance.
And S5, the gateway configuration storage design conforms to the general design mode of the cloud native service, and the ETCD component is used for storage.
And acquiring corresponding API gateway configuration through different label identifications among the service instances.
And S6, triggering the gateway service to update without stopping in the K8S environment.
And configuring each group of instances as two copies by default, updating only one part of copies in the updating process, and updating more copies after success to complete the updating of all copies.
The implementation method for API gateway service high availability under the K8S environment realizes service instance distribution based on ECTD configuration resource unified management; based on a self-development configuration management module, realizing configuration hot update of a gateway service instance; and based on real-time resource monitoring, updating the gateway service version by the management background and automatically triggering the rolling update of the gateway service instance. And classifying and storing the gateway API resources by using the ConfigMap resources in the ETCD, and classifying and splitting the configured resources based on the optimal resource unit storage capacity of the ConfigMap. And the self-developed configuration management Controller manages the configuration resources corresponding to the master user through preset environment variables, updates through the configuration version number, and triggers the hot update of the service instance after the configuration version number is matched with the plurality of the split ConfigMap resources. Based on the real-time monitoring of the service instance resources, the information of the mirror image version of the current service instance is recorded, the version difference is automatically detected by updating the gateway service instance mirror image version number of the management background, and the gateway service instance of the old version is updated in a rolling manner.
The API gateway service high-availability implementation method under the K8S environment is used for realizing distributed high-availability resource-saving application of the API gateway based on K8s, based on business requirements, a VIP master user can independently share one group of gateway service examples, common users share one group of gateway service examples, different master users configure API slave technology layers to be mutually isolated, dynamic expansion and contraction capacity based on service flow is realized, and non-stop updating of gateway service is realized. The cluster ecology realizes that the number of service instances is dynamically adjusted based on the size of service flow, and the service capability of gateway service is ensured; the configuration file is mounted in the virtual resource, so that automatic recovery after abnormal service is realized, and manual operation and maintenance are not needed; and the mirror image of the gateway service instance is automatically updated without stopping by upgrading the latest mirror image version in the management background.
The above-described embodiments are merely preferred embodiments of the present invention, and general changes and substitutions by those skilled in the art within the technical scope of the present invention are included in the protection scope of the present invention.
Claims (8)
1. An API gateway service high-availability implementation method under the K8S environment is characterized in that: the method realizes multiple service requirements by compiling the user-defined service plug-in, reasonably configures the master user by analyzing the service to achieve full use of resources, and realizes the distributed gateway service shared by multiple master users and multiple sub-users by monitoring the performance use state and performing dynamic expansion and contraction capacity of the distributed instance.
2. The API gateway service high-availability implementation method in the K8S environment according to claim 1, wherein: the method specifically comprises the following steps:
s1, deploying nginx-ingress service in the cluster as an external unified entrance of the gateway service;
s2, configuring the ingress resource of K8S, and leading the flow into different gateway routing service instances through nginx-ingress;
s3, configuring a node selector in the deployment by the gateway instance to select a node corresponding to the label for scheduling;
s4, identifying a group of gateway service instances by a master user specified by a service according to the service requirement by a gateway routing API (application programming interface), and shunting the request to the gateway service instances of different master users by the API through nginx-ingress;
s5, the gateway configuration storage design conforms to a general design mode of cloud native services, and the ETCD component is used for storage;
and S6, triggering the gateway service to update without stopping in the K8S environment.
3. The API gateway service high-availability implementation method in the K8S environment according to claim 2, wherein: in step S2, the gateway instance configures an HPA automatic capacity expansion mechanism, sets a critical value of the memory and the CPU, and automatically expands the pod number of the service instance exceeding the critical value, thereby implementing dynamic capacity expansion based on the service traffic peak-valley.
4. The API gateway service high-availability implementation method in the K8S environment according to claim 3, wherein: the threshold for memory and CPU is set at 80%.
5. The API gateway service high-availability implementation method in the K8S environment according to claim 4, wherein: in step S3, a plurality of nodes are configured, and balanced scheduling is performed on the gateway pod between the nodes through two links of preselection and optimization, so as to reasonably utilize node resources and ensure that when a single node is hung up, the gateway instances on other nodes continue to serve.
6. The API gateway service high-availability implementation method in the K8S environment according to claim 5, wherein: in step S4, the master user API provides gateway routing services by the exclusive shared instance, and a plurality of common users provide services by using the shared gateway instance.
7. The API gateway service high-availability implementation method in the K8S environment according to claim 6, wherein: in step S5, the service instances acquire corresponding API gateway configurations through different label identifications.
8. The API gateway service high availability implementation method in the K8S environment according to claim 7, wherein: in step S6, each group of instances is configured to default to two copies, only a part of the copies are updated at a time in the updating process, and after the updating is successful, more copies are updated, thereby completing the updating of all copies.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011298644.5A CN112422683B (en) | 2020-11-19 | 2020-11-19 | API gateway service high-availability implementation method in K8S environment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011298644.5A CN112422683B (en) | 2020-11-19 | 2020-11-19 | API gateway service high-availability implementation method in K8S environment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112422683A true CN112422683A (en) | 2021-02-26 |
CN112422683B CN112422683B (en) | 2023-02-03 |
Family
ID=74773529
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011298644.5A Active CN112422683B (en) | 2020-11-19 | 2020-11-19 | API gateway service high-availability implementation method in K8S environment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112422683B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113032097A (en) * | 2021-03-22 | 2021-06-25 | 浪潮云信息技术股份公司 | API gateway implementation method and system capable of automatically scaling number of instances |
CN113595788A (en) * | 2021-07-28 | 2021-11-02 | 上海华兴数字科技有限公司 | API gateway management method and device based on plug-in |
CN114221997A (en) * | 2021-12-14 | 2022-03-22 | 国泰君安证券股份有限公司 | Interface monitoring system based on micro-service gateway |
CN115473766A (en) * | 2022-08-22 | 2022-12-13 | 苏州思萃工业互联网技术研究所有限公司 | Method and system for realizing vip based on distributed gateway |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107947961A (en) * | 2017-10-17 | 2018-04-20 | 上海数讯信息技术有限公司 | Kubernetes Network Management System and method based on SDN |
CN109165088A (en) * | 2018-09-06 | 2019-01-08 | 华泰证券股份有限公司 | It is a kind of based on elastic-job frame can single machine elasticity dilatation task sharding method |
CN109324943A (en) * | 2018-08-15 | 2019-02-12 | 刘鹏 | DOCLOUD flow engine system |
CN109981789A (en) * | 2019-04-03 | 2019-07-05 | 山东浪潮云信息技术有限公司 | A kind of micro services engine based on proxy mode |
CN111143054A (en) * | 2019-12-10 | 2020-05-12 | 北京计算机技术及应用研究所 | Heterogeneous domestic CPU resource fusion management method |
CN111327681A (en) * | 2020-01-21 | 2020-06-23 | 北京工业大学 | Cloud computing data platform construction method based on Kubernetes |
CN111835862A (en) * | 2020-07-22 | 2020-10-27 | 浪潮云信息技术股份公司 | Method for realizing reference flow type deployment object storage back-end service |
-
2020
- 2020-11-19 CN CN202011298644.5A patent/CN112422683B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107947961A (en) * | 2017-10-17 | 2018-04-20 | 上海数讯信息技术有限公司 | Kubernetes Network Management System and method based on SDN |
CN109324943A (en) * | 2018-08-15 | 2019-02-12 | 刘鹏 | DOCLOUD flow engine system |
CN109165088A (en) * | 2018-09-06 | 2019-01-08 | 华泰证券股份有限公司 | It is a kind of based on elastic-job frame can single machine elasticity dilatation task sharding method |
CN109981789A (en) * | 2019-04-03 | 2019-07-05 | 山东浪潮云信息技术有限公司 | A kind of micro services engine based on proxy mode |
CN111143054A (en) * | 2019-12-10 | 2020-05-12 | 北京计算机技术及应用研究所 | Heterogeneous domestic CPU resource fusion management method |
CN111327681A (en) * | 2020-01-21 | 2020-06-23 | 北京工业大学 | Cloud computing data platform construction method based on Kubernetes |
CN111835862A (en) * | 2020-07-22 | 2020-10-27 | 浪潮云信息技术股份公司 | Method for realizing reference flow type deployment object storage back-end service |
Non-Patent Citations (1)
Title |
---|
李想: ""基于Kubernetes容器云的资源调度算法研究"", 《中国硕士期刊全文库》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113032097A (en) * | 2021-03-22 | 2021-06-25 | 浪潮云信息技术股份公司 | API gateway implementation method and system capable of automatically scaling number of instances |
CN113595788A (en) * | 2021-07-28 | 2021-11-02 | 上海华兴数字科技有限公司 | API gateway management method and device based on plug-in |
CN114221997A (en) * | 2021-12-14 | 2022-03-22 | 国泰君安证券股份有限公司 | Interface monitoring system based on micro-service gateway |
CN115473766A (en) * | 2022-08-22 | 2022-12-13 | 苏州思萃工业互联网技术研究所有限公司 | Method and system for realizing vip based on distributed gateway |
CN115473766B (en) * | 2022-08-22 | 2024-01-26 | 苏州思萃工业互联网技术研究所有限公司 | Vip implementation method and system based on distributed gateway |
Also Published As
Publication number | Publication date |
---|---|
CN112422683B (en) | 2023-02-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112422683B (en) | API gateway service high-availability implementation method in K8S environment | |
CN111371627B (en) | Method for setting multiple IPs (Internet protocol) in Kubernetes through Pod | |
CN111371696B (en) | Method for realizing Pod network flow control in Kubernetes | |
CN111796905B (en) | Method and system for realizing Kubernetes container cloud platform VLAN network | |
CN110213369B (en) | Automatic arranging system and arranging method for service function chain | |
EP3200393B1 (en) | Method and device for virtual network function management | |
CN103200036B (en) | A kind of automation collocation method of electric power system cloud computing platform | |
CN107404509B (en) | Distributed service configuration system and information management method | |
CN114237812A (en) | Container network management system | |
CN110391940B (en) | Service address response method, device, system, equipment and storage medium | |
CN110113406B (en) | Distributed computing service cluster system | |
CN103999413A (en) | Method and apparatus for messaging in the cloud | |
CN103546572A (en) | Cloud storage device and multi-cloud storage networking system and method | |
CN112698992B (en) | Disaster recovery management method and related device for cloud cluster | |
CN114301828A (en) | Cross-subnet interaction method and device, electronic equipment and storage medium | |
CN110764918A (en) | Method for managing main nodes in container cluster | |
CN113835834A (en) | K8S container cluster-based computing node capacity expansion method and system | |
CN104052799A (en) | Method for achieving high availability storage through resource rings | |
CN114363164B (en) | Cloud network service arrangement control method, system, storage medium and electronic equipment | |
CN114338670B (en) | Edge cloud platform and network-connected traffic three-level cloud control platform with same | |
CN115454571A (en) | Kubernetes-based multi-tenant network isolation method and system | |
AU2018290375B2 (en) | Resource allocation method and system | |
CN114338714A (en) | Block synchronization method and device, electronic equipment and storage medium | |
CN114338724A (en) | Block synchronization method and device, electronic equipment and storage medium | |
CN103685015B (en) | The expandable route task allocating method of Component-Based Development |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |