Method, device, terminal and medium for pipeline cross-cluster deployment of application
By using a pipelined cross-cluster application deployment method, generating declarative YAML files and creating resource controllers, the difficulties of manually configuring files in Kubernetes clusters are solved, achieving efficient and simplified application deployment and image management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ENVISION DIGITAL INT PTE LTD
- Filing Date
- 2022-05-25
- Publication Date
- 2026-04-10
AI Technical Summary
When deploying applications in a Kubernetes cluster, developers need to have Kubernetes knowledge and manually write configuration files, which leads to deployment difficulties and high costs for bug fixing.
This paper provides a method for pipelined cross-cluster application deployment. It obtains the target resource template, configures application parameters to generate a declarative style YAML file, interacts with the Kubernetes cluster, creates deployment resources, updates the replica count and image tags, and uses the resource controller to pull the image to start the target instance pod. The image is stored in the private repository Harbor.
It reduces the difficulty for development and operations personnel to deploy applications across clusters through pipelines, simplifies the configuration process, reduces image redundancy, and improves deployment efficiency and the convenience of image management.
Smart Images

Figure CN114896027B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of computer, and particularly relate to a method and device for cross-cluster deployment of pipeline application, a terminal and a medium. BACKGROUND
[0002] K8s (Kubernetes) is an open-source container cluster management system that can manage containerized applications on multiple hosts in a cloud platform.
[0003] In the related art, the clusters that need to be deployed in K8s require developers to have K8s knowledge and experience, and manually write corresponding configuration files. In the case of not being familiar with K8s knowledge, the cost of deployment, troubleshooting and error correction is high. SUMMARY
[0004] Embodiments of the present application provide a method and device for cross-cluster deployment of pipeline application, a terminal and a medium. The technical solution is as follows:
[0005] According to an aspect of the present application, a method for cross-cluster deployment of pipeline application is provided, which comprises:
[0006] obtaining a target resource template, the target resource template including personalized parameters and default general parameters;
[0007] configuring application parameters according to the resource template to generate a declaration style YAML file;
[0008] interacting with a Kubernetes cluster based on the declaration style YAML file to create a deployment resource;
[0009] updating the number of replicas and the image tag of the deployment resource in response to deploying a first task;
[0010] creating a resource controller based on the deployment resource in the Kubernetes cluster;
[0011] The resource controller pulls an image and starts a target instance pod of a target number of replicas to complete the deployment of the application, the image being built after running the pipeline and stored in a private repository harbor.
[0012] According to another aspect of the present application, a device for cross-cluster deployment of pipeline application is provided, which comprises:
[0013] a first obtaining module configured to obtain a target resource template, the target resource template including personalized parameters and default general parameters;
[0014] The generating module is configured to generate a declaration style YAML file according to the application parameter configured based on the resource template;
[0015] The first creating module is configured to interact with a Kubernetes cluster based on the declaration style YAML file to create a deployment resource;
[0016] The updating module is configured to update the number of replicas and the image tag of the deployment resource in response to deploying a first task;
[0017] The second creating module is configured to create a resource controller based on the deployment resource in the Kubernetes cluster;
[0018] The deployment module is configured to pull an image and start a target instance pod of a target number of replicas by the resource controller to complete deployment of the application, the image being built after running a pipeline and stored in a private repository harbor.
[0019] According to another aspect of the present application, a terminal is provided, which comprises a processor and a memory, the memory storing at least one instruction, the instruction being loaded and executed by the processor to implement the method for deploying an application across clusters by a pipeline as provided in various aspects of the present application.
[0020] According to another aspect of the present application, a computer readable storage medium is provided, the storage medium storing at least one instruction, the instruction being loaded and executed by a processor to implement the method for deploying an application across clusters by a pipeline as provided in various aspects of the present application.
[0021] The technical scheme provided by the embodiments of the present application can bring the following beneficial effects:
[0022] The present application provides a target resource template, and then configures an application parameter, generates a declaration style YAML file and creates a deployment resource. When a first task is deployed, the number of replicas and the image tag of the deployment resource are updated. Based on the deployment resource in the Kubernetes cluster, a resource controller is created. The resource controller pulls an image and starts a target instance pod of a target number of replicas to complete deployment of the application. The image is built after running a pipeline and stored in a private repository harbor. The present application templates the declaration style YAML file, so that general configuration is automatically filled in, and the difficulty of deploying an application across clusters by a pipeline for a development and operation personnel is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly introduce the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments of the present application will be briefly introduced. Obviously, the drawings in the following description only represent some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of these drawings.
[0024] Figure 1 is a structural block diagram of a terminal provided by an exemplary embodiment of the present application;
[0025] Figure 2 is a flow chart of a method for pipeline cross-cluster deployment of an application provided by an exemplary embodiment of the present application;
[0026] Figure 3 is a flow chart of a method for pipeline cross-cluster deployment of an application provided by another exemplary embodiment of the present application;
[0027] Figure 4 is a schematic diagram of a method for pipeline cross-cluster deployment of an application provided by an embodiment of the present application;
[0028] Figure 5 is a schematic diagram of another method for pipeline cross-cluster deployment of an application provided by an embodiment of the present application;
[0029] Figure 6 is a schematic diagram of another method for pipeline cross-cluster deployment of an application provided by an embodiment of the present application;
[0030] Figure 7 is a structural block diagram of an apparatus for pipeline cross-cluster deployment of an application provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail in combination with the drawings.
[0032] The following description refers to the accompanying drawings. Unless otherwise indicated, like numbers in the different figures represent the same or similar elements. The following exemplary embodiments are described in the context of the embodiments described, but they are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples consistent with some aspects of the present application as detailed in the appended claims.
[0033] In the description of the present application, it is necessary to understand that the terms "first", "second" and the like are only for the purpose of description, and cannot be understood as indicating or implying relative importance. In the description of the present application, it is necessary to explain that, unless otherwise specified and limited, the terms "connected", "connected" should be understood in a broad sense, for example, it can be fixedly connected, or it can be detachably connected, or integrally connected; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances. In addition, in the description of the present application, "a plurality of" means two or more, unless otherwise specified. "And / or", the association between the associated objects, means that there can be three kinds of relationships, for example, A and / or B, which can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. The character " / " generally represents that the associated objects before and after are a kind of "or" relationship.
[0034] As used herein, the term "if' is optionally interpreted as "when," "while," "in response to a determination," or "in response to a detection," depending on the context. Similarly, depending on the context, the phrase "if it is determined that" or "if it is detected that (a stated condition or event) occurs" or "in response to detecting (a stated condition or event)."
[0035] It should be noted that the use of personally identifiable information should follow the privacy policies and practices that are recognized as meeting or exceeding industry or government requirements for maintaining user privacy. Specifically, personally identifiable information should be explicitly stated to the user during management and processing to authorize the nature of use, so as to minimize the risk of unintentional or unauthorized access or use.
[0036] In the art, Kubernetes (K8s for short) is an open source container cluster management system developed by Google, which provides application deployment, maintenance, expansion mechanism and other functions, and can conveniently manage cross-machine running containerized applications by using Kubernetes.
[0037] Pipeline refers to a set of technical solutions based on continuous integration and continuous deployment. R&D personnel can improve R&D efficiency through pipeline.
[0038] Harbor is an enterprise-level Registry server for storing and distributing Docker images, which extends open source Docker Distribution by adding some enterprise-required features such as security, identification and management. Different Kubernetes clusters may be configured with different private harbor repositories.
[0039] Different clusters can be configured with different private harbor repositories, and different harbor repositories can synchronize images through configuration synchronization rules. Cross-cluster deployment can reduce image redundancy caused by the need to meet synchronization rules and improve the storage capacity of harbor repositories. Moreover, cross-cluster deployment can greatly simplify the operation cost of development and operation personnel, saving time and human resources.
[0040] Among them, cross-cluster deployment can reduce image redundancy caused by the need to meet synchronization rules. This can be understood through the following description. Among them, harbor can configure synchronization rules, and images meeting these rules will trigger synchronization. For a pre-production environment, the synchronization rule generally starts with tag, representing that the image has passed the test and entered the pre-production. However, this pre-production environment will be used for testing for some reason, and if the tested image also starts with tag, it will cause confusion in image management, because the tested image and the pre-production image are in the same format.
[0041] Exemplarily, the method for pipeline cross-cluster deployment application shown in the embodiments of the present application can be applied in a terminal. The terminal has a display screen and has the function of pipeline cross-cluster deployment application. The terminal can include a mobile phone, a tablet computer, a laptop computer, a desktop computer, an all-in-one computer, a server, a workstation, a television, a set-top box, smart glasses, a smart watch, a digital camera, an MP4 player terminal, an MP5 player terminal, a learning machine, a point-reading machine, an electronic paper, an electronic dictionary, a vehicle-mounted terminal, a virtual reality (VR) player terminal, or an augmented reality (AR) player terminal, etc.
[0042] Figure 1 is a structural block diagram of a terminal provided by an exemplary embodiment of the present application, as shown in Figure 1 The terminal includes a processor 120 and a memory 140, and the memory 140 stores at least one instruction, which is loaded and executed by the processor 120 to implement the method for pipeline cross-cluster deployment application as described in various method embodiments of the present application.
[0043] In the present application, the terminal 100 is an electronic device with the function of pipeline cross-cluster deployment application. When the terminal 100 obtains a target resource template, the target resource template includes personalized parameters and default general parameters; application parameters are configured according to the resource template to generate a declaration style YAML file; the declaration style YAML file is interacted with a Kubernetes cluster to create a deployment resource; in response to deploying a first task, the number of replicas and the image tag of the deployment resource are updated; based on the deployment resource in the Kubernetes cluster, a resource controller is created; the resource controller is used to pull an image and start a target instance pod with a target number of replicas, the image is built after running the pipeline and stored in a private repository harbor, to complete the deployment of the application.
[0044] The processor 120 can include one or more processing cores. The processor 120 connects various parts within the entire terminal 100 through various interfaces and lines, executes various functions of the terminal 100 and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 140, and calling data stored in the memory 140. Alternatively, the processor 120 can be implemented in at least one of a hardware form of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 120 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes operating systems, user interfaces, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 120, but can be realized by a separate chip.
[0045] The memory 140 can include a random access memory (RAM) and a read-only memory (ROM). Optionally, the memory 140 includes a non-transitory computer-readable storage medium. The memory 140 can be configured to store instructions, programs, codes, code sets, or instruction sets. The memory 140 can include a program storage area and a data storage area, where the program storage area can store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing each of the following method embodiments, etc., and the data storage area can store data related to each of the following method embodiments, etc.
[0046] Please refer to Figure 2 , Figure 2 is a flowchart of a method for pipeline cross-cluster deployment of an application provided by an example embodiment of the present application. The method for pipeline cross-cluster deployment of an application can be applied in the terminal shown in the above. Figure 2 In the method for pipeline cross-cluster deployment of an application, the following steps are included.
[0047] In step 210, a target resource template is obtained, and the target resource template includes personalized parameters and default general parameters.
[0048] In the embodiment of the present application, the terminal needs to obtain a target resource template when performing pipeline cross-cluster deployment of an application. The target resource template can be in a templated form of a YAML file. The target resource template can include personalized parameters and general parameters. The general parameters can be pre-filled according to general numerical values.
[0049] In step 220, application parameters are configured according to the resource template, and a declaration style YAML file is generated.
[0050] In the embodiment of the present application, the terminal can extract personalized parameters and general parameters from the target resource template by using a rendering tool, and automatically fill the personalized parameters and general parameters into a YAML file. That is, application parameters are configured according to the personalized parameters and general parameters, and a declaration style YAML file is generated.
[0051] In step 230, the declaration style YAML file is interacted with a Kubernetes cluster to create a deployment resource.
[0052] In the embodiment of the present application, after the terminal generates a declaration style YAML file, the terminal can interact with a Kubernetes cluster based on the YAML file, so as to create a deployment (Deployment) resource.
[0053] In step 240, the number of replicas and the image tag of the deployment resource are updated in response to deploying the first task.
[0054] In the embodiment of the present application, the terminal can deploy the first task. When the terminal deploys the first task, the number of replicas and the image tag of the deployment resource can be updated.
[0055] In step 250, a resource controller is created based on the deployment resource in the Kubernetes cluster.
[0056] In the embodiment of the present application, the terminal can also create a resource controller based on the deployment resource in the Kubernetes cluster.
[0057] In step 260, the target instance pod of the target number of replicas is started by the resource controller to complete the deployment of the application, and the image is built after running the pipeline and stored in the private repository harbor.
[0058] In the embodiment of the present application, the terminal will pull the image through the resource controller (RS). And the terminal will start the target instance pod of the target number of replicas. For example, the target number of replicas is 5, then the terminal will start 5 target instance pods. Through this process, the terminal can complete the deployment of the application. Wherein, the image is built after the terminal runs the pipeline, and the image is built after the terminal runs the pipeline and stored in the private repository harbor.
[0059] In summary, the method for pipeline cross-cluster deployment of application provided by the embodiment updates the number of replicas and the image tag of the deployment resource when deploying the first task, creates a resource controller based on the deployment resource in the Kubernetes cluster, and pulls the image through the resource controller and starts the target instance pod of the target number of replicas to complete the deployment of the application. The image is built after running the pipeline and stored in the private repository harbor. Because the template declaration style YAML file is provided in the present application, the general configuration is automatically filled, which reduces the difficulty of the development and operation personnel to deploy the application across the cluster through the pipeline.
[0060] Based on the scheme disclosed in the previous embodiment, the terminal can also achieve the purpose of pipeline cross-cluster deployment of application through further schemes, please refer to the following embodiments.
[0061] Please refer to Figure 3 , Figure 3is a flowchart of a method for pipeline cross-cluster deployment of an application provided by another exemplary embodiment of the present application. The method for pipeline cross-cluster deployment of an application can be applied in the terminal shown in the above. Figure 3 In the method for pipeline cross-cluster deployment of an application, the method comprises the following steps.
[0062] In step 301, a target resource template is obtained, and the target resource template comprises individualized parameters and default general parameters.
[0063] In the embodiment of the present application, the execution process of step 301 can refer to the execution process of step 210, which will not be repeated here.
[0064] In step 302, application parameters are configured according to the resource template, and a declaration style YAML file is generated.
[0065] In the embodiment of the present application, the execution process of step 302 can refer to the execution process of step 220, which will not be repeated here.
[0066] In step 303, the declaration style YAML file is interacted with a Kubernetes cluster to create a deployment resource.
[0067] In the embodiment of the present application, the execution process of step 303 can refer to the execution process of step 230, which will not be repeated here.
[0068] In step 304, in response to the deployment of the first task, the number of replicas and the image tag of the deployment resource are updated.
[0069] In the embodiment of the present application, the execution process of step 304 can refer to the execution process of step 240, which will not be repeated here.
[0070] In step 305, a resource controller is created based on the deployment resource in the Kubernetes cluster.
[0071] In the embodiment of the present application, the execution process of step 305 can refer to the execution process of step 250, which will not be repeated here.
[0072] In step 306, the resource controller is used to pull an image and start a target instance pod with a target number of replicas, so as to complete the deployment of the application, and the image is built after the pipeline is run and stored in a private repository harbor.
[0073] In the embodiment of the present application, the execution process of step 306 can refer to the execution process of step 260, which will not be repeated here.
[0074] In step 307, a second task is built, and the second task is used to compile target code in a code hosting platform to generate an image and push the image to the private repository harbor.
[0075] In the embodiment of the present application, the terminal can construct a second task, which is used to compile the target code in the code hosting platform and generate an image based on the compiled target code. When the terminal generates the image, the image can be pushed to the private repository harbor.
[0076] Optionally, the code hosting platform can be Gitlab.
[0077] Step 308, executing the second task.
[0078] In the embodiment of the present application, the terminal can execute the second task to realize the function of the second task.
[0079] Step 309, scanning the target code and selecting branch code with a code quality higher than a quality threshold.
[0080] Step 310, deploying the first task based on the branch code.
[0081] Step 311, in response to deploying the first task, triggering an image synchronization process, which includes synchronizing the image of the private repository harbor to the Kubernetes cluster.
[0082] Step 312, creating a synchronization policy task.
[0083] Step 313, adding the synchronization policy task to the remote dictionary service Redis queue.
[0084] Step 314, executing a timing task, which is used to obtain the queue of the synchronization policy task from the remote dictionary service Redis queue.
[0085] In a possible implementation manner of the present application, the timing task is also used to obtain the verification result from the remote dictionary service Redis queue.
[0086] In an implementation manner, if the verification result indicates that the synchronization policy task is executed successfully, the synchronization policy task is deleted.
[0087] In another implementation manner, if the verification result indicates that the synchronization policy task fails, the synchronization policy task is retransmitted.
[0088] Step 315, verifying the number of tasks being synchronized, and executing the image synchronization process or stopping the execution of the image synchronization process based on the verification result.
[0089] In summary, in the method for deploying an application across clusters by a pipeline shown in the application, by providing a target resource template, then configuring application parameters, generating a declaration style YAML file and creating a deployment resource, when deploying a first task, updating the number of replicas and image tags of the deployment resource, creating a resource controller based on the deployment resource in the Kubernetes cluster, pulling the image through the resource controller and starting the target instance pod of the target number of replicas to complete the deployment of the application. The image is built after running the pipeline and stored in the private repository harbor. Since the declaration style YAML file is templated in the application, the general configuration is automatically filled in, reducing the difficulty of deploying an application across clusters by a pipeline for development and operation personnel.
[0090] The method for deploying an application across clusters by a pipeline provided in the embodiment can also template the Yaml file of the Deployment resource and automatically fill in the general configuration. The development and operation personnel only need to care about their own personalized configuration, and then extract the configuration parameters of the template to fill in the Yaml file, and interact with the Kubernetes cluster for application deployment, greatly reducing the learning cost of the development and operation personnel.
[0091] The method for deploying an application across clusters by a pipeline provided in the embodiment can also achieve continuous integration and deployment for different clusters without additional operations, which can be completed in the pipeline, and can view various states of the deployment stage in real time at low cost, and can accurately find the cause of the problem when an exception occurs.
[0092] The method for deploying an application across clusters by a pipeline provided in the embodiment can also not need to configure additional image synchronization rules in the main harbor, and does not need to wait for the automatic triggering of the synchronization rule. The pipeline asynchronously triggers the synchronization of the image, monitors the synchronization state, and immediately tries to synchronize again for the image that fails to synchronize.
[0093] Please refer to Figure 4 , Figure 4 is a schematic diagram of a method for deploying an application across clusters by a pipeline provided in the embodiment. In Figure 4 , it includes a deployment operator 410, a target resource template 420, a declaration style YAML file 430, a first Kubernetes cluster 441, a second Kubernetes cluster 442, a pipeline 450, and a private repository harbor 460.
[0094] In Figure 4In the middle, the deployment operator 410 configures the application parameters through the target resource template 420 before running the pipeline 450, converts the Yaml file corresponding to the value of the image field into null, and the number of copies is 0, and interacts with the Kubernetes cluster to create the Deployment resource. After the deployment operator 410 executes the pipeline 450, the built docker image is pushed to the harbor warehouse, and then the deployment task is started. The deployment task updates the number of copies and the image tag of the Deployment resource. The RS created by the Deployment resource in the cluster can pull the image and start the pod with the specified number of copies, and finally complete the deployment of the application.
[0095] Referring to Figure 5 , Figure 5 is a schematic diagram of another method for cross-cluster deployment of an application provided by an embodiment of the present application. For the embodiment shown in Figure 5 , the build task compiles and packages the code in the code hosting platform (Gitlab) to generate a docker image and pushes it to the master harbor. The code scanning and the selected branch meet the quality requirements, and the deployment task is started. The deployment task first triggers image synchronization, and the image in the master harbor is synchronized to the harbor warehouse in the target cluster. The asynchronous deployment task in the target cluster detects the target image and starts to execute the deployment. The deployment task of the pipeline will always poll the deployment status, and after the asynchronous deployment is completed, the deployment task of the pipeline is called back. The polling and callback (Polling deploy status and waiting for callback) jointly update the task status.
[0096] Referring to Figure 6 , Figure 6 is a schematic diagram of another method for cross-cluster deployment of an application provided by an embodiment of the present application. For the embodiment shown in Figure 6 , the deployment task triggers the creation of a synchronization policy and joins the redis queue before executing the asynchronous deployment. The timing task obtains the queue of the synchronization policy task from the redis queue, checks the number of tasks being synchronized to determine whether to synchronize, and adds the synchronized task to the redis queue to be cleared. The timing task obtains the task from the redis queue to be cleared, checks whether the task is completed, retransmits the failed task, and deletes the completed task.
[0097] Based on Figure 5 and Figure 6The embodiments provided in the present application can reduce the learning cost of users in deploying applications in Kubernetes by providing the user with a template of a Deployment resource. The image synchronization is triggered through the pipeline, and the synchronization state is monitored, thereby saving the waiting time for triggering image synchronization at a fixed time, and the image synchronization state is checkable and controllable, and the user does not need to log in to the harbor warehouse to check the synchronization state, thereby improving the security. At the same time, the redundant images in the main harbor warehouse are reduced, and the convenience of image management is improved. The deployment of a single cluster and cross-cluster is centralized to the pipeline, thereby avoiding the fragmentation of continuous integration and deployment, reducing the operation steps of the development and operation personnel, making the deployment of the application safe and reliable, and greatly improving the research and development and delivery efficiency of the application software. The deployment task is sunk to the cluster in an asynchronous manner, thereby reducing the network instability and other risks caused by communication between different regions.
[0098] The following is an apparatus embodiment of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the apparatus embodiments of the present application, please refer to the method embodiments of the present application.
[0099] Please refer to Figure 7 , Figure 7 is a structural block diagram of an apparatus for deploying an application across clusters by a pipeline according to an example embodiment of the present application. The apparatus for deploying an application across clusters by a pipeline can be realized by software, hardware or a combination of both to become all or part of a terminal. The apparatus comprises:
[0100] The first obtaining module 710 is configured to obtain a target resource template, wherein the target resource template comprises individualized parameters and default general parameters;
[0101] The generating module 720 is configured to configure application parameters according to the resource template, and generate a declaration style YAML file;
[0102] The first creating module 730 is configured to interact with a Kubernetes cluster based on the declaration style YAML file to create a deployment resource;
[0103] The updating module 740 is configured to update the number of replicas and the image tag of the deployment resource in response to a deployment first task;
[0104] The second creating module 750 is configured to create a resource controller based on the deployment resource in the Kubernetes cluster;
[0105] The deployment module 760 is configured to pull an image and start a target number of target instance pods through the resource controller to complete the deployment of the application, wherein the image is built after running the pipeline and stored in a private warehouse harbor.
[0106] In an optional embodiment, the apparatus further comprises a first execution module configured to construct a second task, the second task being configured to compile the target code in the code hosting platform to generate the image and push the image to the private repository harbor; and execute the second task.
[0107] In an optional embodiment, the apparatus further comprises a second execution module configured to scan the target code, select branch code with a code quality higher than a quality threshold; and deploy the first task based on the branch code.
[0108] In an optional embodiment, the apparatus further comprises a synchronization module configured to trigger an image synchronization process in response to the deployment of the first task, the image synchronization process comprising synchronizing images in the private repository harbor to the Kubernetes cluster.
[0109] In an optional embodiment, the apparatus further comprises a third execution module configured to create a synchronization policy task; add the synchronization policy task to a remote dictionary service Redis queue; execute a timing task configured to obtain a queue of the synchronization policy task from the remote dictionary service Redis queue; and check a number of tasks being synchronized, and execute the image synchronization process or stop executing the image synchronization process based on a check result.
[0110] In an optional embodiment, the timing task in the apparatus is further configured to obtain the check result from the remote dictionary service Redis queue; delete the synchronization policy task if the check result indicates that the synchronization policy task is executed successfully; and cause the synchronization policy task to be retransmitted if the check result indicates that the synchronization policy task is executed unsuccessfully.
[0111] In summary, in the apparatus for cross-cluster deployment of an application by a pipeline shown in the present application, a target resource template is provided, and then application parameters are configured, a declaration style YAML file is generated and a deployment resource is created. When the first task is deployed, the number of copies and the image tag of the deployment resource are updated. Based on the deployment resource in the Kubernetes cluster, a resource controller is created, the image is pulled through the resource controller, and the target instance pod with the target number of copies is started to complete the deployment of the application. The image is built after the pipeline is run and is stored in the private repository harbor. Since the declaration style YAML file is templated in the present application, general configuration is automatically filled in, which reduces the difficulty of the development and operation personnel in deploying the application across clusters by the pipeline.
[0112] The embodiment of the present application further provides a computer readable medium, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method for deploying an application in a pipeline across clusters according to various embodiments.
[0113] The embodiment of the present application further provides a computer program, which comprises computer instructions, and the computer instructions are executed by the processor of the terminal, so that the terminal executes the method for deploying an application in a pipeline across clusters provided by the present application.
[0114] It should be noted that the apparatus for deploying an application in a pipeline across clusters provided in the above embodiments is only used for executing the method for deploying an application in a pipeline across clusters, and the above-mentioned functions are divided into different functional modules for example, and in actual application, the above-mentioned functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus for deploying an application in a pipeline across clusters and the method for deploying an application in a pipeline across clusters provided in the above embodiments belong to the same concept, and the specific implementation process is described in the method embodiments, which will not be repeated here.
[0115] The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0116] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program to instruct related hardware to complete, and the program can be stored in a computer readable storage medium, and the above-mentioned storage medium can be read-only memory, magnetic disk or optical disk, etc.
[0117] The above-mentioned is only an exemplary embodiment which can be implemented by the present application, and does not limit the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims
1. A method for pipelined cross-cluster application deployment, characterized in that, The method includes: Obtain the target resource template, which includes personalized parameters and default general parameters; Based on the resource template configuration application parameters, a declaration style YAML file is generated, wherein the default general parameters do not need to be manually configured and are automatically populated into the declaration style YAML file; Based on the declared style YAML file, interact with at least two Kubernetes clusters to create cross-cluster deployment resources; In response to the deployment of the first task, the number of replicas and image tags of the deployment resources are updated, and an image synchronization process is triggered. The image synchronization process includes synchronizing the images of the private repository Harbor to the Kubernetes cluster. The image synchronization process includes creating a synchronization policy task, adding the synchronization policy task to the remote dictionary service Redis queue, and executing a scheduled task. The scheduled task is used to retrieve the queue of the synchronization policy task from the remote dictionary service Redis queue, verify the number of tasks that are being synchronized, and execute the image synchronization process or stop executing the image synchronization process based on the verification result. Create a resource controller based on the deployment resources in the at least two Kubernetes clusters; The application is deployed across clusters by pulling the image from the resource controller and starting the target number of replicas of the target instance pod. The image is built after running the pipeline and stored in the private repository Harbor.
2. The method according to claim 1, characterized in that, The method further includes: The second task is to compile the target code in the code hosting platform to generate the image, and then push the image to the private repository Harbor. Perform the second task.
3. The method according to claim 2, characterized in that, After performing the second task, the method further includes: Scan the target code and select the branch code whose code quality is higher than the quality threshold; Based on the branch code, deploy the first task.
4. The method according to claim 3, characterized in that, The scheduled task is also used to obtain the verification result from the remote dictionary service Redis queue; If the verification result indicates that the synchronization strategy task was executed successfully, then the synchronization strategy task is deleted. If the verification result indicates that the synchronization strategy task has failed, then the synchronization strategy task is instructed to retransmit.
5. A device for pipelined cross-cluster deployment applications, characterized in that, The device includes: The first acquisition module is used to acquire a target resource template, which includes personalized parameters and default general parameters; The generation module is used to generate a declaration style YAML file based on the application parameters configured in the resource template. The default general parameters do not need to be manually configured and are automatically populated into the declaration style YAML file. The first creation module is used to interact with at least two Kubernetes clusters based on the declared style YAML file to create cross-cluster deployment resources; The update module is used to respond to the first deployment task, update the number of replicas and image tags of the deployment resources, and trigger the image synchronization process. The image synchronization process includes synchronizing the images of the private repository Harbor to the Kubernetes cluster. The image synchronization process includes creating a synchronization policy task, adding the synchronization policy task to the remote dictionary service Redis queue, and executing a scheduled task. The scheduled task is used to retrieve the queue of the synchronization policy task from the remote dictionary service Redis queue, verify the number of tasks that are being synchronized, and execute the image synchronization process or stop the execution of the image synchronization process based on the verification result. The second creation module is used to create a resource controller based on the deployment resources in at least two of the Kubernetes clusters; The deployment module is used to pull the image through the resource controller and start the target number of target instance pods to complete the cross-cluster deployment of the application. The image is built after running the pipeline and stored in the private repository Harbor.
6. A terminal, characterized in that, The terminal includes a processor, a memory connected to the processor, and program instructions stored in the memory. When the processor executes the program instructions, it implements the method for pipelined cross-cluster deployment of applications as described in any one of claims 1 to 4.
7. A computer-readable storage medium storing program instructions, characterized in that, When the program instructions are executed by the processor, they implement the method for pipelined cross-cluster deployment of applications as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Continuous integration method and system based on k8s and docker containers
CN111930388A
Automatic CI / CD assembly line method based on Jenkins
CN112130956A