Distributed database multi-tenant isolation method and system

Through Kubernetes and namespace permission management, the problems of server resource waste and high difficulty in implementing multi-tenant isolation in distributed databases are solved, and efficient multi-tenant isolation and unified operation and maintenance are achieved.

CN114239055BActive Publication Date: 2025-09-19上海沄熹科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111428773.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-29
Publication Date
2025-09-19
Estimated Expiration
2041-11-29

AI Technical Summary

Technical Problem

When implementing distributed database multi-tenant isolation, existing technologies have problems such as waste of server resources, inconvenient deployment, easy destruction of virtual machines, and difficulty and high cost in implementing Docker multi-tenant solutions. How to reduce the risks and costs of business deployment is an urgent problem to be solved.

Method used

Kubernetes (k8s) is used as the container orchestration tool, namespace is used as the resource isolation unit, and combined with RBAC permission management, multi-tenant isolation is achieved through network isolation. Specifically, it includes creating PV, Statefulset, database service and certificate management to ensure data isolation and permission control for each tenant.

Benefits of technology

It achieves multi-tenant isolation of distributed databases, reduces the risk and cost of business deployment, has high resource utilization, isolates user data and makes it available on demand, and implements unified operation and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114239055B_ABST
    Figure CN114239055B_ABST
Patent Text Reader

Abstract

The present invention discloses a distributed database multi-tenant isolation method and system, which belongs to the Kubernetes related technical field. The technical problem to be solved by the present invention is how to achieve multi-tenant isolation of distributed databases to reduce the risk and cost of business deployment. The technical solution adopted is: the method uses k8s technology as a container orchestration tool to deploy the database, and uses the namespace provided by k8s as the basic resource isolation unit, while providing a permission management method based on namespace permissions, that is, k8s establishes access control based on user roles, and then allows cross-tenant application requests within the whitelist range between different namespaces by ensuring network isolation between namespaces, thereby achieving multi-tenant isolation of distributed databases. The system includes creation module one, creation module two, creation module three and isolation module.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field related to Kubernetes, and specifically to a distributed database multi-tenant isolation method and system. Background Art

[0002] Kubernetes, or K8s for short, is an open-source framework for managing containerized applications across multiple hosts in a cloud platform. Kubernetes aims to make deploying containerized applications simple and powerful. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance.

[0003] Currently, the following technical solutions are mostly used to implement multi-tenant isolation in distributed databases:

[0004] (1) Physical isolation: Each tenant corresponds to an independent server cluster. Multiple server clusters are managed to deploy multiple tenants using multiple servers to achieve strong physical isolation. However, using multiple servers to solve the multi-tenant isolation of distributed databases still faces relatively serious problems. The ultimate problem of deploying multiple tenants using multiple servers is poor practicality, which will cause waste of server resources and is not very convenient to deploy.

[0005] (2) Virtual Machine: A shared (private) cloud architecture is managed uniformly by a cloud management platform. Distributed databases can be deployed through virtual machines to achieve multi-tenant isolation. It has the advantages of easy scalability, high availability, load balancing, and improved resource utilization. However, virtual machines are built on the host. After all, they are virtual machines and files, and can be easily damaged.

[0006] (3) Containers: Implementing a customized container cloud platform with containers requires first resolving the issue of isolation between tenant containers. The requirements for data isolation and functional customization imply isolation of each tenant's execution environment. Docker is the tentatively selected container solution. For multi-tenancy, Docker needs to add a method for defining users and placing them in namespaces that only allow operations on specific containers and volumes, restricting options that allow breaking out of the container, such as changing functionality or arbitrarily mounting file systems from the host. Docker's enterprise product, UCP, does begin to add these capabilities through the use of labels on objects, but Docker's multi-tenancy solution is not yet complete and may require modifying the underlying code to implement multi-tenancy support, which is difficult and costly to implement.

[0007] Therefore, how to achieve multi-tenant isolation of distributed databases to reduce the risks and costs of business deployment is a technical problem that needs to be solved urgently. Summary of the Invention

[0008] The technical task of the present invention is to provide a distributed database multi-tenant isolation method and system to solve the problem of how to achieve multi-tenant isolation of distributed databases to reduce the risk and cost of business deployment.

[0009] The technical task of the present invention is achieved in the following way: a distributed database multi-tenant isolation method, which uses k8s (Kubernetes) technology as a container orchestration tool to deploy the database, and uses the namespace provided by k8s as the basic resource isolation unit, while providing a permission management method based on namespace permissions (RBAC), that is, k8s establishes user role-based access control, and then ensures network isolation between namespaces. Only cross-tenant application requests within the whitelist range are allowed between different namespaces, thereby realizing multi-tenant isolation of the distributed database.

[0010] Among them, Namespace is another very important concept in the Kubernetes system. Namespace is often used to implement multi-tenant resource isolation. Different businesses can be isolated using different namespaces.

[0011] Namespace permissions (Kubernetes RBAC authorization);

[0012] Namespace permissions are based on Kubernetes RBAC capabilities. By setting permissions, different users or user groups can have the authority to operate different Kubernetes resources. The Kubernetes RBAC API defines four types: Role, ClusterRole, RoleBinding, and ClusterRoleBinding. The relationship between these four types and a brief description are as follows:

[0013] Role: A role defines a set of access rules for Kubernetes resources (at the namespace level).

[0014] RoleBinding: Role binding defines the relationship between users and roles.

[0015] ClusterRole: A cluster role defines a set of access rules for Kubernetes resources (cluster level, including all namespaces).

[0016] ClusterRoleBinding: Cluster role binding defines the relationship between users and cluster roles.

[0017] Role and ClusterRole specify which actions can be performed on which resources. RoleBinding and ClusterRoleBinding bind roles to specific users, user groups, or ServiceAccounts.

[0018] As preferred, the method is as follows:

[0019] Based on Kubernetes, a shared data disk model is adopted to create required PVs in sequence. PVs are used to store data of NewSQL database instances, which makes it easier to scale the database instances and perform backup and restore operations.

[0020] After creating a PV, create a Statefulset. The pods managed by a Statefulset have fixed pod names and a fixed start and stop order. StatefulSet is essentially a variant of Deployment and has become a GA version in v1.9. It is used to solve the problems of stateful services.

[0021] Create a database service through k8s;

[0022] After creating the database service, the database instance can be used normally. The database instance has its own namespace, and isolation between multiple tenants can be achieved through RBAC permission control of the namespace.

[0023] Preferably, before creating a PV, create a PV-mounting directory on the corresponding server's data disk directory / mnt / disks / <database instance name>; the number of PVs depends on the number of database nodes.

[0024] In StatefulSet, the Pod name is the network identifier (hostname). The most significant feature of StatefulSet is that each node cannot use the same storage volume. Each node has its own dedicated storage. Each Pod in StatefulSet has its own dedicated storage volume. Therefore, StatefulSet storage volumes cannot be created using Pod templates. Instead, StatefulSet storage volumes are created using volumeClaimTemplate. VolumeClaimTemplate generates a different PVC for each Pod and binds it to the PV, ensuring that each pod has dedicated storage.

[0025] Better yet, the prerequisite for creating a database service through k8s is to create a certificate. There are three types of certificates: root certificate, user certificate, and node certificate. The details are as follows:

[0026] Generate a root certificate. The root certificate should be as unique as possible and kept properly.

[0027] Node certificates and user certificates need to be signed by a root certificate.

[0028] Better yet, create a database service through k8s as follows:

[0029] Create a configMap object to save the root certificate and key file. K8s saves the certificate through configMap and specifies the namespace.

[0030] Creating a Service in secure mode does not require an additional init job compared to non-secure mode. When issuing node certificates for the newly added initContainers container, the following parameters are added and need to be specified by the administrator: node IP or domain is the node IP or domain name provided by the database instance for external access to k8s; in NodePort mode, node IP or domain is the IP address of a k8s node.

[0031] A distributed database multi-tenant isolation system, the system comprising:

[0032] Create Module 1, which is used to create the required PVs in sequence using a shared data disk model based on Kubernetes. PVs are used to store data for NewSQL database instances, making it easier to scale the database instances and perform backup and restore operations.

[0033] Create Module 2, which is used to create a Statefulset after creating a PV. The pods managed by a Statefulset have fixed pod names and a fixed start and stop order. StatefulSet is essentially a variant of Deployment and has become GA in version 1.9. It is used to solve the problems of stateful services.

[0034] Create module three to create a database service through k8s;

[0035] The isolation module is used to ensure the normal use of the database instance after the database service is created. The database instance has a dedicated namespace, and isolation between multiple tenants can be achieved through RBAC permission control of the namespace.

[0036] Preferably, the creation module three includes:

[0037] The certificate creation submodule is used to create certificates. There are three types of certificates: root certificate, user certificate and node certificate. Specifically: a root certificate is generated. The root certificate should be as unique as possible and kept properly. Node certificates and user certificates need to be issued from the root certificate.

[0038] The object creation submodule is used to create a configMap object to save the root certificate and key file. K8s saves the certificate through configMap and specifies the namespace;

[0039] The Service creation submodule is used to create a service in secure mode. Compared with the non-secure mode, it no longer requires an additional init job. When the newly added initContainers container issues the node certificate, the following parameters are added and need to be specified by the administrator: node IP or domain is the node IP or domain name provided by the database instance for external access to k8s; in NodePort mode, node IP or domain is the IP address of a k8s node.

[0040] An electronic device comprising: a memory and at least one processor;

[0041] wherein the memory stores computer-executable instructions;

[0042] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the distributed database multi-tenant isolation method as described above.

[0043] A computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the distributed database multi-tenant isolation method as described above is implemented.

[0044] The distributed database multi-tenant isolation method and system of the present invention have the following advantages:

[0045] (1) This invention uses the namespace provided by Kubernetes as the basic resource isolation unit and utilizes the RBAC-based permission management method to implement multi-tenant isolation of distributed databases to reduce the risk and cost of business deployment;

[0046] (2) The present invention can achieve the multi-tenancy goal of a distributed database. A single product instance can provide services to multiple users and use resources on demand. User data is isolated from each other, and multiple product instances are integrated for unified operation and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] The present invention will be further described below with reference to the accompanying drawings.

[0048] Attachment Figure 1 Schematic diagram of the distributed database multi-tenant isolation method. DETAILED DESCRIPTION

[0049] The distributed database multi-tenant isolation method and system of the present invention are described in detail below with reference to the accompanying drawings and specific embodiments.

[0050] Example 1:

[0051] As attached Figure 1 As shown, the distributed database multi-tenant isolation method of the present invention uses k8s (Kubernetes) technology as a container orchestration tool to deploy the database, and uses the namespace provided by k8s as the basic resource isolation unit, while providing a permission management method based on namespace permissions (RBAC). That is, k8s establishes user role-based access control, and then ensures network isolation between namespaces. Only cross-tenant application requests within the whitelist range are allowed between different namespaces, thereby realizing multi-tenant isolation of the distributed database; the method is specifically as follows:

[0052] S1. Based on Kubernetes, adopt the shared data disk model and create the required PVs in sequence. PVs are used to store data for NewSQL database instances, which makes it easier to scale the database instances and perform backup and restore operations.

[0053] S2. After creating the PV, create a Statefulset. The pods managed by the Statefulset have fixed pod names and a fixed start and stop order. StatefulSet is essentially a variant of Deployment and has become a GA version in v1.9. It is used to solve the problems of stateful services.

[0054] S3. Create a database service through k8s;

[0055] S4. After creating the database service, the database instance can be used normally. The database instance has its own namespace, and isolation between multiple tenants can be achieved through RBAC permission control of the namespace.

[0056] In this embodiment, before creating a PV, create a PV-mounted directory on the data disk directory / mnt / disks / <database instance name> of the corresponding server; the number of PVs depends on the number of database nodes.

[0057] In the StatefulSet of this embodiment, the Pod name is called the network identifier (hostname). The most significant feature of StatefulSet is that different nodes cannot use the same storage volume. Each node has its own dedicated storage. Each Pod in StatefulSet has its own dedicated storage volume. Therefore, the storage volume of StatefulSet can no longer be created using Pod templates. Therefore, the storage volume of StatefulSet is created using volumeClaimTemplate (volume application template). VolumeClaimTemplate will generate a different PVC for each Pod and bind it to the PV, so that each pod has dedicated storage.

[0058] In this embodiment, the prerequisite for creating a database service through k8s in step S3 is to create a certificate. There are three types of certificates: root certificate, user certificate, and node certificate. The details are as follows:

[0059] (1) Generate a root certificate. The root certificate should be unique as much as possible and kept properly.

[0060] (2) Node certificates and user certificates need to be issued from the root certificate.

[0061] In this embodiment, the details of creating a database service through k8s in step S3 are as follows:

[0062] S301. Create a configMap object to save the root certificate and key file. K8s saves the certificate through configMap and specifies the namespace.

[0063] S302. Create a Service in secure mode. Compared with non-secure mode, no additional init job is required. When the newly added initContainers container issues the node certificate, the following parameters are added and need to be specified by the administrator: node IP or domain is the node IP or domain name provided by the database instance for external access to k8s; in NodePort mode, node IP or domain is the IP address of a k8s node.

[0064] Example 2:

[0065] The distributed database multi-tenant isolation system of the present invention includes:

[0066] Create Module 1, which is used to create the required PVs in sequence using a shared data disk model based on Kubernetes. PVs are used to store data for NewSQL database instances, making it easier to scale the database instances and perform backup and restore operations.

[0067] Create Module 2, which is used to create a Statefulset after creating a PV. The pods managed by a Statefulset have fixed pod names and a fixed start and stop order. StatefulSet is essentially a variant of Deployment and has become GA in version 1.9. It is used to solve the problems of stateful services.

[0068] Create module three to create a database service through k8s;

[0069] The isolation module is used to ensure the normal use of the database instance after the database service is created. The database instance has a dedicated namespace, and isolation between multiple tenants can be achieved through RBAC permission control of the namespace.

[0070] The creation module three in this embodiment includes:

[0071] The certificate creation submodule is used to create certificates. There are three types of certificates: root certificate, user certificate and node certificate. Specifically: a root certificate is generated. The root certificate should be as unique as possible and kept properly. Node certificates and user certificates need to be issued from the root certificate.

[0072] The object creation submodule is used to create a configMap object to save the root certificate and key file. K8s saves the certificate through configMap and specifies the namespace;

[0073] The Service creation submodule is used to create a service in secure mode. Compared with the non-secure mode, it no longer requires an additional init job. When the newly added initContainers container issues the node certificate, the following parameters are added and need to be specified by the administrator: node IP or domain is the node IP or domain name provided by the database instance for external access to k8s; in NodePort mode, node IP or domain is the IP address of a k8s node.

[0074] Example 3:

[0075] An embodiment of the present invention further provides an electronic device, comprising: a memory and a processor;

[0076] wherein the memory stores computer-executable instructions;

[0077] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the distributed database multi-tenant isolation method of any embodiment.

[0078] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor may be a microprocessor or any conventional processor, etc.

[0079] The memory can be used to store computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory and accessing the data stored in the memory. The memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system and at least one application required for the function; the data storage area can store data generated based on the use of the terminal. In addition, the memory can also include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0080] Example 4:

[0081] An embodiment of the present invention further provides a computer-readable storage medium storing a plurality of instructions, which are loaded by a processor to cause the processor to execute the distributed database multi-tenant isolation method according to any embodiment of the present invention. Specifically, a system or device equipped with a storage medium can be provided, wherein the storage medium stores software program code that implements the functions of any of the above-described embodiments, and a computer (or CPU or MPU) of the system or device can read and execute the program code stored in the storage medium.

[0082] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute part of the present invention.

[0083] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (e.g., CD-ROMs, CD-Rs, CD-RWs, DVD-ROMs, DVD-RAMs, DVD-RWs, and DVD+RWs), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer via a communications network.

[0084] In addition, it should be clear that the functions of any of the above embodiments can be achieved not only by executing the program code read by the computer, but also by enabling the operating system operating on the computer to complete part or all of the actual operations based on the instructions of the program code.

[0085] In addition, it can be understood that the program code read from the storage medium is written into the memory provided in the expansion board inserted into the computer or into the memory provided in the expansion unit connected to the computer, and then based on the instructions of the program code, the CPU installed on the expansion board or expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above embodiments.

[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A distributed database multi-tenant isolation method, characterized in that: This method uses k8s technology as a container orchestration tool to deploy the database, and uses the namespace provided by k8s as the basic resource isolation unit. It also provides a permission management method based on namespace permissions. That is, k8s establishes access control based on user roles, and then ensures network isolation between namespaces. It allows cross-tenant application requests within the whitelist range between different namespaces, thereby achieving multi-tenant isolation of distributed databases. The details are as follows: Based on Kubernetes, a shared data disk model is adopted to create required PVs in sequence. PVs are used to store data of NewSQL database instances, which makes it easier to scale the database instances and perform backup and restore operations. After creating PV, create Statefulset. The Pods managed by Statefulset have fixed Pod names and start and stop orders. Create a database service through k8s; After creating the database service, the database instance can be used normally. The database instance has its own namespace, and the RBAC permission control of the namespace can achieve isolation between multiple tenants. Before creating a PV, create a PV-mounted directory on the corresponding server's data disk directory / mnt / disks / database instance name; the number of PVs depends on the number of database nodes; In a StatefulSet, the Pod name is used as the network identifier. Each Pod in a StatefulSet has its own dedicated storage volume. The StatefulSet storage volume is created using the volumeClaimTemplate. The volumeClaimTemplate generates a different PVC for each Pod and binds it to the PV, ensuring that each Pod has dedicated storage. The prerequisite for creating a database service through k8s is to create a certificate. There are three types of certificates: root certificate, user certificate, and node certificate. The details are as follows: Generate a root certificate, which is guaranteed to be unique; Node certificates and user certificates need to be issued from the root certificate; The details of creating a database Service through k8s are as follows: Create a configMap object to save the root certificate and key file. K8s saves the certificate through configMap and specifies the namespace. When creating a Service in security mode and issuing a node certificate for the newly added initContainers container, add the administrator-specified parameter node IP or domain. The node IP or domain is the node IP or domain name provided by the corresponding database instance for external access to k8s. In NodePort mode, the node IP or domain is the IP address of a k8s node.

2. A distributed database multi-tenant isolation system, characterized in that: The system uses k8s technology as a container orchestration tool to deploy the database, and uses the namespace provided by k8s as the basic resource isolation unit. It also provides a permission management method based on namespace permissions. That is, k8s establishes access control based on user roles, and then ensures network isolation between namespaces. It allows cross-tenant application requests within the whitelist range between different namespaces, thereby achieving multi-tenant isolation of distributed databases. The system includes: Create Module 1, which is used to create the required PVs in sequence using a shared data disk model based on Kubernetes. PVs are used to store data for NewSQL database instances, making it easier to scale the database instances and perform backup and restore operations. Create Module 2, which is used to create a Statefulset after creating a PV. The Pods managed by the Statefulset have fixed Pod names and start and stop orders. Create module three to create a database service through k8s; The isolation module is used to ensure the normal use of the database instance after the database service is created. The database instance has a dedicated namespace, and the RBAC permission control of the namespace can be used to achieve isolation between multiple tenants. Among them, the creation module three includes: The certificate creation submodule is used to create certificates. There are three types of certificates: root certificate, user certificate and node certificate. Specifically: a root certificate is generated, and the root certificate is guaranteed to be unique; node certificates and user certificates need to be issued from the root certificate; The object creation submodule is used to create a configMap object to save the root certificate and key file. K8s saves the certificate through configMap and specifies the namespace; The Service creation submodule is used to create a Service in security mode. When the newly added initContainers container issues the node certificate, the administrator specifies the parameter node IP or domain. The node IP or domain is the node IP or domain name provided by the corresponding database instance for external access to k8s. In NodePort mode, the node IP or domain is the IP address of a k8s node.

3. An electronic device, characterized in that: include: memory and at least one processor; wherein the memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the distributed database multi-tenant isolation method as described in claim 1.

4. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the distributed database multi-tenant isolation method according to claim 1 is implemented.

Citation Information

Patent Citations

  • Method and system for isolating resources among cloud tenants based on namespace binding

    CN111324456A

  • Containerized deployment method and device for stateful applications

    CN112783646A