Service deployment method, apparatus, device, and storage medium

By using containers instead of physical machines or virtual machines in service deployment, and extracting image file information and target container information for image deployment, the problems of high cost and poor reliability in existing technologies are solved, and more efficient resource utilization and stability management are achieved.

CN117407116BActive Publication Date: 2026-11-10360 TECH GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210795943.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-07
Publication Date
2026-11-10
Estimated Expiration
2042-07-07

AI Technical Summary

Technical Problem

Existing software service deployment solutions are costly, unreliable, and wasteful of resources. They are also complex, time-consuming, and labor-intensive to maintain, making it difficult to guarantee service stability.

Method used

By extracting image file information and target container information from the service deployment request, the target service image is obtained, and the container to be deployed is removed from the cluster service list. After the image is deployed, it is added back to the cluster service list, using containers to replace traditional physical machines or virtual machines for deployment.

Benefits of technology

It improved equipment utilization, simplified environmental consistency management, enhanced the execution efficiency and reliability of service deployment, and reduced labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117407116B_ABST
    Figure CN117407116B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of computer technology and discloses a service deployment method, apparatus, device, and storage medium. Embodiments of this invention extract image file information and target container information from a service deployment request; obtain the target service image based on the image file information and determine the container to be deployed based on the target container information; remove the container to be deployed from the cluster service list and perform image deployment on the container to be deployed based on the target service image; and add the container to be deployed to the cluster service list upon completion of image deployment. Because containers are used instead of traditional physical machines or virtual machines when deploying services, the utilization rate of equipment is higher, and the environment is more easily unified due to the use of containers. Therefore, image files with high requirements for environment consistency can be used for rapid deployment, thereby improving the execution efficiency of service deployment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a service deployment method, apparatus, device, and storage medium. Background Technology

[0002] Existing software service deployment solutions typically involve: using a code compilation service (such as Jenkins) on the build machine (physical or virtual machine) corresponding to the business to perform code retrieval and compilation operations, and uploading the compiled output (such as compressed packages or executable code packages) to one or more deployment machines (physical or virtual machines) corresponding to the service. Then, the service update and replacement commands are executed on the deployment machines to achieve service deployment.

[0003] However, this approach requires each business to maintain a separate code compilation service, which is complex, time-consuming, labor-intensive, and has high human resource costs. Furthermore, due to the varying experience of maintenance personnel, the reliability and stability of the service are difficult to guarantee. In addition, each business needs a corresponding build machine and more than one deployment machine, resulting in a significant waste of machine resources.

[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention

[0005] The main objective of this invention is to provide a service deployment method, apparatus, device, and storage medium, aiming to solve the technical problems of high cost and poor reliability of existing software deployment solutions.

[0006] To achieve the above objectives, the present invention provides a service deployment method, the method comprising the following steps: Extract image file information and target container information from the service deployment request; Obtain the target service image based on the image file information, and determine the container to be deployed based on the target container information; Remove the container to be deployed from the cluster service list, and deploy the container to be deployed using the target service image; Once the image deployment is complete, the container to be deployed is added to the cluster service list.

[0007] Optionally, the step of obtaining the target service image based on the image file information includes: The information of the image file is extracted based on preset rules to obtain the encrypted access path and file storage path; The encrypted access path is decrypted using a preset decryption algorithm to obtain the repository access path; Obtain the target service image based on the warehouse access path and the file storage path.

[0008] Optionally, before the step of extracting image file information and target container information from the service deployment request, the method further includes: Upon receiving an image build request, the code access path and repository access path are extracted from the image build request; Create a service build container and obtain the code to be deployed based on the code access path; The code to be deployed is passed into the service build container so that the service build container can build an image based on the code to be deployed. When the image building is complete, the service image file generated by the image building is extracted from the service building container, and the service image file is uploaded to the corresponding image repository according to the repository access path.

[0009] Optionally, the step of creating a service build container and obtaining the code to be deployed based on the code access path includes: Extract the service namespace from the image build request; Create a service building container in the memory space corresponding to the service namespace; The code repository is determined based on the code access path; The code to be deployed is obtained from the code repository according to the code access path.

[0010] Optionally, the step of obtaining the code to be deployed from the code repository according to the code access path includes: Obtain the code repository identifier corresponding to the code repository; Based on the code repository identifier, the corresponding repository access account and repository access password are searched in the preset account table; Based on the code repository identifier, the corresponding data combination rule is searched in the preset repository rule table; A code retrieval request is generated based on the data combination rules, the warehouse access account, the warehouse access password, and the code access path; Based on the code retrieval request, the code to be deployed is retrieved from the code repository.

[0011] Optionally, the step of generating a code retrieval request based on the data combination rules, the repository access account, the repository access password, and the code access path includes: The warehouse access account, the warehouse access password, and the code access path are combined according to the data combination rules to generate rule combination data; The rule combination data is encrypted using a preset encryption algorithm to obtain data signature data; A code retrieval request is constructed based on the data signature data, the repository access account, the repository access password, and the code access path.

[0012] Optionally, the step of determining the container to be deployed based on the target container information includes: The target container information is parsed to obtain at least one container matching condition; Construct container matching rules based on the container matching conditions; The container identifiers corresponding to each container in the cluster are matched with the container matching rules, and the containers to be deployed are determined based on the matching results.

[0013] Optionally, the step of matching the container identifiers corresponding to each container in the cluster with the container matching rules, and determining the container to be deployed based on the matching results, includes: Extract the target space identifier from the service deployment request; The target memory space is determined based on the target space identifier; Obtain the container identifiers corresponding to each container in the target memory space; The container identifiers corresponding to each container in the target memory space are matched with the container matching rules, and the containers to be deployed are determined based on the matching results.

[0014] Optionally, the step of deploying the container to be deployed based on the target service image includes: Extract deployment environment parameters from the target service image; The container environment of the container to be deployed is adjusted according to the deployment environment parameters; Upon completion of the adjustment, the target service image is transferred to the container to be deployed, so that the container to be deployed can perform image deployment based on the target service image.

[0015] Optionally, before the step of adjusting the container environment of the container to be deployed according to the deployment environment parameters, the method further includes: Extract the service runtime identifier from the target service image; Detect whether the container background service corresponding to the service running identifier exists in the container to be deployed; If it exists, a service stop command is generated based on the service running identifier; The container background service corresponding to the service running identifier in the container to be deployed is terminated according to the service stop command. Upon successful termination, the step of adjusting the container environment of the container to be deployed based on the deployment environment parameters is executed.

[0016] Optionally, the step of adding the container to be deployed to the cluster service list when the image deployment is completed includes: When the image deployment is complete, the target service identifier is extracted from the target service image; Search the cluster service list according to the target service identifier to obtain the number of records corresponding to the target service identifier; Generate service index data based on the number of records; Generate a container service record based on the target service identifier, the service index data, and the container information corresponding to the container to be deployed; The container to be deployed is added to the cluster service list based on the container service record.

[0017] Furthermore, to achieve the above objectives, the present invention also proposes a service deployment apparatus, which includes the following modules: The information extraction module is used to extract image file information and target container information from service deployment requests; The target determination module is used to obtain the target service image based on the image file information and determine the container to be deployed based on the target container information. The image deployment module is used to remove the container to be deployed from the cluster service list and deploy the container to be deployed according to the target service image. The service addition module is used to add the container to be deployed to the cluster service list when the image deployment is completed.

[0018] Optionally, the target determination module is further configured to extract the image file information based on preset rules to obtain an encrypted access path and a file storage path; decrypt the encrypted access path using a preset decryption algorithm to obtain a repository access path; and obtain the target service image based on the repository access path and the file storage path.

[0019] Optionally, the information extraction module is further configured to, upon receiving an image build request, extract the code access path and repository access path from the image build request; create a service build container and obtain the code to be deployed according to the code access path; pass the code to be deployed into the service build container so that the service build container performs image build based on the code to be deployed; and, upon completion of image build, extract the service image file generated by image build from the service build container and upload the service image file to the corresponding image repository according to the repository access path.

[0020] Optionally, the information extraction module is further configured to extract a service namespace from the image build request; create a service build container in the memory space corresponding to the service namespace; determine a code repository based on the code access path; and obtain the code to be deployed from the code repository based on the code access path.

[0021] Optionally, the information extraction module is further configured to: obtain the code repository identifier corresponding to the code repository; search for the corresponding repository access account and repository access password in a preset account table based on the code repository identifier; search for the corresponding data combination rule in a preset repository rule table based on the code repository identifier; generate a code acquisition request based on the data combination rule, the repository access account, the repository access password, and the code access path; and acquire the code to be deployed from the code repository based on the code acquisition request.

[0022] Optionally, the information extraction module is further configured to combine the warehouse access account, the warehouse access password, and the code access path according to the data combination rules to generate rule combination data; encrypt the rule combination data using a preset encryption algorithm to obtain data signature data; and construct a code acquisition request based on the data signature data, the warehouse access account, the warehouse access password, and the code access path.

[0023] Optionally, the target determination module is further configured to parse the target container information to obtain at least one container matching condition; construct a container matching rule based on the container matching condition; match the container identifiers corresponding to each container in the cluster with the container matching rule, and determine the container to be deployed based on the matching result.

[0024] In addition, to achieve the above objectives, the present invention also proposes a service deployment device, which includes a processor, a memory, and a service deployment program stored in the memory and executable on the processor. When the service deployment program is executed by the processor, it implements the steps of the service deployment method described above.

[0025] Furthermore, to achieve the above objectives, the present invention also proposes a computer-readable storage medium storing a service deployment program, which, when executed, implements the steps of the service deployment method described above.

[0026] This invention extracts image file information and target container information from service deployment requests; obtains the target service image based on the image file information and determines the container to be deployed based on the target container information; removes the container to be deployed from the cluster service list and deploys the container based on the target service image; and adds the container to be deployed back to the cluster service list upon completion of image deployment. Because containers are used instead of traditional physical machines or virtual machines for service deployment, device utilization is higher, and the environment is more easily standardized due to container deployment. Therefore, image files with high requirements for environment consistency can be used for rapid deployment, thereby improving the execution efficiency of service deployment. Attached Figure Description

[0027] Figure 1 This is a schematic diagram of the structure of an electronic device in the hardware operating environment involved in the embodiments of the present invention; Figure 2 This is a flowchart illustrating the first embodiment of the service deployment method of the present invention. Figure 3 This is a flowchart illustrating the second embodiment of the service deployment method of the present invention. Figure 4 A flowchart illustrating the third embodiment of the service deployment method of the present invention; Figure 5 This is a structural block diagram of the first embodiment of the service deployment device of the present invention.

[0028] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0029] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.

[0030] Reference Figure 1 , Figure 1 This is a schematic diagram of the service deployment device structure of the hardware operating environment involved in the embodiments of the present invention.

[0031] like Figure 1As shown, the electronic device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be high-speed random access memory (RAM) or stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.

[0032] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0033] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a service deployment program.

[0034] exist Figure 1 In the electronic device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the electronic device of the present invention can be set in the service deployment device. The electronic device calls the service deployment program stored in the memory 1005 through the processor 1001 and executes the service deployment method provided in the embodiment of the present invention.

[0035] This invention provides a service deployment method, referring to... Figure 2 , Figure 2 This is a flowchart illustrating a first embodiment of a service deployment method according to the present invention.

[0036] In this embodiment, the service deployment method includes the following steps: Step S10: Extract image file information and target container information from the service deployment request.

[0037] It should be noted that the execution subject of this embodiment can be the service deployment device, which can be a personal computer, server or other electronic device, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the service deployment device is used as an example to illustrate the service deployment method of the present invention.

[0038] It should be noted that a service deployment request can be a request sent by a user to the service deployment device when the user operates other devices to deploy software services, or it can be a request generated based on the task information of the automatic deployment task when the triggering conditions of the automatic deployment task are met. For example, if the automatic deployment task is set to automatically deploy the service of business A at 9:00 pm every night, the service deployment device will read the task information corresponding to the automatic deployment task and generate the corresponding service deployment request when it detects that the time has reached 9 pm.

[0039] In practical implementation, traditional physical machine or virtual machine service deployment methods have low resource utilization, while container service deployment can be performed directly using image files, which is faster and has higher resource utilization. Therefore, containers can be used to replace traditional physical machines or virtual machines for service deployment. Image file information can be the information of the image file required for image deployment. Image file information can include at least one of the following: the access directory of the image file, the name of the image file, the size of the image file, and the version number of the image file. The image file can be a Docker image file, but other types of image files are also possible; this embodiment does not limit this. Target container information can be the container information of the selected container for service deployment. Target container information can include the container name, container identifier, etc. The container can be a slave container, or other containers that can achieve the same function.

[0040] Step S20: Obtain the target service image based on the image file information, and determine the container to be deployed based on the target container information.

[0041] It should be noted that the target service image can be the image file required during image deployment. The container to be deployed can be the container selected for service deployment.

[0042] In practical use, image files are typically stored in an image repository. Obtaining the target service image based on image file information can be achieved by searching the image repository for that image file. Alternatively, service deployment devices can store downloaded image files locally for a certain period. In this case, obtaining the target service image based on image file information can also involve matching the file information of the locally stored image file with the target image file information. If a matching image file exists, it is used as the target service image; otherwise, the image file is searched in the image repository. Determining the container to be deployed based on the target container information can be achieved by matching the container information of all containers in the service cluster with the target container information. Containers that match are used as the container to be deployed. If no matching container exists, a new container can be created as the container to be deployed.

[0043] Furthermore, since the image repository contains a large number of image files corresponding to various services, exposing the access path of the image repository to the external network poses a significant risk. To avoid this, the access path of the image repository can be encrypted before being provided to the user. In this case, the image file information extracted from the service deployment request will only contain the encrypted access path of the image repository, and it is not possible to directly access the image repository based on the image file information. Additional processing is required. Therefore, the step of obtaining the target service image based on the image file information described in this embodiment may include: The information of the image file is extracted based on preset rules to obtain the encrypted access path and file storage path; The encrypted access path is decrypted using a preset decryption algorithm to obtain the repository access path; Obtain the target service image based on the warehouse access path and the file storage path.

[0044] It should be noted that the preset rules can be set according to the length of the encrypted data generated after encrypting the access path of the image repository. For example, if the length of the encrypted data generated after encrypting the access path is fixed at 32, and the data concatenation method in the image file information is that the encrypted access path comes first and the file storage path comes second, then the preset rule can be set to: extract the 0th to 31st characters in the image file information, use the extracted part as the encrypted access path, and use the remaining part as the file storage path.

[0045] In practical implementation, reversible encryption algorithms, such as DES or RSA, can be used to encrypt the access path to the mirror repository. The default decryption algorithm can be the decryption algorithm corresponding to the encryption algorithm used to encrypt the access path to the mirror repository.

[0046] In practical use, obtaining the target service image based on the repository access path and file storage path can be achieved by accessing the image repository based on the repository access path, and then reading the file corresponding to the file storage path in the image repository to obtain the target service image.

[0047] Furthermore, in order to quickly identify the container to be deployed, the step of determining the container to be deployed based on the target container information described in this embodiment may be: The target container information is parsed to obtain at least one container matching condition; Construct container matching rules based on the container matching conditions; The container identifiers corresponding to each container in the cluster are matched with the container matching rules, and the containers to be deployed are determined based on the matching results.

[0048] It should be noted that users may select containers for deployment in multiple ways, resulting in various container matching conditions. When sending data to the containers, these different conditions are typically transformed and concatenated according to preset transformation rules to facilitate transmission and reception. For example, if a user sets the condition as "containers named 'test' with numbers 1-3 and 4-5", it will be transformed into "@test#1-3|4-5". Therefore, parsing the target container information to obtain at least one container matching condition can be achieved by parsing the target container information according to the preset transformation rules.

[0049] In practical use, constructing container matching rules based on container matching conditions can be achieved by converting the container matching conditions into regular expressions and using the converted regular expressions as container matching rules. For example, if the container matching condition is "the container name is 'test' and the number is 1-3", then the converted regular expression is "^test[1,2,3]{1}$".

[0050] Understandably, regular expression matching is fast. The generated regular expression is used as the container matching rule, and then the container matching rule is matched with the container identifier of each container to quickly determine the container to be deployed.

[0051] Furthermore, if the cluster is large, the total number of containers is also large. Matching them one by one could be extremely time-consuming. To improve the matching speed, the step described in this embodiment of matching the container identifiers corresponding to each container in the cluster with the container matching rules and determining the containers to be deployed based on the matching results may include: Extract the target space identifier from the service deployment request; The target memory space is determined based on the target space identifier; Obtain the container identifiers corresponding to each container in the target memory space; The container identifiers corresponding to each container in the target memory space are matched with the container matching rules, and the containers to be deployed are determined based on the matching results.

[0052] It should be noted that when the cluster is large, for easier management, containers in the cluster can be set up in different memory spaces, and each memory space can be assigned a unique identifier. The target space identifier can be a unique identifier of the memory space that the user specifies to be searched.

[0053] It is understandable that by first finding the corresponding memory space, i.e. the target memory space, through the target space identifier, and then matching the container identifiers corresponding to each container in the target memory space with the container matching rules, the number of containers that need to be matched can be greatly reduced, thereby improving the matching speed.

[0054] Step S30: Remove the container to be deployed from the cluster service list, and deploy the container to be deployed according to the target service image.

[0055] It's important to note that removing a container's information from the cluster service list will prevent other services in the cluster from accessing that container. If you need to redeploy a service to a container, the container's service will be unavailable during the deployment process. To avoid impacting the normal operation of the service cluster, you can remove the container's information from the cluster service list.

[0056] In practical use, deploying a container based on a target service image can be done by passing the target service image into the container and sending an image deployment command to the container, which then adjusts its environment according to the target service image and starts the service based on the software code in the target service image.

[0057] Step S40: When the image deployment is complete, add the container to be deployed to the cluster service list.

[0058] It should be noted that if the image deployment is complete, it means that the service in the container to be deployed has been successfully updated to the service corresponding to the target service image. At this time, the container to be deployed can provide services normally. In order to make it accessible to other services in the service cluster, the container to be deployed can be added to the cluster service list.

[0059] Furthermore, to ensure that other services in the cluster can recognize the services in the container to be deployed after deployment and make normal calls, step S40 in this embodiment may include: When the image deployment is complete, the target service identifier is extracted from the target service image; Search the cluster service list according to the target service identifier to obtain the number of records corresponding to the target service identifier; Generate service index data based on the number of records; Generate a container service record based on the target service identifier, the service index data, and the container information corresponding to the container to be deployed; The container to be deployed is added to the cluster service list based on the container service record.

[0060] It should be noted that the target service identifier can be a unique identifier for the service corresponding to the target service image. Searching the cluster service list based on the target service identifier to obtain the number of records corresponding to that identifier can be done by matching the container names of each container in the cluster service list with the target service identifier and counting the number of matched containers. The container names and the target service identifier can be matched using a prefix; for example, if the target service identifier is "test", then all containers whose names begin with "test" will be successfully matched.

[0061] In practical implementation, since the cluster provides services through multiple machine systems, multiple different servers will provide services corresponding to the same business. In order to ensure that each container can be distinguished normally, it is necessary to establish corresponding service index data (such as: 1, 2, 3, etc.) for each container. When adding the container to be deployed back to the cluster service list, in order to determine the service index data corresponding to the container to be deployed, it is necessary to determine how many containers are currently providing services for the business corresponding to the service currently running by the container to be deployed. Therefore, the target business identifier can be extracted from the target service image, and then the cluster service list can be searched according to the target business identifier to determine the number of records corresponding to the target business identifier. Based on the number of records, the number of containers in the cluster that are providing services for this business can be determined.

[0062] In practical use, generating service index data based on the number of records can be achieved by incrementing the number of records by one, and then using the result as the service index data. Generating container service records based on the target business identifier, service index data, and the container information corresponding to the container to be deployed can be achieved by concatenating the target business identifier and service index data into a concatenated container name, modifying the container name of the container to be deployed to the concatenated container name, and then filling the container name and the container information corresponding to the container to be deployed into the container record template to obtain the container service record. The container record template can be pre-configured by the administrators of the service deployment equipment according to actual needs.

[0063] It should be noted that there is generally a record table in the cluster that records containers that can provide services, which can be called the service container record table. Adding the container to be deployed to the cluster service list based on the container service record can be achieved by adding the container service record to the service container record table in the cluster, thereby adding the container to be deployed to the cluster service list.

[0064] This embodiment extracts image file information and target container information from the service deployment request; obtains the target service image based on the image file information and determines the container to be deployed based on the target container information; removes the container to be deployed from the cluster service list and deploys the container based on the target service image; and adds the container to be deployed to the cluster service list upon completion of image deployment. Since containers are used instead of traditional physical machines or virtual machines when deploying services, device utilization is higher, and the environment is more easily standardized due to container deployment. Therefore, image files with high requirements for environment consistency can be used for rapid deployment, thereby improving the execution efficiency of service deployment.

[0065] refer to Figure 3 , Figure 3 This is a flowchart illustrating a second embodiment of a service deployment method according to the present invention.

[0066] Based on the first embodiment described above, the service deployment method of this embodiment further includes, before step S10: Step S01: Upon receiving an image build request, extract the code access path and repository access path from the image build request.

[0067] It's important to note that the image files used for image deployment require pre-compilation and building of the code. Image build requests can be sent to the service deployment device by the user operating other devices, generated directly by the user operating the service deployment device, or automatically generated when the trigger conditions for an automated deployment task are met. The code access path can be the specified access path for the code used for image building, and the repository access path can be the access path for the image repository.

[0068] Step S02: Create a service build container and obtain the code to be deployed according to the code access path.

[0069] It should be noted that creating a service build container can be done by creating a container based on a standard container template and using that container as the service build container. Obtaining the code to be deployed based on a code access path can be done by pulling the software code according to the code access path and using the pulled software code as the code to be deployed.

[0070] In practice, the service corresponding to the code to be deployed may have already had a service build container created and not destroyed. In this case, it is not necessary to create a new service build container, but to reuse the previously created service build container directly.

[0071] In practical use, different businesses may have different requirements for containers. After obtaining the code to be deployed, it is also possible to check whether there is an environment configuration file in the code to be deployed. If so, the environment in the service building container can be adjusted according to the environment configuration file.

[0072] Furthermore, to avoid mutual interference between services corresponding to multiple different businesses, step S02 in this embodiment may include: Extract the service namespace from the image build request; Create a service building container in the memory space corresponding to the service namespace; The code repository is determined based on the code access path; The code to be deployed is obtained from the code repository according to the code access path.

[0073] It's important to note that services corresponding to different business operations need to be isolated by building containers. This can be achieved by dividing the device's memory into different memory spaces. To distinguish these different memory spaces, a unique identifier, i.e., a namespace, can be assigned to each memory space. The service namespace can be the namespace corresponding to the business operation to which the code to be deployed belongs. Accessing the code repository based on the code access path can be achieved by extracting the repository name from the code access path and then determining the code repository based on the repository name.

[0074] In the implementation, to avoid service deployment containers for different services residing in the same memory space and thus interfering with each other, the service namespace is extracted from the image build request before creating the service build container. Then, the corresponding memory space for that service namespace is located, and the service build container is created within that memory space. This isolates the service build containers for each service, preventing interference. Obtaining the code to be deployed from the code repository based on the code access path can be achieved by generating a code retrieval request based on the code access path, sending the request to the code repository, and having the repository return the software code corresponding to the access path, thus obtaining the code to be deployed.

[0075] Furthermore, the service deployment device may simultaneously connect to multiple different code repositories. The usernames and passwords used to access these repositories may differ, and the security requirements of each repository may vary. Consequently, the methods for generating code retrieval requests will also differ significantly. To ensure support for different code repositories, the step of retrieving the code to be deployed from the code repository based on the code access path, as described in this embodiment, may include: Obtain the code repository identifier corresponding to the code repository; Based on the code repository identifier, the corresponding repository access account and repository access password are searched in the preset account table; Based on the code repository identifier, the corresponding data combination rule is searched in the preset repository rule table; A code retrieval request is generated based on the data combination rules, the warehouse access account, the warehouse access password, and the code access path; Based on the code retrieval request, the code to be deployed is retrieved from the code repository.

[0076] It should be noted that the code repository identifier can be the name of the code repository. However, in some cases, the code names may be the same. In this case, you can not only use the name of the code repository, but also combine the domain name, port number, etc. of the code repository as the code repository identifier. For example, you can concatenate the name, domain name, and port number of the code repository in the format of "name-domain name-port number" and use the concatenated string as the code repository identifier.

[0077] It should be noted that generating a code retrieval request based on data combination rules, repository access account, repository access password, and code access path can be achieved by combining these three parameters into request parameters according to the data combination rules, and then filling these parameters into the code retrieval request template. For example, the repository access account and password can be separated by "|", and the code access path by "&", thus combining them into a string, which can then be used as the request parameter. Different code repositories can correspond to different data combination rules, and the code retrieval request template can be pre-configured by the administrators of the service deployment equipment according to actual needs.

[0078] In practical use, retrieving the code to be deployed from the code repository based on the code retrieval request can be done by sending the code retrieval request to the code repository, which then verifies the repository access account and password in the code retrieval request. After successful verification, the repository will search for the corresponding code to be deployed in the code access path in the code retrieval request and then send the code to be deployed back to the service deployment device.

[0079] Furthermore, since simply concatenating the repository access account, repository access password, and code access path using data combination rules and sending them as request parameters to the code repository, even though the parameters have been modified through concatenation, they are still displayed in plaintext, making them vulnerable to cracking and posing a high risk, to improve security, the step of generating a code acquisition request based on the data combination rules, the repository access account, the repository access password, and the code access path described in this embodiment may include: The warehouse access account, the warehouse access password, and the code access path are combined according to the data combination rules to generate rule combination data; The rule combination data is encrypted using a preset encryption algorithm to obtain data signature data; A code retrieval request is constructed based on the data signature data, the repository access account, the repository access password, and the code access path.

[0080] It should be noted that, according to the data combination rules, the warehouse access account, warehouse access password, and code access path are combined to generate rule combination data. This can be done by combining the warehouse access account, warehouse access password, and code access path into a string based on the data concatenation and data splitting methods recorded in the data combination rules, and then using the resulting string as the rule combination data. The data concatenation order and data splitting method can be preset by the administrators of the service deployment device according to actual needs. For example, the data concatenation order can be set to "warehouse access account - warehouse access password - code access path", and the data splitting method can be set to separate the warehouse access account and warehouse access password with the character "$", and separate the warehouse access password and code access path with the character "@".

[0081] In practical implementation, to increase the difficulty of cracking the data signature data, the preset encryption algorithm can be an irreversible encryption algorithm, such as the MD5 algorithm or the MD5-SHA algorithm. Of course, other types of algorithms can also be used, and this embodiment does not limit this. Constructing a code retrieval request based on the data signature data, repository access account, repository access password, and code access path can be achieved by filling the data signature data, repository access account, repository access password, and code access path as request parameters into the code retrieval request template, thereby generating a code retrieval request. Alternatively, depending on actual needs, the data signature data, repository access account, repository access password, and code access path can be concatenated into a string, and then the concatenated string can be used as a request parameter.

[0082] Understandably, after receiving a code retrieval request, the code repository can extract data signature data, repository access account, repository access password, and code access path. Then, it generates signature verification data using the same method based on the repository access account, password, and path. This verification data is then compared to the data signature data. If they match, account verification is performed using the repository access account and password. If verification passes, the code to be deployed is located using the code access path. During this process, even if the code retrieval request is intercepted, the interceptor cannot know how to generate the data signature data based on the repository access account, password, and path, thus failing the code repository's verification and improving security.

[0083] Step S03: Pass the code to be deployed into the service build container so that the service build container can build an image based on the code to be deployed.

[0084] It should be noted that the service build container created according to the standard container template contains the image build tools and image build scripts required for image building. At this time, the code to be deployed is passed into the service build container, and the service build container can execute the image build script through the image build tools to perform image building.

[0085] Step S04: When the image building is complete, extract the service image file generated by the image building from the service building container, and upload the service image file to the corresponding image repository according to the repository access path.

[0086] Understandably, after the image is built, in order to facilitate rapid service deployment by directly using the service image file generated by the image build, the service image file can be uploaded to the corresponding image repository for storage according to the repository access path.

[0087] This embodiment extracts the code access path and repository access path from the image build request upon receipt; creates a service build container and obtains the code to be deployed based on the code access path; passes the code to be deployed into the service build container, enabling the service build container to build an image based on the code; and upon completion of the image build, extracts the service image file generated by the image build container and uploads the service image file to the corresponding image repository according to the repository access path. Because the code to be deployed is extracted in advance and a standardized service build container is created, and the corresponding image file is generated and stored in the image repository within the service build container, the corresponding image file can be quickly extracted from the image repository for service deployment when needed subsequently.

[0088] refer to Figure 4 , Figure 4 This is a flowchart illustrating a third embodiment of a service deployment method according to the present invention.

[0089] Based on the first embodiment described above, step S30 of the service deployment method in this embodiment may include: Step S301: Remove the container to be deployed from the cluster service list and extract the deployment environment parameters from the target service image.

[0090] It should be noted that deployment environment parameters can include the software dependencies of the service corresponding to the target service image and the software version numbers of each dependency. These deployment environment parameters can be stored in the header of the image file; in this case, extracting the deployment environment parameters from the target service image can be done by reading them from the target service image's header.

[0091] Step S302: Adjust the container environment of the container to be deployed according to the deployment environment parameters.

[0092] It should be noted that adjusting the container environment of the container to be deployed based on the deployment environment parameters can involve reading the container environment of the container to be deployed, comparing the container environment with the deployment environment parameters to identify missing software and out-of-version software, installing the missing software in the container, uninstalling the out-of-version software in the container, and then reinstalling it according to the software version number of the out-of-version software recorded in the deployment environment parameters. The container environment can include the software already installed in the container and the software version numbers of each installed software.

[0093] Furthermore, since service deployment may be required due to software upgrades, the container to be deployed may already have an earlier version of the service running. In this case, the dependent software within the container may be occupied, and the adjustment may fail. To avoid this, before step S302 in this embodiment, the following may also be included: Extract the service runtime identifier from the target service image; Detect whether the container background service corresponding to the service running identifier exists in the container to be deployed; If it exists, a service stop command is generated based on the service running identifier; The container background service corresponding to the service running identifier in the container to be deployed is terminated according to the service stop command. Upon successful termination, the step of adjusting the container environment of the container to be deployed based on the deployment environment parameters is executed.

[0094] It should be noted that the service runtime identifier can be a unique identifier for the service corresponding to the target service image within the container's service list at runtime. Generating a service stop command based on the service runtime identifier can be achieved by filling the service runtime identifier as a command parameter into a stop command template. The stop command template can be pre-configured by the administrator of the service deployment device based on the container type used in the cluster.

[0095] It is understandable that if a container background service corresponding to the service running identifier exists in the container to be deployed, it means that an earlier version of the service is running in the container to be deployed. In this case, adjusting the container environment may fail, and the container background service corresponding to the service running identifier in the container to be deployed needs to be stopped. Therefore, a service stop command can be generated based on the service running identifier.

[0096] In practical use, terminating the container background service corresponding to the service running identifier in the container to be deployed according to the service stop command can be achieved by sending the service stop command to the container to be deployed, causing the container to execute the service stop command, thereby stopping the container background service corresponding to the service running identifier.

[0097] Step S303: Upon completion of the adjustment, the target service image is transferred to the container to be deployed, so that the container to be deployed can perform image deployment based on the target service image.

[0098] Understandably, after the adjustment is completed, the container to be deployed already has all the dependent software to run the service corresponding to the target service image. At this time, the service corresponding to the target service image can run normally in the container to be deployed. Therefore, the target service image can be passed to the container to be deployed so that the container to be deployed can perform image deployment based on the target service image, thereby deploying the service corresponding to the target service image in the container to be deployed.

[0099] This embodiment extracts deployment environment parameters from the target service image; adjusts the container environment of the container to be deployed based on these parameters; and upon completion of the adjustment, transfers the target service image into the container to be deployed, enabling the container to deploy based on the target service image. Because deployment environment parameters are extracted from the target service image before deployment, and the container environment is adjusted accordingly, the image deployment is performed only after the adjustment is complete, ensuring that the services within the container to be deployed can operate normally and provide services after image deployment.

[0100] Furthermore, embodiments of the present invention also propose a storage medium storing a service deployment program, which, when executed by a processor, implements the steps of the service deployment method described above.

[0101] Reference Figure 5 , Figure 5 This is a structural block diagram of the first embodiment of the service deployment device of the present invention.

[0102] like Figure 5 As shown, the service deployment apparatus proposed in this embodiment of the invention includes: Information extraction module 10 is used to extract image file information and target container information from service deployment requests; The target determination module 20 is used to obtain the target service image based on the image file information and determine the container to be deployed based on the target container information; The image deployment module 30 is used to remove the container to be deployed from the cluster service list and deploy the container to be deployed according to the target service image. The service addition module 40 is used to add the container to be deployed to the cluster service list when the image deployment is completed.

[0103] This embodiment extracts image file information and target container information from the service deployment request; obtains the target service image based on the image file information and determines the container to be deployed based on the target container information; removes the container to be deployed from the cluster service list and deploys the container based on the target service image; and adds the container to be deployed to the cluster service list upon completion of image deployment. Since containers are used instead of traditional physical machines or virtual machines when deploying services, device utilization is higher, and the environment is more easily standardized due to container deployment. Therefore, image files with high requirements for environment consistency can be used for rapid deployment, thereby improving the execution efficiency of service deployment.

[0104] Furthermore, the target determination module 20 is also used to extract the image file information based on preset rules to obtain the encrypted access path and file storage path; decrypt the encrypted access path through a preset decryption algorithm to obtain the repository access path; and obtain the target service image based on the repository access path and the file storage path.

[0105] Furthermore, the target determination module 20 is also configured to, upon receiving an image build request, extract the code access path and repository access path from the image build request; create a service build container and obtain the code to be deployed according to the code access path; pass the code to be deployed into the service build container so that the service build container performs image build based on the code to be deployed; and when the image build is completed, extract the service image file generated by the image build from the service build container and upload the service image file to the corresponding image repository according to the repository access path.

[0106] Furthermore, the target determination module 20 is also used to extract a service namespace from the image build request; create a service build container in the memory space corresponding to the service namespace; determine a code repository according to the code access path; and obtain the code to be deployed from the code repository according to the code access path.

[0107] Furthermore, the target determination module 20 is also used to obtain the code repository identifier corresponding to the code repository; search for the corresponding repository access account and repository access password in a preset account table according to the code repository identifier; search for the corresponding data combination rule in a preset repository rule table according to the code repository identifier; generate a code acquisition request according to the data combination rule, the repository access account, the repository access password and the code access path; and acquire the code to be deployed from the code repository based on the code acquisition request.

[0108] Furthermore, the target determination module 20 is also used to combine the warehouse access account, the warehouse access password, and the code access path according to the data combination rules to generate rule combination data; encrypt the rule combination data using a preset encryption algorithm to obtain data signature data; and construct a code acquisition request based on the data signature data, the warehouse access account, the warehouse access password, and the code access path.

[0109] Furthermore, the target determination module 20 is also used to parse the target container information to obtain at least one container matching condition; construct a container matching rule based on the container matching condition; match the container identifiers corresponding to each container in the cluster with the container matching rule, and determine the container to be deployed based on the matching result.

[0110] Furthermore, the target determination module 20 is also used to extract a target space identifier from the service deployment request; determine a target memory space based on the target space identifier; obtain the container identifier corresponding to each container in the target memory space; match the container identifier corresponding to each container in the target memory space with the container matching rules, and determine the container to be deployed based on the matching result.

[0111] Furthermore, the image deployment module 30 is also used to extract deployment environment parameters from the target service image; adjust the container environment of the container to be deployed according to the deployment environment parameters; and when the adjustment is completed, transfer the target service image into the container to be deployed so that the container to be deployed can perform image deployment according to the target service image.

[0112] Furthermore, the image deployment module 30 is also used to extract a service running identifier from the target service image; detect whether there is a container background service corresponding to the service running identifier in the container to be deployed; if there is, generate a service stop command according to the service running identifier; terminate the container background service corresponding to the service running identifier in the container to be deployed according to the service stop command; and when the termination is successful, execute the step of adjusting the container environment of the container to be deployed according to the deployment environment parameters.

[0113] Furthermore, the service addition module 40 is also used to extract a target service identifier from the target service image when the image deployment is completed; search the cluster service list according to the target service identifier to obtain the number of records corresponding to the target service identifier; generate service index data according to the number of records; generate a container service record according to the target service identifier, the service index data and the container information corresponding to the container to be deployed; and add the container to be deployed to the cluster service list according to the container service record.

[0114] It should be understood that the above are merely illustrative examples and do not constitute any limitation on the technical solutions of the present invention. In specific applications, those skilled in the art can make settings as needed, and the present invention does not impose any restrictions on this.

[0115] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of this invention. In practical applications, those skilled in the art can select some or all of the workflow to achieve the purpose of this embodiment according to actual needs, and no restrictions are imposed here.

[0116] In addition, for technical details not described in detail in this embodiment, please refer to the service deployment method provided in any embodiment of the present invention, which will not be repeated here.

[0117] Furthermore, it should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0118] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0119] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory (ROM) / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0120] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A service deployment method, characterized in that, The service deployment method includes the following steps: Extract image file information and target container information from the service deployment request; Obtain the target service image based on the image file information, and determine the container to be deployed based on the target container information; Remove the container to be deployed from the cluster service list, and deploy the container to be deployed using the target service image; Once the image deployment is complete, add the container to be deployed to the cluster service list; The step of deploying the container to be deployed based on the target service image includes: Extract deployment environment parameters from the target service image; The container environment of the container to be deployed is adjusted according to the deployment environment parameters; Upon completion of the adjustment, the target service image is passed into the container to be deployed, so that the container to be deployed can perform image deployment based on the target service image; The step of obtaining the target service image based on the image file information includes: The information of the image file is extracted based on preset rules to obtain the encrypted access path and file storage path; The encrypted access path is decrypted using a preset decryption algorithm to obtain the repository access path; Obtain the target service image based on the warehouse access path and the file storage path.

2. The service deployment method as described in claim 1, characterized in that, Before the step of extracting image file information and target container information from the service deployment request, the method further includes: Upon receiving an image build request, the code access path and repository access path are extracted from the image build request; Create a service build container and obtain the code to be deployed based on the code access path; The code to be deployed is passed into the service build container so that the service build container can build an image based on the code to be deployed. When the image building is complete, the service image file generated by the image building is extracted from the service building container, and the service image file is uploaded to the corresponding image repository according to the repository access path.

3. The service deployment method as described in claim 2, characterized in that, The steps of creating a service build container and obtaining the code to be deployed based on the code access path include: Extract the service namespace from the image build request; Create a service building container in the memory space corresponding to the service namespace; The code repository is determined based on the code access path; The code to be deployed is obtained from the code repository according to the code access path.

4. The service deployment method as described in claim 3, characterized in that, The step of obtaining the code to be deployed from the code repository according to the code access path includes: Obtain the code repository identifier corresponding to the code repository; Based on the code repository identifier, the corresponding repository access account and repository access password are searched in the preset account table; Based on the code repository identifier, the corresponding data combination rule is searched in the preset repository rule table; A code retrieval request is generated based on the data combination rules, the warehouse access account, the warehouse access password, and the code access path; Based on the code retrieval request, the code to be deployed is retrieved from the code repository.

5. The service deployment method as described in claim 4, characterized in that, The step of generating a code retrieval request based on the data combination rules, the repository access account, the repository access password, and the code access path includes: The warehouse access account, the warehouse access password, and the code access path are combined according to the data combination rules to generate rule combination data; The rule combination data is encrypted using a preset encryption algorithm to obtain data signature data; A code retrieval request is constructed based on the data signature data, the repository access account, the repository access password, and the code access path.

6. The service deployment method as described in claim 1, characterized in that, The step of determining the container to be deployed based on the target container information includes: The target container information is parsed to obtain at least one container matching condition; Construct container matching rules based on the container matching conditions; The container identifiers corresponding to each container in the cluster are matched with the container matching rules, and the containers to be deployed are determined based on the matching results.

7. The service deployment method as described in claim 6, characterized in that, The step of matching the container identifiers corresponding to each container in the cluster with the container matching rules, and determining the container to be deployed based on the matching results, includes: Extract the target space identifier from the service deployment request; The target memory space is determined based on the target space identifier; Obtain the container identifiers corresponding to each container in the target memory space; The container identifiers corresponding to each container in the target memory space are matched with the container matching rules, and the containers to be deployed are determined based on the matching results.

8. The service deployment method as described in claim 1, characterized in that, Before the step of adjusting the container environment of the container to be deployed based on the deployment environment parameters, the method further includes: Extract the service runtime identifier from the target service image; Detect whether the container background service corresponding to the service running identifier exists in the container to be deployed; If it exists, a service stop command is generated based on the service running identifier; The container background service corresponding to the service running identifier in the container to be deployed is terminated according to the service stop command. Upon successful termination, the step of adjusting the container environment of the container to be deployed based on the deployment environment parameters is executed.

9. The service deployment method as described in any one of claims 1-8, characterized in that, The step of adding the container to be deployed to the cluster service list when the image deployment is completed includes: When the image deployment is complete, the target service identifier is extracted from the target service image; Search the cluster service list according to the target service identifier to obtain the number of records corresponding to the target service identifier; Generate service index data based on the number of records; Generate a container service record based on the target service identifier, the service index data, and the container information corresponding to the container to be deployed; The container to be deployed is added to the cluster service list based on the container service record.

10. A service deployment apparatus, characterized in that, The service deployment device includes the following modules: The information extraction module is used to extract image file information and target container information from service deployment requests; The target determination module is used to obtain the target service image based on the image file information and determine the container to be deployed based on the target container information. The image deployment module is used to remove the container to be deployed from the cluster service list and deploy the container to be deployed according to the target service image. The service addition module is used to add the container to be deployed to the cluster service list when the image deployment is completed; The image deployment module is further configured to extract deployment environment parameters from the target service image; adjust the container environment of the container to be deployed according to the deployment environment parameters; and, upon completion of the adjustment, transfer the target service image to the container to be deployed so that the container to be deployed can perform image deployment based on the target service image. The target determination module is further configured to extract the image file information based on preset rules to obtain the encrypted access path and file storage path; decrypt the encrypted access path using a preset decryption algorithm to obtain the repository access path; and obtain the target service image based on the repository access path and the file storage path.

11. The service deployment apparatus as described in claim 10, characterized in that, The information extraction module is further configured to, upon receiving an image build request, extract the code access path and repository access path from the image build request; create a service build container and obtain the code to be deployed according to the code access path; pass the code to be deployed into the service build container so that the service build container performs image build based on the code to be deployed; and, upon completion of image build, extract the service image file generated by image build from the service build container and upload the service image file to the corresponding image repository according to the repository access path.

12. The service deployment apparatus as described in claim 11, characterized in that, The information extraction module is further configured to extract the service namespace from the image build request; create a service build container in the memory space corresponding to the service namespace; determine the code repository according to the code access path; and obtain the code to be deployed from the code repository according to the code access path.

13. The service deployment apparatus as described in claim 12, characterized in that, The information extraction module is also used to obtain the code repository identifier corresponding to the code repository; and to search for the corresponding repository access account and repository access password in the preset account table based on the code repository identifier. The code repository identifier is used to find the corresponding data combination rule in the preset repository rule table; a code retrieval request is generated based on the data combination rule, the repository access account, the repository access password, and the code access path; Based on the code retrieval request, the code to be deployed is retrieved from the code repository.

14. The service deployment apparatus as described in claim 13, characterized in that, The information extraction module is further configured to combine the warehouse access account, the warehouse access password, and the code access path according to the data combination rules to generate rule combination data; encrypt the rule combination data using a preset encryption algorithm to obtain data signature data; and construct a code acquisition request based on the data signature data, the warehouse access account, the warehouse access password, and the code access path.

15. The service deployment apparatus as described in claim 10, characterized in that, The target determination module is further configured to parse the target container information to obtain at least one container matching condition; construct a container matching rule based on the container matching condition; match the container identifiers corresponding to each container in the cluster with the container matching rule; and determine the container to be deployed based on the matching result.

16. A service deployment device, characterized in that, The service deployment device includes: a processor, a memory, and a service deployment program stored in the memory and executable on the processor, wherein when the service deployment program is executed by the processor, it implements the steps of the service deployment method as described in any one of claims 1-9.

17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a service deployment program, which, when executed by a processor, implements the steps of the service deployment method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Container application deployment method and device, computer equipment and storage medium

    CN108958927A

  • Server code deployment method and device, server apparatus and storage medium

    CN109324819A