Data processing method, K8s service system and computer readable storage medium
By creating virtual machine objects and generating startup code configuration data within the enterprise, and using Pod containers to create virtual machine instances, KaaS service automation is achieved under resource-constrained conditions, reducing the impact on physical host resource planning. Lightweight virtualization management is achieved by using general Kubernetes clusters and physical servers as infrastructure.
Patent Information
- Application Number
- CN202411596251.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-02-28
AI Technical Summary
How can we minimize the impact on physical server resource planning when providing KaaS services when internal enterprise resources are limited?
The K8s cluster provisioning module creates virtual machine objects, the K8s node configuration generation module generates startup code configuration data, and the virtual machine instance provisioning module creates Pod objects to create virtual machine instances through Pod containers. This enables the automated creation of Kubernetes clusters as a KaaS service, using general-purpose Kubernetes clusters and physical servers as the underlying infrastructure and sharing underlying resources.
It enables the automated creation of Kubernetes clusters as a KaaS service when enterprise resources are limited, reducing the impact on physical host resource planning and enabling lightweight virtualization management through container and Kubernetes technologies.
Smart Images

Figure CN119536908A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data processing method, a K8s service system and a computer-readable storage medium. Background Art
[0002] Currently, most public cloud platforms provide fully automated KaaS (Kubernetes as a Service), such as Azure AKS, Google GKE, etc., which means that users can create independent K8s clusters by performing simple self-service operations on the platform.
[0003] The automated K8s service on the public cloud platform is deeply dependent on the underlying IaaS infrastructure. In the process of automatically providing the K8s cluster, the virtual machine instance is automatically created by calling the existing virtual machine service interface on the IaaS platform, and the relevant instructions for joining the K8s cluster are executed on the newly created virtual machine through some automated script solution. In this process, the computing nodes of the K8s cluster are provided.
[0004] Therefore, how to reduce the impact on resource planning of physical hosts when providing KaaS services when the internal resources of the enterprise are limited is a problem that needs to be solved urgently. Summary of the invention
[0005] The main purpose of this application is to provide a data processing method, a K8s service system and a computer-readable storage medium, aiming to solve the technical problem of how to reduce the impact on resource planning of physical hosts when providing KaaS services when the internal resources of the enterprise are limited.
[0006] To achieve the above purpose, the present application provides a data processing method, which is applied to a K8s service system. The K8s service system includes a physical K8s cluster, a K8s cluster provisioning module, a K8s node configuration generation module, and a virtual machine instance provisioning module, including:
[0007] The physical K8s cluster receives a K8sCluster object, wherein the K8sCluster object includes creation information corresponding to the cluster creation request;
[0008] The K8s cluster provisioning module creates a virtual machine object based on the K8sCluster object, and the K8s node configuration generation module generates startup code configuration data based on the K8sCluster object;
[0009] The virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object, and adds startup code configuration data to the Pod container;
[0010] The virtual machine instance provisioning module creates a virtual machine instance through the Pod container to enable the VMM process to run, and performs an initialization operation to enable the virtual machine instance to join the Kubernetes cluster.
[0011] Furthermore, the virtual machine object includes a first virtual machine object for creating a control plane node of a Kubernete cluster and a second virtual machine object for creating a computing node of a Kubernetes cluster, and the step of the K8s cluster provisioning module creating a virtual machine object based on the K8sCluster object includes:
[0012] The K8s cluster provisioning module obtains the K8sCluster object from the physical K8s cluster, and parses the K8sCluster object to obtain the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and the resource configuration specifications corresponding to each node in the creation information;
[0013] The K8s cluster provisioning module creates the first virtual machine object based on the resource configuration specification and the number of Kubernetes control plane nodes, and creates the second virtual machine object based on the resource configuration specification and the number of Kubernetes computing nodes.
[0014] Furthermore, the step of the K8s node configuration generation module generating startup code configuration data based on the K8sCluster object includes:
[0015] The K8s cluster provisioning module obtains the K8sCluster object from the physical K8s cluster, and parses the K8sCluster object to obtain the number of Kubernetes control plane nodes and the number of Kubernetes computing nodes in the creation information;
[0016] The K8s cluster provisioning module generates startup code configuration data corresponding to each node based on the number of Kubernetes control plane nodes and the number of Kubernetes computing nodes, and saves the startup code configuration data to the corresponding ConfigMap object.
[0017] Furthermore, the step of the K8s cluster provisioning module creating the first virtual machine object based on the resource configuration specification and the number of Kubernetes control plane nodes includes:
[0018] For a target control plane node in each Kubernetes control plane node, the K8s cluster provisioning module obtains a target ConfigMap object name of a ConfigMap object storing startup code configuration data corresponding to the target control plane node;
[0019] The K8s cluster provisioning module creates a target virtual machine object based on the resource configuration specification corresponding to the target control plane node;
[0020] The K8s cluster provisioning module sets the target ConfigMap object name in the target virtual machine object and obtains the first virtual machine object corresponding to the target control plane node.
[0021] Furthermore, the steps of the virtual machine instance provisioning module creating a virtual machine instance through the Pod container to enable the VMM process to run, and performing an initialization operation to enable the virtual machine instance to join the Kubernetes cluster include:
[0022] The virtual machine instance provisioning module obtains the startup code configuration data from the ConfigMap object through the Pod container as an ISO disk image file;
[0023] The virtual machine instance provisioning module creates a virtual machine instance through the cloud-hypervisor program in the Pod container, so that the VMM process runs, wherein the virtual machine operating system image file in the container image is used as the virtual machine disk, and the ISO disk image file is used as the external storage drive;
[0024] When the operating system of the virtual machine instance starts, the CloudInit initialization operation is executed to enable the virtual machine instance to join the Kubernetes cluster.
[0025] Furthermore, after the step of creating a virtual machine object based on the K8sCluster object, the K8s cluster provisioning module further includes:
[0026] The K8s cluster provisioning module uploads the virtual machine object to the physical K8s cluster;
[0027] The steps of the virtual machine instance provisioning module creating a Pod object including a VMM program based on the virtual machine object and adding startup code configuration data to the Pod container include:
[0028] The virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object in the physical K8s cluster;
[0029] The virtual machine instance provisioning module uses the startup code configuration data as a file in the Pod container.
[0030] Furthermore, the virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object in the physical K8s cluster, including:
[0031] The virtual machine instance provisioning module obtains virtual machine configuration information based on the virtual machine object in the physical K8s cluster;
[0032] The virtual machine instance provisioning module creates a Kubernetes Pod object template, and fills the virtual machine configuration information into the Kubernetes Pod object template to obtain the Pod object.
[0033] Furthermore, the K8s service system further includes a KaaS service encapsulation module, and before the step of the physical K8s cluster receiving the K8sCluster object, it also includes:
[0034] The KaaS service encapsulation module receives creation information corresponding to the K8s cluster creation request, wherein the creation information includes the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and resource configuration specifications corresponding to each node;
[0035] The KaaS service encapsulation module converts the creation information into the K8sCluster object and uploads the K8sCluster object to the physical K8s cluster.
[0036] In addition, to achieve the above-mentioned purpose, the present application also provides a K8s service system, which includes: a memory, a processor, and a data processing program stored on the memory and executable on the processor, and the data processing program implements the steps of the aforementioned data processing method when executed by the processor.
[0037] In addition, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which a data processing program is stored, and when the data processing program is executed by a processor, the steps of the aforementioned data processing method are implemented.
[0038] The present application receives a K8sCluster object through the physical K8s cluster, wherein the K8sCluster object includes creation information corresponding to a cluster creation request; then the K8s cluster provisioning module creates a virtual machine object based on the K8sCluster object, and the K8s node configuration generation module generates startup code configuration data based on the K8sCluster object; then the virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object, and adds the startup code configuration data to the Pod container; then the virtual machine instance provisioning module creates a virtual machine instance through the Pod container to enable the VMM process to run, and performs an initialization operation to enable the virtual machine instance to join the Kubernets cluster, creates a virtual machine object through the K8s cluster provisioning module, the K8s node configuration generation module generates startup code configuration data, and the virtual machine instance provisioning module creates a Pod object to create a virtual machine instance through the Pod container, thereby realizing automatic creation of a KaaS service for a Kubernets cluster, using a general Kubernets cluster and a physical server as underlying infrastructure to provide a KaaS service, and sharing underlying resources with other software to reduce the impact on resource planning of the physical host.
[0039] At the same time, container technology is used to run the VMM process to start virtual machine instances, and Kubernetes technology is used to schedule VMM containers to achieve low-cost and lightweight virtualization management. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0042] Figure 1 A flowchart of the first embodiment of the data processing method of the present application is provided;
[0043] Figure 2 This is a functional module diagram of an embodiment of the K8s service system of the present application;
[0044] Figure 3 This is a functional module diagram of an embodiment of a virtual machine instance provisioning module in a K8s service system of the present application;
[0045] Figure 4This is a schematic diagram of the module structure of the data processing device according to an embodiment of the present application.
[0046] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0047] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0049] The main solution of the present application is: the physical K8s cluster receives a K8sCluster object, wherein the K8sCluster object includes creation information corresponding to a cluster creation request; the K8s cluster provisioning module creates a virtual machine object based on the K8sCluster object, and the K8s node configuration generation module generates startup code configuration data based on the K8sCluster object; the virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object, and adds the startup code configuration data to the Pod container; the virtual machine instance provisioning module creates a virtual machine instance through the Pod container to enable the VMM process to run, and performs initialization operations to enable the virtual machine instance to join the Kubernets cluster.
[0050] Currently, most public cloud platforms provide fully automated KaaS (Kubernetes as a Service), such as Azure AKS, Google GKE, etc., which means that users can create independent K8s clusters by performing simple self-service operations on the platform.
[0051] The automated K8s service on the public cloud platform is deeply dependent on the underlying IaaS (Infrastructure as a Service) infrastructure. In the process of automatically providing the K8s cluster, the virtual machine instance is automatically created by calling the existing virtual machine service interface on the IaaS platform, and the relevant instructions for joining the K8s cluster are executed on the newly created virtual machine through some automated script solution, thereby providing the computing nodes of the K8s cluster. However, the KaaS service for the public cloud platform relies on the API of the underlying IaaS platform of each public cloud platform, which is not replicable and cannot be applied in the offline private environment within the enterprise.
[0052] Currently, command-line tools such as Kubespray, Kops, and kk can realize functions such as automatic configuration of K8s nodes and automatic joining of K8s nodes, but the Linux server host resources used to create the K8s cluster need to be manually prepared in advance; software systems such as Proxmox and Harvester provide lightweight virtualization management functions, which to a certain extent improve the automation and efficiency of creating computing nodes when providing K8s cluster services in batches. Such software systems provide functions in the form of dedicated virtualization operating systems (similar to VMWare ESXI) and require exclusive physical servers. As a result, the existing open source K8s cluster creation tools cannot solve the problem of automatically creating Linux hosts, and cannot realize the automated provision of KaaS services in the offline environment within the enterprise. It still requires the use of multiple physical servers to install this lightweight virtualization management system, and cannot realize the low-cost automated KaaS services in the enterprise environment.
[0053] Therefore, how to reduce the impact on resource planning of physical hosts when providing KaaS services when the internal resources of the enterprise are limited is a problem that needs to be solved urgently.
[0054] This application creates virtual machine objects through the K8s cluster provisioning module, generates startup code configuration data through the K8s node configuration generation module, and creates Pod objects through the virtual machine instance provisioning module to create virtual machine instances through Pod containers, thereby automatically creating KaaS services for Kubernets clusters, using general Kubernets clusters and physical servers as underlying infrastructure to provide KaaS services, and sharing underlying resources with other software to reduce the impact on resource planning of physical hosts.
[0055] It should be noted that the execution subject of this embodiment can be a K8s service system, or a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a data processing device capable of realizing the above functions, etc., and this embodiment does not specifically limit this. The following takes the K8s service system as an example of the execution subject to illustrate this embodiment and the following embodiments.
[0056] Based on this, this application proposes a data processing method of the first embodiment, please refer to Figure 1 to Figure 2 The data processing method is applied to a K8s service system, which includes a physical K8s cluster, a K8s cluster provisioning module, a K8s node configuration generation module, and a virtual machine instance provisioning module.
[0057] The physical K8s cluster includes multiple physical hosts, that is, the physical K8s cluster is a deployed Kubernetes cluster based on physical host nodes, and the physical K8s cluster may be a cluster in use.
[0058] Reference Figure 3 The virtualization instance provisioning module consists of the virtualization instance controller Operator (cloud native virtualization Operator controller), KVM virtual machine (Kernel-based Virtual Machine, KVM) monitor VMM (Virtual Machine Monitor), virtual machine container Pod, and the virtual machine instance itself.
[0059] The virtualization instance controller Operator defines a resource type: "VirtualMachine" through the K8s CRD mechanism, and creates virtual machines or modifies and deletes virtual machine instances by monitoring the VirtualMachine object instance submitted to the physical host K8s api-server. The virtual machine instance created is a virtual machine instance based on KVM technology. This instance starts the VMM process for controlling the KVM virtual machine by running the container through the Kubernetes Pod object; the system can use a variety of KVM virtual machine VMMs, such as Cloud Hypervisor or QEMU, two open source solutions.
[0060] Among them, the properties of the "VirtualMachine" object type include: VirtualMachine.Size, VirtualMachine.Disks, VirtualMachine.Volumes and VirtualMachine.NetInterfaces;
[0061] VirtualMachine.Size is cpu (set the number of CPU cores) and memory (set the memory size); VirtualMachine.Disks is to set the virtual disk mounted by the virtual machine, which can be a virtual disk in QCOW2 or RAW format (the Linux operating system magnetic image running in the virtual machine is mounted in this way). The QCOW2 data file is saved in the container image to facilitate downloading when starting the Pod in the K8s environment. VirtualMachine.Volumes is to set the data content of the virtual machine CloudInit image file (the startup configuration code data is mounted in this way), which is referenced by the ConfigMap object name; VirtualMachine.NetInterfaces is to set the Linux virtual network device to which the virtual machine is connected.
[0062] When the VMM process is run in the container Pod and the KVM virtual machine instance is started on the physical host, the virtual device in the container Pod used to connect the Pod to the Kubernets container network is connected to the started KVM host through the Linux bridge device, so that the KVM virtual machine started by the VMM process is connected to the Kubernetes container network to support the subsequent launch of multiple cloud-native virtualization instances to communicate through the container network and form a new Kubernetes cluster.
[0063] When the virtual machine instance Pod is started, a standard container image is used. The container image stores the virtual disk file (usually in QCOW2 format) and the VMM program binary file (cloud-hypervisor) used to start the KVM virtual machine instance. When the Pod container is started, the cloud-hypervisor program in the container initiates the KVM virtual machine creation instruction to the physical machine operating system kernel (Linux Kernel), including loading the specified virtual machine system kernel, configuring the virtual machine's virtual hardware resources (CPU, memory, mounted disk, network interface), and starting the virtual machine operating system to officially start the controlled virtual machine. Before the VMM Pod container exits, the VMM process will also issue a shutdown control instruction to the virtual machine instance so that the virtual machine operating system is properly shut down.
[0064] When starting a virtual machine instance through the VMM process in a container Pod, you can set the startup configuration code of the virtual machine instance by mounting a storage volume device for the virtual machine. This startup configuration code will be loaded and read by the Cloud Init software built into the virtual machine image when the virtual machine is started for the first time, thereby executing specific Linux commands to complete software configuration, system initialization and other operations of a virtual machine; this function is used in this system to execute the process of starting a Kubernetes node and joining a cluster.
[0065] The K8s cluster provisioning module includes a K8s cluster provisioning controller Operator, which is used to coordinate the virtualization instance provisioning module and the K8s node configuration generation module. It creates multiple cloud-native virtual machine instances and loads the virtual machine startup configuration code from the K8s node configuration generation module for them to realize the formation of a K8s cluster with multiple cloud-native virtual machine instances.
[0066] The K8s cluster provisioning controller Operator provides a "K8sCluster" resource type through the Kubernetes CRD mechanism, which is used to configure the key parameters of the K8s cluster (such as the number of control plane nodes, the number of working nodes, the K8s cluster container network address range, etc.), and in the controller program, it listens to the "K8sCluster object instance" submitted to the underlying physical host K8s api-server to create cloud-native virtual machine instances, load K8s node configurations, and other actions.
[0067] Each virtual machine instance used to form the K8s cluster created by KaaS needs to run certain initialization commands to complete the action of joining the K8s cluster. The K8s cluster provisioning module uses the ConfigMap function of Kubernetes to load the K8s node virtual machine startup configuration code generated by the K8s node configuration generation module into the virtual machine instance Pod container. When creating a VirtualMachine object, the configuration data in the ConfigMap is set as a virtual machine storage volume (Volume) in the VirtualMachine object, and the startup code is converted into an ISO disk file in the VMM Pod container for the virtual machine to read.
[0068] The K8s node configuration generation module monitors the "K8sCluster" resource object created by the K8s cluster provisioning module in the physical host Kubernetes cluster, analyzes the number of configured Kubernetes nodes and node startup parameters, and generates corresponding "startup code configuration data" for the two types of K8s nodes that need to be created. This code is saved in the Kubernetes ConfigMap object for reading by the K8s cluster provisioning module and the cloud-native virtualization instance provisioning module.
[0069] The main properties of the K8sCluster object include: K8sCluster.ControlPlaneNodes, K8sCluster.ComputeNodes, and K8sCluster.KubernetesConfig.
[0070] K8sCluster.ControlPlaneNodes is used to set the number of control plane nodes for KaaS to start the K8s cluster; K8sCluster.ComputeNodes is used to set the number of computing nodes for KaaS to start the K8s cluster; K8sCluster.KubernetesConfig is used to set the customized startup parameters of K8s (such as the startup parameters of kubelet and api-server). The data type is consistent with the configuration file of Kubernetes' node initialization tool "kubeadm" for direct use. kubeadm is a common tool in the Kubernetes open source project, which is used to complete the startup of a K8s node on a Linux host. The K8s node startup configuration code (startup code configuration data) is mainly used to generate the configuration file of kubeadm.
[0071] The KaaS service encapsulation module encapsulates the functions provided by other modules and provides the function of quickly creating a K8s cluster in the form of an API, thereby providing KaaS services without relying on the load IaaS platform. The KaaS service encapsulation module is created in the api-server in the physical K8s cluster.
[0072] Among them, Kubernetes Operator is an automated management technology based on the Kubernetes platform, which aims to simplify the deployment and operation of complex applications. Through Kubernetes Operator, users can define custom resources and controllers to achieve automated management and operation of specific applications. It mainly includes the following core concepts:
[0073] Custom Resources allows Kubernetes Operators to define their own resource types, which can represent the components, configurations, and states of an application. Users can use custom resources to describe specific requirements and behaviors of an application.
[0074] Controllers are the core components of Kubernetes Operators and are responsible for monitoring and managing the status of custom resources. Controllers perform corresponding operations based on the status changes of custom resources to ensure that the application runs as expected.
[0075] The data processing method comprises steps S101 to S104:
[0076] Step S10, the physical K8s cluster receives a K8sCluster object, wherein the K8sCluster object includes creation information corresponding to the cluster creation request;
[0077] In this embodiment, the K8sCluster object is obtained by the KaaS service encapsulation module and uploaded to the physical K8s cluster. Specifically, the KaaS service encapsulation module parses the K8s cluster creation request and obtains the creation information corresponding to the K8s cluster creation request, which includes the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and the resource configuration specifications corresponding to each node, wherein the resource configuration specifications include basic configurations such as CPU, memory, and disk capacity. The KaaS service encapsulation module converts the creation information into a K8sCluster object and uploads the K8sCluster object to the physical K8s cluster api-server. The physical K8s cluster receives the K8sCluster object submitted by the KaaS service encapsulation module.
[0078] Step S102, the K8s cluster provisioning module creates a virtual machine object based on the K8sCluster object, and the K8s node configuration generation module generates startup code configuration data based on the K8sCluster object;
[0079] In this embodiment, the K8s node configuration generation module receives the "K8sCluster" object from the physical K8s cluster api-server, and generates startup code configuration data based on the K8sCluster object. Further, step S102 may include steps S1021 to S1022:
[0080] Step S1021, the K8s cluster provisioning module obtains the K8sCluster object from the physical K8s cluster, and parses the K8sCluster object to obtain the number of Kubernetes control plane nodes and the number of Kubernetes computing nodes in the creation information;
[0081] Step S1022: The K8s cluster provisioning module generates startup code configuration data corresponding to each node based on the number of Kubernetes control plane nodes and the number of Kubernetes computing nodes, and saves the startup code configuration data to the corresponding ConfigMap object.
[0082] In this embodiment, the K8s cluster provisioning module obtains the K8sCluster object from the physical K8s cluster, and parses the K8sCluster object to obtain creation information, which includes the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and the resource configuration specifications corresponding to each node.
[0083] After obtaining the creation information, the K8s cluster provisioning module generates the startup code configuration data corresponding to each node based on the number of Kubernetes control plane nodes and the number of Kubernetes computing nodes. Specifically, for each node in the number of Kubernetes control plane nodes and the Kubernetes computing nodes, the K8s cluster provisioning module generates the corresponding startup code configuration data and saves the startup code configuration data in the Kubernetes ConfigMap object, where the ConfigMap object uses a fixed naming method agreed with the K8s cluster provisioning module. The ConfigMap object name corresponding to each node can be obtained from the preset agreed information, so that the K8s cluster provisioning module can correctly reference the corresponding startup code configuration data according to the ConfigMap object name to improve the accuracy of creating virtual machine objects.
[0084] At the same time, the K8s cluster provisioning module receives the "K8sCluster" object from the physical K8s cluster api-server, and creates a virtual machine object based on the K8sCluster object. Further, in a feasible implementation, the virtual machine object includes a first virtual machine object for creating a control plane node of the Kubernete cluster and a second virtual machine object for creating a computing node of the Kubernetes cluster. Step S102 may include steps S1023 to S1024:
[0085] Step S1023, the K8s cluster provisioning module obtains the K8sCluster object from the physical K8s cluster, and parses the K8sCluster object to obtain the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and the resource configuration specifications corresponding to each node in the creation information;
[0086] Step S1024, the K8s cluster provisioning module creates the first virtual machine object based on the resource configuration specification and the number of Kubernetes control plane nodes, and creates the second virtual machine object based on the resource configuration specification and the number of Kubernetes computing nodes.
[0087] In this embodiment, the K8s cluster provisioning module obtains the K8sCluster object from the physical K8s cluster, parses the K8sCluster object, and obtains the Kubernetes control plane node number CP, the Kubernetes computing node number CM, and the resource configuration specifications corresponding to each node in the creation information.
[0088] Next, the K8s cluster provisioning module creates CP first virtual machine objects based on the resource configuration specifications of the Kubernetes control plane nodes, and creates CM second virtual machine objects based on the resource configuration specifications of the Kubernetes computing nodes, that is, it creates CP "VirtualMachine" objects (first virtual machine objects) to create the control plane nodes of the Kubernete cluster, and creates CM "VirtualMachine" objects (second virtual machine objects) to create the computing nodes of the Kubernetes cluster. The K8s cluster provisioning module can create virtual machine objects corresponding to the control plane nodes and computing nodes by parsing the K8sCluster object, thereby realizing automatic creation of virtual machine objects and improving the efficiency of creating virtual machine objects.
[0089] Further, in a feasible implementation manner, step S1024 may include steps a1 to a3:
[0090] Step a1: for a target control plane node in each Kubernetes control plane node, the K8s cluster provisioning module obtains the target ConfigMap object name of the ConfigMap object storing the startup code configuration data corresponding to the target control plane node;
[0091] Step a2, the K8s cluster provisioning module creates a target virtual machine object based on the resource configuration specification corresponding to the target control plane node;
[0092] Step a3, the K8s cluster provisioning module sets the target ConfigMap object name in the target virtual machine object, and obtains the first virtual machine object corresponding to the target control plane node.
[0093] In this embodiment, for the target control plane node in each Kubernetes control plane node, the K8s cluster provisioning module obtains the resource configuration specification corresponding to the target control plane node, and obtains the target ConfigMap object name of the ConfigMap object of the startup code configuration data corresponding to the target control plane node. Specifically, the ConfigMap object name corresponding to the target control plane node can be obtained in the preset agreed information.
[0094] After obtaining the ConfigMap object name, the K8s cluster provisioning module creates a target virtual machine object based on the resource configuration specifications corresponding to the target control plane node, sets the target ConfigMap object name in the target virtual machine object, obtains the first virtual machine object corresponding to the target control plane node, and then references the startup code configuration data of each node to the corresponding virtual machine object through the ConfigMap object name, further improving efficiency.
[0095] It should be noted that the creation process of the second virtual machine object is similar to that of the first virtual machine object, and will not be repeated here. After creating the first virtual machine object and the second virtual machine object, the K8s cluster provisioning module uploads the virtual machine object to the physical K8s cluster.
[0096] Step S103, the virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object, and adds startup code configuration data to the Pod container;
[0097] In this embodiment, after receiving one or more "VirtualMachine" objects (virtual machine objects), the virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object, and adds the startup code configuration data to the Pod container. In a feasible implementation manner, the data processing method further includes:
[0098] The K8s cluster provisioning module uploads the virtual machine object to the physical K8s cluster;
[0099] Step S103 may further include steps S1031 to S1032:
[0100] Step S1031, the virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object in the physical K8s cluster;
[0101] Step S1033: The virtual machine instance provisioning module uses the startup code configuration data as a file in the Pod container.
[0102] In this embodiment, after creating the virtual machine object, the K8s cluster provisioning module uploads the virtual machine object to the physical K8s cluster.
[0103] The virtual machine instance provisioning module is based on the virtual machine objects in the physical K8s cluster, that is, the virtual machine instance provisioning module receives one or more "VirtualMachine" objects from the physical K8s cluster api-server. The virtual machine configuration information in each virtual machine object is obtained, and a Pod object including a VMM program is created based on the virtual machine configuration information. Further, in a feasible implementation, step S1032 may include steps b1 to a2:
[0104] Step b1, the virtual machine instance provisioning module obtains virtual machine configuration information based on the virtual machine object in the physical K8s cluster;
[0105] Step b2: The virtual machine instance provisioning module creates a Kubernetes Pod object template, and fills the virtual machine configuration information into the Kubernetes Pod object template to obtain the Pod object.
[0106] In this embodiment, the virtual machine instance provisioning module obtains virtual machine configuration information based on the virtual machine objects in the physical K8s cluster. Specifically, the virtual machine instance provisioning module receives one or more virtual machine objects from the physical K8s cluster api-server. The virtual machine configuration information is obtained according to the virtual machine object, that is, the virtual machine configuration information is read from each virtual machine object. The virtual machine configuration information includes the container image address where the virtual machine operating system is located, the number of CPU cores of the virtual machine, the memory size of the virtual machine, and the startup code configuration data of the virtual machine.
[0107] After obtaining the virtual machine configuration information, the virtual machine instance provisioning module creates a Kubernetes Pod object template and fills the virtual machine configuration information into the Kubernetes Pod object template to obtain the Pod object. The Pod object includes the VMM program, and then the Pod object can be accurately created according to the virtual machine object. The VMM process is run using a container to manage the virtual machine instance without relying on other IaaS platform interfaces, which simplifies the technical difficulty of virtual machine management.
[0108] Step S104: the virtual machine instance provisioning module creates a virtual machine instance through the Pod container to enable the VMM process to run, and performs an initialization operation to enable the virtual machine instance to join the Kubernetes cluster.
[0109] In this embodiment, after the virtual machine instance provisioning module creates the Pod container, it creates a virtual machine instance through the Pod container to enable the VMM process to run, and performs an initialization operation to enable the virtual machine instance to join the Kubernetes cluster. Specifically, in a feasible implementation, step S104 may include steps S1041 to S104:
[0110] Step S1041, the virtual machine instance provisioning module obtains the startup code configuration data from the ConfigMap object through the Pod container as an ISO disk image file;
[0111] Step S1042, the virtual machine instance provisioning module creates a virtual machine instance through the cloud-hypervisor program in the Pod container, so that the VMM process runs, wherein the virtual machine operating system image file in the container image is used as the virtual machine disk, and the ISO disk image file is used as the external storage drive;
[0112] Step S1043, when the operating system of the virtual machine instance is started, the CloudInit initialization operation is performed to allow the virtual machine instance to join the Kubernetes cluster.
[0113] In this embodiment, after the virtual machine instance provisioning module creates a Pod container, the virtual machine instance provisioning module obtains the startup code configuration data from the ConfigMap object through the Pod container as an ISO disk image file. Specifically, the startup script in the virtual machine instance Pod container calls the CloudInit tool command "cloud-localds" to mount the startup code configuration data from the ConfigMap into the Pod container as an ISO disk image file that can be mounted by the virtual machine.
[0114] Next, the virtual machine instance provisioning module creates a virtual machine instance through the cloud-hypervisor program in the Pod container. Specifically, the startup script in the virtual machine instance Pod container calls the cloud-hypervisor to create a virtual machine instance, and the VMM process starts running to run the virtual machine, wherein the virtual machine operating system image file in the container image serves as the virtual machine disk, and the ISO disk image file serves as the external storage drive.
[0115] When the operating system of the virtual machine instance starts, that is, when the operating system of the virtual machine instance is detected to be started after the virtual machine is running, the CloudInit initialization operation is performed. Specifically, the startup script configuration in CloudInit is automatically run, including running the kubeadm initialization command, so that the virtual machine instance joins the Kubernetes cluster and completes the virtual machine instance joining the Kubernetes cluster.
[0116] The data processing method proposed in this embodiment receives a K8sCluster object through the physical K8s cluster, wherein the K8sCluster object includes creation information corresponding to a cluster creation request; then the K8s cluster provisioning module creates a virtual machine object based on the K8sCluster object, and the K8s node configuration generation module generates startup code configuration data based on the K8sCluster object; then the virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object, and adds the startup code configuration data to the Pod container; then the virtual machine instance provisioning module creates a virtual machine instance through the Pod container to enable the VMM process to run, and performs an initialization operation to enable the virtual machine instance to join the Kubernets cluster, creates a virtual machine object through the K8s cluster provisioning module, the K8s node configuration generation module generates startup code configuration data, and the virtual machine instance provisioning module creates a Pod object to create a virtual machine instance through the Pod container, thereby realizing automatic creation of the KaaS service of the Kubernets cluster, using a general Kubernets cluster and a physical server as the underlying infrastructure to provide KaaS services, and sharing underlying resources with other software to reduce the impact on resource planning of the physical host.
[0117] At the same time, container technology is used to run the VMM process to start virtual machine instances, and Kubernetes technology is used to schedule VMM containers to achieve low-cost and lightweight virtualization management.
[0118] Furthermore, in a feasible implementation manner, before step S101, the data processing method may further include steps S201 to S202:
[0119] Step S201, the KaaS service encapsulation module receives the creation information corresponding to the K8s cluster creation request, wherein the creation information includes the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and the resource configuration specifications corresponding to each node;
[0120] Step S202, the KaaS service encapsulation module converts the creation information into the K8sCluster object, and uploads the K8sCluster object to the physical K8s cluster.
[0121] In this embodiment, when the KaaS service receives a K8s cluster creation request from a user or an upper-level system, it sends the K8s cluster creation request to the KaaS service encapsulation module. The KaaS service encapsulation module parses the K8s cluster creation request and obtains the creation information corresponding to the K8s cluster creation request. The creation information includes the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and the resource configuration specifications corresponding to each node, wherein the resource configuration specifications include basic configurations such as CPU, memory, and disk capacity.
[0122] After obtaining the creation information, the KaaS service encapsulation module converts the creation information into a K8sCluster object and uploads the K8sCluster object to the physical K8s cluster, so that the K8s cluster provisioning module and the K8s node configuration generation module can obtain the creation information corresponding to the K8s cluster creation request by calling the K8sCluster object in the physical K8s cluster, thereby improving the convenience of K8s cluster creation.
[0123] The data processing method proposed in this embodiment receives the creation information corresponding to the K8s cluster creation request through the KaaS service encapsulation module, wherein the creation information includes the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and the resource configuration specifications corresponding to each node; then the KaaS service encapsulation module converts the creation information into the K8sCluster object, and uploads the K8sCluster object to the physical K8s cluster, so that the K8s cluster provisioning module and the K8s node configuration generation module obtain the creation information corresponding to the K8s cluster creation request by calling the K8sCluster object in the physical K8s cluster, thereby improving the convenience of K8s cluster creation.
[0124] The data processing device provided in the embodiment of the present application adopts the data processing method in the above embodiment, which can solve the technical problem of how to reduce the impact on the resource planning of the physical host when providing KaaS services when the internal resources of the enterprise are limited. Compared with the prior art, the beneficial effects of the data processing device provided in the embodiment of the present application are the same as the beneficial effects of the data processing method provided in the above embodiment, and the other technical features in the data processing device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0125] The present application provides a K8s service system, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data processing method in the above-mentioned embodiment one.
[0126] Reference below Figure 4 , which shows a schematic diagram of the structure of a K8s service system suitable for implementing an embodiment of the present application. The K8s service system in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The K8s service system shown is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of the present application.
[0127] like Figure 4 As shown, the K8s service system may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. Various programs and data required for the operation of the K8s service system are also stored in RAM1004. The processing device 1001, ROM1002, and RAM1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the K8s service system to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a K8s service system with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.
[0128] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0129] The K8s service system provided by this application adopts the data processing method in the above embodiment, which can solve the technical problem of how to reduce the impact on resource planning of physical hosts when providing KaaS services when the internal resources of the enterprise are limited. Compared with the prior art, the beneficial effects of the K8s service system provided by this application are the same as the beneficial effects of the data processing method provided by the above embodiment, and other technical features of the K8s service system are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0130] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0131] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0132] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the data processing method in the above-mentioned embodiment.
[0133] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0134] The above-mentioned computer-readable storage medium may be included in the K8s service system; or it may exist independently without being assembled into the K8s service system.
[0135] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the K8s service system, in the K8s service system: the physical K8s cluster receives the K8sCluster object, wherein the K8sCluster object includes creation information corresponding to the cluster creation request; the K8s cluster provisioning module creates a virtual machine object based on the K8sCluster object, and the K8s node configuration generation module generates startup code configuration data based on the K8sCluster object; the virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object, and adds the startup code configuration data to the Pod container; the virtual machine instance provisioning module creates a virtual machine instance through the Pod container to enable the VMM process to run, and performs initialization operations to enable the virtual machine instance to join the Kubernets cluster.
[0136] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0137] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0138] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0139] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned data processing method, and can solve the technical problem of how to reduce the impact on resource planning of physical hosts when providing KaaS services when the internal resources of an enterprise are limited. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the data processing method provided in the above-mentioned embodiment, and will not be repeated here.
[0140] An embodiment of the present application provides a computer program product, including a computer program, which implements the steps of the above-mentioned data processing method when executed by a processor.
[0141] The computer program product provided in this application can solve the technical problem of how to reduce the impact on resource planning of physical hosts when providing KaaS services when the internal resources of an enterprise are limited. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiment of this application are the same as the beneficial effects of the data processing method provided in the above embodiment, which will not be repeated here.
[0142] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A data processing method, characterized in that: Applied to the K8s service system, the K8s service system includes a physical K8s cluster, a K8s cluster provisioning module, a K8s node configuration generation module, and a virtual machine instance provisioning module, including: The physical K8s cluster receives a K8sCluster object, wherein the K8sCluster object includes creation information corresponding to the cluster creation request; The K8s cluster provisioning module creates a virtual machine object based on the K8sCluster object, and the K8s node configuration generation module generates startup code configuration data based on the K8sCluster object; The virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object, and adds startup code configuration data to the Pod container; The virtual machine instance provisioning module creates a virtual machine instance through the Pod container to enable the VMM process to run, and performs an initialization operation to enable the virtual machine instance to join the Kubernetes cluster.
2. The data processing method according to claim 1, characterized in that: The virtual machine object includes a first virtual machine object for creating a control plane node of a Kubernete cluster and a second virtual machine object for creating a computing node of a Kubernetes cluster, and the step of the K8s cluster provisioning module creating a virtual machine object based on the K8sCluster object includes: The K8s cluster provisioning module obtains the K8sCluster object from the physical K8s cluster, and parses the K8sCluster object to obtain the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and the resource configuration specifications corresponding to each node in the creation information; The K8s cluster provisioning module creates the first virtual machine object based on the resource configuration specification and the number of Kubernetes control plane nodes, and creates the second virtual machine object based on the resource configuration specification and the number of Kubernetes computing nodes.
3. The data processing method according to claim 2, characterized in that: The step of the K8s node configuration generation module generating startup code configuration data based on the K8sCluster object includes: The K8s cluster provisioning module obtains a K8sCluster object from the physical K8s cluster, and parses the K8sCluster object to obtain the number of Kubernetes control plane nodes and the number of Kubernetes computing nodes in the creation information; The K8s cluster provisioning module generates startup code configuration data corresponding to each node based on the number of Kubernetes control plane nodes and the number of Kubernetes computing nodes, and saves the startup code configuration data to the corresponding ConfigMap object.
4. The data processing method according to claim 3, characterized in that: The step of the K8s cluster provisioning module creating the first virtual machine object based on the resource configuration specification and the number of Kubernetes control plane nodes includes: For a target control plane node in each Kubernetes control plane node, the K8s cluster provisioning module obtains a target ConfigMap object name of a ConfigMap object storing startup code configuration data corresponding to the target control plane node; The K8s cluster provisioning module creates a target virtual machine object based on the resource configuration specification corresponding to the target control plane node; The K8s cluster provisioning module sets the target ConfigMap object name in the target virtual machine object and obtains the first virtual machine object corresponding to the target control plane node.
5. The data processing method according to claim 3, characterized in that: The steps of the virtual machine instance provisioning module creating a virtual machine instance through the Pod container to enable the VMM process to run, and performing an initialization operation to enable the virtual machine instance to join the Kubernetes cluster include: The virtual machine instance provisioning module obtains the startup code configuration data from the ConfigMap object through the Pod container as an ISO disk image file; The virtual machine instance provisioning module creates a virtual machine instance through the cloud-hypervisor program in the Pod container, so that the VMM process runs, wherein the virtual machine operating system image file in the container image is used as the virtual machine disk, and the ISO disk image file is used as the external storage drive; When the operating system of the virtual machine instance starts, the CloudInit initialization operation is executed to enable the virtual machine instance to join the Kubernetes cluster.
6. The data processing method according to claim 1, characterized in that: After the step of the K8s cluster provisioning module creating a virtual machine object based on the K8sCluster object, the step further includes: The K8s cluster provisioning module uploads the virtual machine object to the physical K8s cluster; The steps of the virtual machine instance provisioning module creating a Pod object including a VMM program based on the virtual machine object and adding startup code configuration data to the Pod container include: The virtual machine instance provisioning module creates a Pod object including a VMM program based on the virtual machine object in the physical K8s cluster; The virtual machine instance provisioning module uses the startup code configuration data as a file in the Pod container.
7. The data processing method according to claim 6, characterized in that: The steps of the virtual machine instance provisioning module creating a Pod object including a VMM program based on the virtual machine object in the physical K8s cluster include: The virtual machine instance provisioning module obtains virtual machine configuration information based on the virtual machine object in the physical K8s cluster; The virtual machine instance provisioning module creates a Kubernetes Pod object template, and fills the virtual machine configuration information into the Kubernetes Pod object template to obtain the Pod object.
8. The data processing method according to any one of claims 1 to 7, characterized in that: The K8s service system further includes a KaaS service encapsulation module. Before the step of the physical K8s cluster receiving the K8sCluster object, the system further includes: The KaaS service encapsulation module receives creation information corresponding to the K8s cluster creation request, wherein the creation information includes the number of Kubernetes control plane nodes, the number of Kubernetes computing nodes, and resource configuration specifications corresponding to each node; The KaaS service encapsulation module converts the creation information into the K8sCluster object and uploads the K8sCluster object to the physical K8s cluster.
9. A K8s service system, characterized in that: The K8s service system includes: a memory, a processor, and a data processing program stored in the memory and executable on the processor. When the data processing program is executed by the processor, the steps of the data processing method as described in any one of claims 1 to 8 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a data processing program, and when the data processing program is executed by a processor, the steps of the data processing method according to any one of claims 1 to 8 are implemented.