A method for setting up a tenant-specific DNS server for an application on a container cloud platform
By registering a domain name resolution policy automatic setting tool in the container cloud platform, the tenant-specific DNS server IP is automatically set for the workload, and pods are deleted and rebuilt in batches when the IP changes, which solves the configuration coupling and cost issues caused by changes in the DNS server IP. An efficient update process is achieved.
Patent Information
- Application Number
- CN202111063744.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-10
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-09-10
AI Technical Summary
In the container cloud platform, when the tenant's DNS server IP changes, the workload configuration of a large number of applications needs to be updated, resulting in coupling of development and operation and maintenance, high time and labor costs, and easy omissions.
In the container cloud platform, by registering the domain name resolution policy automatic setting tool during cluster initialization, the tenant-specific DNS server IP is automatically set for the workload, and pods are deleted in batches when the DNS server IP changes, waiting for automatic reconstruction to update the DNS server address.
It realizes the decoupling of DNS server settings and workload, reduces omissions and labor costs during updates, improves the overall update efficiency, and the solution is flexible and easy to expand.
Smart Images

Figure CN113965546B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of setting up a tenant-specific DNS server, and in particular to a method for a container cloud platform to set up a tenant-specific DNS server for an application. Background Art
[0002] Most of the current container cloud platforms are based on the k8s framework (k8s is the abbreviation of kubernetes, which is a common open source container orchestration architecture for container cloud platforms, capable of automatic scheduling, expansion, and fault recovery of containers, etc.), providing users with a functional system with application management as the core. Containerized applications are deployed on the kubernetes cluster in the form of workloads. Each workload can run one or more instances (pods) at the same time. Pod is the smallest management unit of k8s, consisting of one or more containers, which share process, network, and other namespaces. Each pod has its own network information configuration, such as the DNS configuration file / etc / resolv.conf.
[0003] In a production environment, applications often access each other through domain names. Each application configures a fixed DNS server IP in the DNS server configuration file of its network space, and resolves and returns the actual IP of the callee through the domain name server. The advantage of this is that when the access IP of the callee changes, as long as the domain name does not change, the request initiator does not need to make any changes. In the container cloud platform, each pod network space will have a separate / etc / resolv.conf file, which records the IP of the domain name server. By default, the IP is the DNS server IP of the k8s cluster. At the same time, k8s also supports setting dnspolicy (domain name resolution policy) for each workload separately, modifying the / etc / resolv.conf file to fill in the specified DNS server IP. Workload is the deployment form of application components on k8s, including deployment (stateless load) / statefulset (stateful load) / job (task) / cronjob (scheduled task) / daemonset (daemon process) and other forms.
[0004] In actual scenarios, each tenant often has its own set of dedicated DNS servers. All applications within the tenant need to connect to the DNS server for domain name resolution in accordance with the specifications, so as to access each other. According to the design mechanism of the k8s standard, in this scenario, all tenant applications need to specify dnspolicy when creating workloads. The problems caused by this design solution include: application developers need to accurately know the IP of the DNS server when deploying applications and perform relevant configurations, which will lead to the coupling of development and operation and maintenance in the DNS server settings; when there are a large number of applications in the tenant, once the DNS server IP changes, all applications need to modify the workload configuration and recreate it, which is very easy to cause omissions, and the communication between different application development teams will also bring certain time and labor costs. For these problems, we need a more intelligent and automated method for tenant-level dedicated DNS server settings. Summary of the invention
[0005] The purpose of the present invention is to solve the above problems and provide a method for a container cloud platform to set up a tenant-specific DNS server for an application, without specifying a DNS policy when creating a workload, thereby reducing the coupling between application development and operation and maintenance in DNS server configuration, and avoiding the risks of omissions, time and labor costs caused by DNS server changes in a large number of application scenarios within the tenant.
[0006] In order to achieve the above object, the present invention adopts the following technical solution:
[0007] A method for setting a tenant-specific DNS server for an application on a container cloud platform, comprising:
[0008] Step 1: When the cluster is initialized, register the domain name resolution policy automatic setting tool to the parameters of the external service interface of the k8s container orchestration system;
[0009] Step 2: When creating an instance pod for a workload, the external service interface of the k8s container orchestration system automatically calls the domain name resolution policy automatic setting tool to set the domain name resolution policy of the instance pod to the tenant-specific DNS server IP.
[0010] The working method of the domain name resolution strategy automatic setting tool includes:
[0011] Step 1.1, interact with the cloud platform database to obtain the exclusive DNS server IP corresponding to the tenant;
[0012] Step 1.2: When creating an instance pod for a workload, obtain the tenant to which the current instance pod belongs, and query the private DNS server corresponding to the tenant;
[0013] Step 1.3: Change the domain name resolution policy of the current instance pod to the tenant-specific DNS server IP.
[0014] The cloud platform database stores the correspondence between tenants and dedicated DNS server IP information.
[0015] When the tenant-specific DNS server IP changes, delete all tenants' pods in batches at once, wait for the pods to be automatically recreated, and call the domain name resolution policy automatic setting tool again during the creation process to set the domain name resolution policy of the instance pod to the latest tenant-specific DNS server IP.
[0016] Beneficial effects of the present invention:
[0017] (1) There is no need to set up a DNS server when creating each workload, so that the DNS server setting is decoupled from the workload.
[0018] (2) When the DNS server address changes, there is no need to update the workload. Simply delete all pods and wait for the pods to be automatically created to apply the latest DNS server address settings, thereby improving overall update efficiency.
[0019] (3) The overall solution is flexible and easy to expand. If there are new requirements, the adminssion controller processing logic can be modified directly without modification. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0021] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0022] like Figure 1 As shown, a method for a container cloud platform to set up a tenant-specific DNS server for an application includes:
[0023] At the cloud platform level, the relationship between tenants and dedicated DNS server IP information is maintained in the database;
[0024] When the cluster is initialized, the dnspolicy controller is automatically set to register with the parameters of the kube-apiserver; the kube-apiserver is the external service API of the k8s container orchestration system. All resource-related operations in k8s need to call the kube-apiserver related interfaces to implement;
[0025] When a pod is created, kube-apiserver automatically calls the registered controller to modify the pod information and change the dnspolicy to the tenant-specific DNS server IP.
[0026] The working methods of dnspolicy automatic setting controller include:
[0027] Interact with the cloud platform database to obtain the exclusive DNS server IP corresponding to the tenant;
[0028] Modify the pod information, set the dnspolicy to the tenant-specific DNS server IP according to the namespace to which the pod belongs. Namespace is a type of k8s resource used for group management of k8s resources. It is often used to correspond to tenants in the cloud platform, that is, resources in a namespace belong to the same tenant.
[0029] When the tenant-specific DNS server IP changes, all tenants' pods are deleted in batches at one time, and the pods are automatically recreated. During the creation process, the dnspolicy automatic setting controller is also called to modify the pod dnspolicy based on the latest tenant-specific DNS server IP.
[0030] The present invention is based on the adminssion webhook mechanism of k8s. By developing an automatic DNS policy setting tool, the relationship between the tenant (namespace) to which the current workload belongs and the dedicated DNS server is queried during the process of creating a pod for the workload, and the corresponding DNS policy is automatically set. There is no need to specify the DNS policy when creating the workload, thereby reducing the coupling between application development and operation and maintenance on the DNS server configuration, and avoiding the risks of omissions, time and labor costs caused by DNS server changes in a large number of application scenarios within the tenant.
[0031] k8s provides an admission webhook mechanism that allows custom admission controllers to be called during resource creation to perform verification and modification actions. Based on this mechanism, the dnspolicy can be used to automatically set the controller. When creating a pod for a workload, the namespace to which the current pod belongs is obtained, and the dedicated DNS server corresponding to the namespace is queried. The dnspolicy of the pod is modified to set it to the dedicated DNS server IP.
[0032] Application developers do not need to specify dnspolicy when creating workloads. When the IP address of a tenant's dedicated DNS server changes, they only need to batch delete all pods under the tenant. The pods will be automatically rebuilt and the dnspolicy will be automatically updated to the latest DNS server IP address according to the admission webhook mechanism during the creation process, avoiding omissions, time and labor costs caused by modifying workloads.
[0033] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.
Claims
1. A method for a container cloud platform to set up a tenant-specific DNS server for an application. Its characteristics are: include: Step 1: When the cluster is initialized, register the domain name resolution policy automatic setting tool to the parameters of the external service interface of the k8s container orchestration system; Step 2: When creating an instance pod for a workload, the external service interface of the k8s container orchestration system automatically calls the domain name resolution policy automatic setting tool to set the domain name resolution policy of the instance pod to the tenant-specific DNS server IP; The working method of the domain name resolution strategy automatic setting tool includes: Step 1.1: Interact with the cloud platform database to obtain the exclusive DNS server IP corresponding to the tenant; Step 1.2: When creating an instance pod for a workload, obtain the tenant to which the current instance pod belongs, and query the private DNS server corresponding to the tenant; Step 1.3: Modify the domain name resolution strategy of the current instance pod to the tenant-specific DNS server IP; At the cloud platform layer, the relationship between tenants and dedicated DNS server IP information is maintained in the database. Based on the k8s adminssion webhook mechanism, by developing a DNS policy automatic setting tool, the relationship between the tenant to which the current workload belongs and the dedicated DNS server can be queried during the process of creating a pod for the workload, and the corresponding DNS policy can be automatically set.
2. A method for setting up a tenant-specific DNS server for an application on a container cloud platform as claimed in claim 1, Its characteristics are: The cloud platform database stores the correspondence between tenants and dedicated DNS server IP information.
3. A method for setting up a tenant-specific DNS server for an application on a container cloud platform as claimed in claim 1, Its characteristics are: When the tenant-specific DNS server IP changes, delete all tenants' pods in batches at once, wait for the pods to be automatically recreated, and call the domain name resolution policy automatic setting tool again during the creation process to set the domain name resolution policy of the instance pod to the latest tenant-specific DNS server IP.
