A method for deploying distributed database containers in multiple availability zones
By using CRD resources and Webhook Server to listen to container creation events in Kubernetes and modifying node affinity attributes, the problem of inaccurate deployment of distributed database containers in multiple Availability Zones is solved, and precise container deployment is achieved.
Patent Information
- Application Number
- CN202210015688.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-07
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2042-01-07
AI Technical Summary
The prior art cannot accurately control the deployment of distributed database containers in multiple Availability Zones, resulting in inaccurate deployment.
Using the combination of CRD resources and Webhook Server, the container creation events are listened to, and the node affinity attributes are modified to achieve the precise deployment of containers in multi-availability zones.
It realizes the precise deployment of distributed database containers in multiple Availability Zones, improving the accuracy and controllability of deployment.
Smart Images

Figure CN114398149B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of distributed databases and container clouds, and particularly to a method for deploying distributed database containers in multiple availability zones. Background Art
[0002] A distributed database system (DDBS) is developed on the basis of a centralized database system. It consists of a set of data that is physically distributed on different nodes of a computer network and logically belongs to the same system. It is the product of the combination of database technology and network technology, and is a logically unified database formed by connecting multiple physically dispersed database units through a computer network. Each connected database unit is called a node. A distributed database has a unified database management system for management, called a distributed database management system.
[0003] Kubernetes is a portable and extensible open-source platform for managing containerized workloads and services, which can promote declarative configuration and automation. StatefulSet is a built-in component of Kubernetes used to manage the workloads of stateful applications, and has characteristics such as stable and unique network identifiers, stable and persistent storage, ordered and graceful deployment and scaling. The CRD function refers to the ability to add custom Kubernetes object resources according to specific requirements. A WebHook is an HTTP callback: an HTTP POST request triggered under certain conditions; a simple event notification sent via HTTP POST. A WebHook implemented based on a web application will send a message to a specific URL when a specific event occurs.
[0004] A distributed database consists of a set of stateful containers with the same configuration. From the perspective of disaster recovery, these containers must be deployed in multiple availability zones. Deploying in multiple availability zones on Kubernetes is achieved through the built-in components Statefulset and Pod topology constraints. The drawback of this method is that it is impossible to precisely control the deployment of distributed database containers in multiple availability zones. Summary of the Invention
[0005] Based on the above situation, the present invention provides a method for deploying distributed database containers in multiple availability zones, which solves the problem that it is difficult to precisely control the deployment of containers in each availability zone when deploying distributed database containers in multiple availability zones.
[0006] The technical solution of the present invention is as follows:
[0007] A method for deploying distributed database containers in multiple availability zones,
[0008] Precisely describe the deployment of distributed database containers across multiple availability zones using built-in CRD resources. Deploy a webhook Server within Kubernetes to capture the startup events of distributed database containers, and modify the node affinity of the containers based on the CRD resource information, thereby achieving precise control over the multi-availability zone deployment of distributed database containers.
[0009] Furthermore,
[0010] Precisely specify the number of distributed database containers in each availability zone using CRD resources. Deploy the webhook Server and listen for distributed database container creation events. After capturing the container creation events, change the node affinity attributes of the captured containers based on the CRD resource information, container status, and information about existing distributed database containers within the current Kubernetes. Submit the modified containers, and let the built-in scheduler select appropriate nodes to start the containers.
[0011] Use the CRD to specify in detail the number of distributed database containers in each availability zone, availability zone labels, and database parameter information.
[0012] The Webhook Server registers on the api server to listen for distributed database container creation events. When a distributed database container is created, the service will receive the complete container description information. Then the service actively requests the CRD resource information to obtain the precise deployment information of the distributed database container, and actively requests information about other containers of this distributed database on Kubernetes. Based on the CRD information, information about other containers of this database, information about the currently captured container, and historical record information, determine the alternative availability zones. Select an availability zone from the alternative availability zones, and change the node affinity attributes of the currently captured container according to the attributes of this availability zone. Finally, return the modified distributed database container information to the apiserver.
[0013] Furthermore,
[0014] The steps are as follows:
[0015] S1. Precisely specify the characteristics of distributed database containers in each availability zone using CRD resources;
[0016] S2. Deploy the webhook Server and listen for distributed database container creation events;
[0017] S3. After capturing the container creation events, change the node affinity attributes of the captured containers based on the CRD resource information, container status, and information about existing distributed database containers within the current Kubernetes, and submit the modified containers.
[0018] Among them,
[0019] S1 includes the following steps:
[0020] S11. Define a CRD file for the characteristics of the distributed database container in each available zone;
[0021] S12. Publish this CRD file to Kubernetes.
[0022] S2 includes the following steps:
[0023] S21. Deploy a webhook server for handling api server container creation events;
[0024] S22. Register the distributed database container creation event in the api server.
[0025] S3 includes the following steps:
[0026] S31. Capture the distributed database container creation event of the api server;
[0027] S32. Obtain CRD resource information through the api server interface;
[0028] S33. Obtain other container information of the distributed database through the api server interface;
[0029] S34. Comprehensively evaluate the above information to determine alternative available zones;
[0030] S35. Change the node affinity attribute of the captured container;
[0031] S36. Submit the changed container to the api server.
[0032] The beneficial effect of the present invention is
[0033] It solves the problem that it is difficult to precisely control the deployment of containers in each available zone when deploying distributed database containers in multiple available zones. Description of the Drawings
[0034] Figure 1 is the framework diagram of the present invention;
[0035] Figure 2 is the schematic diagram of the working process of the present invention. Detailed Embodiments
[0036] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0037] The present invention provides a method for deploying distributed database containers in multiple availability zones, which is applied to scenarios where precise control over the deployment of distributed database containers in multiple availability zones of Kubernetes is desired. The method includes: precisely specifying the number of distributed database containers in each availability zone using CRD resources, deploying a webhook Server and listening for distributed database container creation events, and after capturing the container creation events, changing the node affinity attributes of the captured containers according to the CRD resource information, container status, and information on existing distributed database containers within the current Kubernetes, and submitting the modified containers, and then having the built-in scheduler select a suitable node to start the containers.
[0038] As shown in the figure, the improvement of the present invention is to add two parts: CRD resource definition and Webhook Server.
[0039] CRD is a way to extend resources in Kubernetes. In the present invention, CRD is used to specify in detail information such as the number of distributed database containers in each availability zone, availability zone labels, and database parameters. Through this CRD resource, precise control can be exerted over the scheduling of each distributed database container to any node in Kubernetes. The CRD contains a set of availability zone description information, and each availability zone is defined as follows:
[0040] Name Meaning Availability Zone Name Availability Zone Name Number of Replicas Specifies the number of database containers to be deployed within this availability zone Availability Zone Identifier Basis for selecting an availability zone during scheduling
[0041] The Webhook Server is a web service that can handle event requests sent by the built-in api server. This service registers on the api server to listen for distributed database container creation events. When a distributed database container is created, this service will receive the complete container description information. Then this service actively requests the CRD resource information to obtain the precise deployment information of the distributed database container, and actively requests information on other containers of this distributed database on Kubernetes. Based on the CRD information, information on other containers of this database, information on the currently captured container, and historical record information, alternative availability zones are determined. One availability zone is preferentially selected from the alternative availability zones, and the node affinity attributes of the currently captured container are changed according to the attributes of this availability zone. Finally, the modified distributed database container information is returned to the api server.
[0042] The above are only the preferred embodiments of the present invention, which are only used to illustrate the technical solutions of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included in the protection scope of the present invention.
Claims
1. A method for deploying distributed database containers in multiple availability zones, characterized in that: Use the built-in CRD resources to accurately describe the deployment of distributed database containers in multiple availability zones. Deploy a webhook Server inside kubernetes to capture the startup events of distributed database containers, and modify the node affinity of the containers according to the CRD resource information, so as to achieve precise control of the deployment of distributed database containers in multiple availability zones; The specific steps are as follows: S1. Use CRD resources to accurately specify the number of distributed database containers in each availability zone; S2. Deploy the webhook Server and listen for the creation events of distributed database containers; S3. After capturing the container creation event, change the node affinity attribute of the captured container according to the CRD resource information, container status and the existing distributed database container information in the current kubernetes, and submit the changed container. The built-in scheduler selects a suitable node to start the container; Wherein, The Webhook Server registers on the api server to listen for the creation events of distributed database containers. When a distributed database container is created, the service receives the complete container description information, and then the service actively requests the CRD resource information to obtain the accurate deployment information of the distributed database container, and actively requests the information of other containers of this distributed database on kubernetes; according to the CRD information, the information of other containers of this database, the information of the currently captured container and the historical record information, determine the alternative availability zones; select an availability zone from the alternative availability zones, and change the node affinity attribute of the currently captured container according to the attributes of this availability zone. Finally, return the modified distributed database container information to the api server.
2. The method according to claim 1, characterized in that: S1 includes the following steps: S11. Define a CRD file for the characteristics of distributed database containers in each availability zone; S12. Publish this CRD file to kubernetes.
3. The method according to claim 1, characterized in that: S2 includes the following steps: S21. Deploy a webhook server that processes the api server container creation event; S22. Register the distributed database container creation event on the api server.
4. The method according to claim 1, characterized in that: S3 includes the following steps: S31. Capture the distributed database container creation event of the api server; S32. Obtain the CRD resource information through the api server interface; S33. Obtain the information of other containers of the distributed database through the api server interface; S34. Comprehensively evaluate the above information to determine the alternative availability zones; S35. Change the node affinity attribute of the captured container; S36. Submit the changed container to the api server.
Citation Information
Patent Citations
Multi-AZ support method for deploying OpenStack based on Helm container
CN111782223A
Intelligent node scheduling method and system based on Kubernetes cluster
CN113645300A