Service deployment method and device
By detecting and modifying the container types in the deployment file, the frequent generation of deployment files caused by differences in installation environments of different hosts is solved, and the efficiency of service deployment is improved.
Patent Information
- Application Number
- CN202310652868.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-02
- Publication Date
- 2024-12-03
AI Technical Summary
When deploying the same service for different hosts, due to the large differences in installation environment, the deployment file needs to be regenerated each time, which takes a long time and is inefficient.
By detecting the installation environment of the host to be deployed, use it directly if there is an applicable deployment file. Otherwise, modify the container type in the deployment file to generate an applicable deployment file to avoid regenerating.
Reduces the time to generate deployment files, improves service deployment efficiency, and avoids the need to frequently regenerate deployment files due to differences in installation environments.
Smart Images

Figure CN119065779A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a service deployment method and device. Background Art
[0002] With the continuous development of computer technology, there is a way to deploy services for hosts through deployment platforms. When deploying services for hosts, the same service is usually deployed for different hosts through a deployment platform. Since the installation environments of different hosts are different, different installation environments correspond to different types of containers. Therefore, hosts with different installation environments correspond to different container types. Different types of containers require different deployment files to deploy the same service for the corresponding hosts, that is, hosts with different installation environments require different deployment files to deploy the same service for them.
[0003] In the prior art, when the same service is deployed for different hosts, the installation environment of the first host corresponds to the Kubernetes container. To deploy the service for the first host, it is necessary to configure the application information, version information and service information including the Kubernetes container corresponding to the service through the deployment platform. A deployment file including the Kubernetes container is generated through the above three information, and the service deployment of the first host is completed using the deployment file including the Kubernetes container. When the same service is deployed for the next host, the installation environment of the next host is different from that of the first host. The installation environment of the next host corresponds to the docker container. The deployment file of the first host cannot be used to install the same service for the next host. It is necessary to regenerate the deployment file including the docker container for the next host, and use the deployment file including the docker container to complete the service deployment of the next host.
[0004] Therefore, when deploying the same service for different hosts, the installation environments of different hosts vary greatly, so each time the same service is deployed for hosts with different installation environments, a deployment file needs to be regenerated. Regenerating a deployment file takes a long time, which makes the service deployment time longer and leads to low service deployment efficiency. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a service deployment method and device to solve the problem of low efficiency of service deployment.
[0006] In order to solve the above technical problems, the embodiments of the present application provide the following technical solutions:
[0007] A first aspect of the present application provides a service deployment method, the method comprising:
[0008] Upon receiving the deployment request, detecting whether there is an applicable first deployment file according to the installation environment of the host to be deployed, where the first deployment file is a file used by the generated deployment target service;
[0009] If it exists, deploy the target service for the host to be deployed using the first deployment file;
[0010] If it does not exist, modify the container type of the specified container in the first deployment file according to the installation environment to obtain a second deployment file;
[0011] The target service is deployed for the host to be deployed using the second deployment file.
[0012] A second aspect of the present application provides a service deployment device, the device comprising:
[0013] A detection module, configured to detect whether there is an applicable first deployment file according to the installation environment of the host to be deployed when receiving a deployment request, wherein the first deployment file is a file used by the generated deployment target service;
[0014] A first deployment module, configured to deploy the target service for the host to be deployed using the first deployment file if it exists;
[0015] a modification module, configured to modify the container type of the specified container in the first deployment file according to the installation environment if the container type does not exist, so as to obtain a second deployment file;
[0016] The second deployment module is used to deploy the target service for the host to be deployed using the second deployment file.
[0017] The third aspect of the present application provides an electronic device, which includes: at least one processor; and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the service deployment method of the above-mentioned first aspect or any optional embodiment of the first aspect.
[0018] A fourth aspect of the present application provides a computer-readable storage medium, the storage medium including a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the service deployment method of the above-mentioned first aspect or any optional embodiment of the first aspect.
[0019] Compared with the prior art, the service deployment method and device provided in the present application need to detect whether there is an applicable deployment file through the installation environment of the host to be deployed when there is a deployment request. If there is an applicable one, the deployment file is directly used to complete the deployment of the service. If there is no applicable one, the container type in the deployment file is modified to obtain an applicable deployment file, and the service deployment is completed through the modified applicable deployment file. In this way, when deploying the same service for different hosts with greatly different installation environments, it is only necessary to modify the container type of the container in the deployment file, and the service can be directly deployed through the modified applicable deployment file, without the need to regenerate the applicable deployment file, so that the time consumed in generating the deployment file is relatively short, thereby shortening the service deployment time and improving the efficiency of service deployment.
[0020] The service deployment device provided in the second aspect of the present application has the same beneficial effects as the service deployment method provided in the first aspect of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0022] Figure 1 A flow chart schematically illustrates a service deployment method;
[0023] Figure 2 A flow chart for determining a container type is schematically shown;
[0024] Figure 3 Schematically shows the structure of the service deployment device Figure 1 ;
[0025] Figure 4 Schematically shows the structure of the service deployment device Figure 2 ;
[0026] Figure 5 The structure diagram of an electronic device is schematically shown. DETAILED DESCRIPTION
[0027] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0028] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by technicians in the field to which this application belongs.
[0029] For service deployment, the prior art is that when deploying the same service for different hosts with different installation environments, the deployment file of the previous host cannot be used to install the same service for the next host. It is necessary to regenerate a deployment file containing the corresponding container for the next host, and use the deployment file containing the corresponding container to complete the service deployment of the next host. Because the installation environments of different hosts are greatly different when deploying the same service for different hosts in the prior art, each time the same service is deployed for hosts with different installation environments, a deployment file needs to be regenerated, and regenerating a deployment file takes a long time, which makes the service deployment time longer. Therefore, the present invention takes into account that when deploying the same service for different hosts with large installation environments, it is necessary to regenerate the deployment file, resulting in a relatively long consumption time for generating the deployment file, and a processing method that does not regenerate the deployment file is required. The processing method that consumes a relatively long time to generate the deployment file is replaced by the regeneration of the deployment file. For this reason, the present invention chooses a processing method that does not regenerate the deployment file. It only needs to modify the container type in the saved deployment file to obtain an applicable deployment file, so that the consumption time for generating the deployment file is relatively short, thereby shortening the service deployment time. The main idea of the present invention is to detect whether there is an applicable deployment file through the installation environment of the host to be deployed when there is a deployment request. If there is an applicable one, the deployment file is directly used to complete the deployment of the service. If there is no applicable one, the container type in the deployment file is modified and the service deployment is completed through the modified deployment file.
[0030] The method in the embodiment of the present invention is described in detail below.
[0031] Figure 1 A flow chart schematically shows a service deployment method in an embodiment of the present invention, see Figure 1 As shown, the method may include:
[0032] S101. When a deployment request is received, detecting whether there is an applicable first deployment file according to the installation environment of the host to be deployed.
[0033] The first deployment file is a file used by the generated deployment target service.
[0034] When deploying the same service for different hosts, the installation environments of the hosts where the service needs to be deployed may be the same or different. Different installation environments correspond to different types of containers. Different types of containers require different deployment files to deploy the same service for the corresponding hosts, that is, hosts with different installation environments require different deployment files to deploy the same service for them, that is, different installation environments correspond to different deployment files, and the same installation environments correspond to the same deployment files. Upon receiving a deployment request, the deployment platform will save each generated deployment file before detecting whether there is an applicable first deployment file based on the installation environment of the host to be deployed. Upon receiving a deployment request, the installation environment of the host to be deployed can be used to detect whether there is a deployment file corresponding to the installation environment of the host to be deployed, that is, the first deployment file applicable to the installation environment of the host to be deployed, among the multiple saved deployment files.
[0035] When a deployment request is received, it is detected whether there is an applicable first deployment file according to the installation environment of the host to be deployed. If so, step S102 is executed, and if not, step S103 is executed.
[0036] S102: Deploy a target service for a host to be deployed using the first deployment file.
[0037] Specifically, when the first deployment file applicable to the installation environment of the host to be deployed is detected according to step S101, the target service is deployed for the host to be deployed using the first deployment file. Since the same installation environment corresponds to the same type of container, the same type of container requires the same deployment file to deploy the same service for the corresponding host. Therefore, the existence of the first deployment file applicable to the installation environment of the host to be deployed indicates that the container type of the container in the first deployment file is the same as the container type of the container adapted to the installation environment of the host to be deployed, and the first deployment file can be used to deploy the service for the host to be deployed.
[0038] If there is a first deployment file suitable for the installation environment of the host to be deployed, the target service is deployed to the host to be deployed directly through the saved first deployment file, avoiding regenerating the deployment file. This saves the time consumed in generating the deployment file and shortens the service deployment time.
[0039] S103: Modify the container type of the specified container in the first deployment file according to the installation environment to obtain a second deployment file.
[0040] Specifically, when the first deployment file applicable to the installation environment of the host to be deployed does not exist according to the detection in step S101, the container type of the container specified in the first deployment file is modified according to the installation environment to obtain the second deployment file.
[0041] Since different installation environments correspond to different types of containers, and different types of containers require different deployment files to deploy the same service for the corresponding hosts, there is no first deployment file suitable for the installation environment of the host to be deployed, indicating that the container type of the container in the first deployment file is different from the container type adapted to the installation environment of the host to be deployed. The first deployment file cannot be used to deploy the service for the host to be deployed. The container type of the container specified in the first deployment file needs to be modified to a container type suitable for the installation environment to obtain a second deployment file.
[0042] The data formats of files corresponding to deployment files of the same container type are the same, and the data formats of files corresponding to deployment files of different container types are different.
[0043] The data format of the second deployment file is different from the data format of the first deployment file.
[0044] S104: Deploy the target service for the host to be deployed using the second deployment file.
[0045] Specifically, the second deployment file obtained in step S103 is used to deploy the target service for the host to be deployed.
[0046] A new deployment file is obtained by modifying the container type of the specified container in the first deployment file. The new deployment file is a deployment file suitable for the installation environment of the host to be deployed. Through this deployment file, a target service can be deployed for the host to be deployed.
[0047] Based on the above Figure 1 It can be seen from the implementation method that the embodiment of the present invention screens the deployment files through the installation environment. When the applicable deployment files cannot be screened out, the container type of the container in the deployment file is modified to achieve the purpose of quickly generating the applicable deployment files. When a deployment file that is not applicable to the installation environment of the host to be deployed is detected, it is only necessary to modify the container type in the saved deployment file to obtain the applicable deployment file. There is no need to regenerate the deployment file, which shortens the time consumed in generating the deployment file, thereby shortening the service deployment time and improving the efficiency of service deployment.
[0048] Further, as a refinement and extension of the above step S101, that is, a refinement and extension of the operation method of detecting whether there is an applicable first deployment file according to the installation environment of the host to be deployed, by searching for the same installation environment as the installation environment of the host to be deployed in the established correspondence between the generated deployment file and the installation environment of the corresponding host, the deployment file corresponding to the same installation environment is determined as the applicable deployment file, so that the applicable deployment file can be determined by simply searching for the same installation environment in the correspondence, and the applicable deployment file can be directly obtained to achieve service deployment, so that the speed of deploying the service is faster and the efficiency of service deployment is improved. Specifically, the above step S101 may include:
[0049] Step A1: In the first correspondence between the generated deployment file and the installation environment of the corresponding host, it is searched whether there is an installation environment that is the same as the installation environment of the host to be deployed.
[0050] Hosts with different installation environments require different deployment files to deploy the same service for them. A first correspondence between the generated deployment files and the installation environments of the corresponding hosts can be established. In the first correspondence between the generated deployment files and the installation environments of the corresponding hosts, it is necessary to search whether there is an installation environment that is the same as the installation environment of the host to be deployed.
[0051] Exemplarily, the installation environments of the four hosts for which deployment files have been generated are different. The installation environment of host 1 corresponds to the Windows system, the installation environment of host 2 corresponds to the Linux system, the installation environment of host 3 corresponds to the Android system, and the installation environment of host 4 corresponds to the Apple system. The generated deployment files corresponding to the installation environments of the four hosts are deployment file 1, deployment file 2, deployment file 3, and deployment file 4, respectively. The installation environment of host 11 to be deployed corresponds to the Windows system. A correspondence relationship 1 is established between deployment file 1 and the Windows system corresponding to the installation environment of host 1, a correspondence relationship 2 is established between deployment file 2 and the Linux system corresponding to the installation environment of host 2, a correspondence relationship 3 is established between deployment file 3 and the Android system corresponding to the installation environment of host 3, and a correspondence relationship 4 is established between deployment file 4 and the Apple system corresponding to the installation environment of host 4.
[0052] In the first correspondence between the generated deployment file and the corresponding host installation environment, it is searched whether there is an installation environment that is the same as the installation environment of the host to be deployed. If so, step A2 is executed; if not, step A3 is executed.
[0053] Step A2: Determine the generated deployment file corresponding to the installation environment that is the same as the installation environment of the host to be deployed as the applicable first deployment file.
[0054] Specifically, when there is an installation environment that is the same as the installation environment of the host to be deployed found in step A1, the generated deployment file corresponding to the installation environment that is the same as the installation environment of the host to be deployed is determined as the applicable first deployment file.
[0055] When there is an applicable first deployment file, the first deployment file can be used to deploy the target service for the host to be deployed.
[0056] Continuing with the example of step A1, in correspondence 1, correspondence 2, correspondence 3 and correspondence 4, search for the Windows system corresponding to the installation environment that is the same as the installation environment of the host 11 to be deployed, and determine the deployment file 1 corresponding to the Windows system as the applicable deployment file.
[0057] Step A3: Determine that there is no applicable first deployment file.
[0058] Specifically, when there is no installation environment that is the same as the installation environment of the host to be deployed according to the search in step A1, it is determined that there is no applicable first deployment file.
[0059] When there is no applicable first deployment file, it is necessary to modify the inapplicable first deployment file to obtain an applicable deployment file. Specifically, the container type of the container specified in the first deployment file is modified according to the installation environment to obtain a second deployment file. The second deployment file is used to deploy the target service for the host to be deployed.
[0060] Exemplarily, the installation environments of the two hosts for which deployment files have been generated are that the installation environment of host a corresponds to the Android system, and the installation environment of host b corresponds to the Linux system. The generated deployment files corresponding to the installation environments of the two hosts are deployment file a and deployment file b, respectively, and the installation environment of the host 11 to be deployed corresponds to the Windows system. A correspondence relationship a is established between the deployment file a and the Android system corresponding to the installation environment of host a, and a correspondence relationship b is established between the deployment file b and the Linux system corresponding to the installation environment of host b. In the correspondence relationship a and the correspondence relationship b, it is searched that there is no installation environment that is the same as the installation environment of the host 11 to be deployed, and it is determined that there is no applicable first deployment file.
[0061] Furthermore, as a Figure 1In step S103, the container type of the container specified in the first deployment file is modified according to the installation environment to obtain the refinement and extension of the operation method of the second deployment file. By obtaining the recording file of the correspondence between all installation environments and corresponding container types, the first container type corresponding to the installation environment of the host to be deployed can be determined. It is only necessary to modify the container type of the container specified in the first deployment file to the first container type to obtain the deployment file of the host to be deployed. There is no need to reconfigure and generate the deployment file. It can be used directly after the modification. In this way, the speed of generating the deployment file is fast.
[0062] Figure 2 For a flowchart of determining the container type in the embodiment of the present application, see Figure 2 As shown, the above step S103 may include:
[0063] Step S1031: Determine a first container type corresponding to the installation environment of the host to be deployed according to the second correspondence between all installation environments and corresponding container types.
[0064] Different installation environments correspond to different types of containers. A second correspondence between all installation environments and corresponding container types can be established. Based on the second correspondence between all installation environments and corresponding container types, the first container type corresponding to the installation environment of the host to be deployed is determined.
[0065] According to the second correspondence between all installation environments and corresponding container types, determining the first container type corresponding to the installation environment of the host to be deployed is specifically: finding the installation environment that is the same as the installation environment of the host to be deployed in the second correspondence, and determining the container type corresponding to this installation environment as the first container type corresponding to the installation environment of the host to be deployed.
[0066] Exemplarily, there are 4 installation environments, namely, installation environment A, installation environment B, installation environment C, and installation environment D. Installation environment A corresponds to the Windows system, installation environment B corresponds to the Linux system, installation environment C corresponds to the Android system, and installation environment D corresponds to the Apple system. The installation environment of the host 11 to be deployed corresponds to the Windows system. The container types corresponding to the Windows system are the Kubernetes container type, the docker container type, and the moebius container type. The container types corresponding to the Linux system are the Kubernetes container type and the docker container type. The container type corresponding to the Android system is the Kubernetes container type, and the container type corresponding to the Apple system is the docker container type. A corresponding relationship Aa between the Windows system and the Kubernetes container type, the docker container type, and the moebius container type corresponding to the installation environment A is established. A corresponding relationship Bb between the Linux system and the Kubernetes container type and the docker container type corresponding to the installation environment B is established. A corresponding relationship Cc between the Android system and the Kubernetes container type corresponding to the installation environment C is established. A corresponding relationship Dd between the Apple system and the docker container type corresponding to the installation environment D is established. In the corresponding relationships Aa, Bb, Cc and Dd, it is determined that the first container type corresponding to the Windows system corresponding to the installation environment of the host 11 to be deployed is a Kubernetes container type, a docker container type and a moebius container type.
[0067] Step S1032: Parse the container type of at least one specified container in the first deployment file.
[0068] Different designated containers correspond to different container types.
[0069] The first deployment files corresponding to different installation environments may contain one or more container types that specify containers, and it is necessary to parse out the container type of at least one specified container in the first deployment file.
[0070] Exemplarily, if the first deployment file is a file corresponding to the Windows system, the container types in the first deployment file a1 corresponding to the Windows system are Kubernetes container type, docker container type, and moebius container type, and it is necessary to parse out that the container types of the three specified containers in the first deployment file a1 are Kubernetes container type, docker container type, and moebius container type. If the first deployment file is a file corresponding to the Android system, the container type in the first deployment file a2 corresponding to the Android system is the Kubernetes container type, and it is necessary to parse out that the container type of one specified container is the Kubernetes container type.
[0071] Step S1033: Determine whether the first container type exists in the container types of at least one specified container.
[0072] Specifically, it is determined whether the first container type exists in the container type of at least one specified container parsed in step S1032. It is determined whether the first container type exists in the container type of at least one specified container, if yes, step S1034 is executed, if no, step S1035 is executed.
[0073] Step S1034: The container type of at least one specified container is not modified.
[0074] Specifically, when the container type of the at least one designated container determined in step S1033 includes the first container type, the container type of the at least one designated container is not modified.
[0075] Continuing with the example of step S1032, the installation environment of the host 11 to be deployed corresponds to the Linux system, and the container types corresponding to the Linux system are the Kubernetes container type and the docker container type. It is determined that the container types in the first deployment file a1 are the Kubernetes container type, the docker container type, and the moebius container type. If there are Kubernetes container types and docker container types, the Kubernetes container type, the docker container type, and the moebius container type in the first deployment file a1 are not modified.
[0076] Step S1035: modify the container type of at least one specified container to the first container type, and obtain a second deployment file.
[0077] Specifically, when the first container type does not exist in the container type of the at least one specified container determined in step S1033, the container type of the at least one specified container is modified to the first container type to obtain the second deployment file.
[0078] Exemplarily, the installation environment of the host 11 to be deployed corresponds to the Android system, and the container type corresponding to the Android system is the Kubernetes container type. If the first deployment file is a file corresponding to the Apple system, the container type in the first deployment file b1 corresponding to the Apple system is the docker container type. It is determined that the container type in the first deployment file b1 is the docker container type, and there is no Kubernetes container type. The docker container type in the first deployment file b1 is modified to the Kubernetes container type to obtain the second deployment file, which is a deployment file containing a Kubernetes container.
[0079] The data formats of the files corresponding to the deployment files of the same container type are the same, and the data formats of the files corresponding to the deployment files of different container types are different. The deployment files of the corresponding data formats can be determined according to the container type. For example, the data format of the files corresponding to the deployment files of the Kubernetes container type is the Helm data format file or the Yaml data format file. If the customer has modification requirements, the Yaml data format file is exported. If there is no requirement, the helm data format file is exported. The data format of the files corresponding to the deployment files of the docker container type is the docker-compose data format file.
[0080] Furthermore, as a refinement and extension of the above-mentioned step S1035, that is, to modify the container type of at least one specified container to the first container type, and obtain the refinement and extension of the operation method of the second deployment file, it is only necessary to modify one of the three information in the generated deployment file, namely, the container type of the service information, to obtain new service information. For other application information and version information, there is no need to reconfigure, only need to obtain them directly for generation. In this way, there is no need to reconfigure all three information to regenerate the deployment file. Only one service information needs to be changed, and the original application information and version information need to be obtained to generate the deployment file, so that the speed of generating the deployment file is faster, the efficiency of generating the deployment file is improved, and the efficiency of service deployment is improved.
[0081] Specifically, the above step S1035 may include:
[0082] Step B1: modify the container type of at least one designated container in the service information to a first container type to obtain new service information.
[0083] The first deployment file includes application information and version information corresponding to the target service and service information of a container type including a specified container.
[0084] The service information mainly includes the service name, number of copies, container, container type, container name, mirror address, and service port number. When there is only one container type for the specified container in the service information, this container type is modified to the first container type to obtain new service information; when there are multiple container types for the specified container in the service information, any one of the multiple container types can be modified to the first container type to obtain new service information, or all of the multiple container types can be modified to the first container type to obtain new service information. By modifying all container types to the first container type, only deployment files in the data format corresponding to the first container type can be generated, and deployment files in the data formats corresponding to other container types will not be generated.
[0085] Step B2: Generate a second deployment file according to the application information, version information and new service information.
[0086] Specifically, a second deployment file is generated according to the application information, the version information and the new service information obtained in step B1.
[0087] Application information mainly includes application name, application description, application source, application type, project, application icon and whether it has been released to the market. Version information mainly includes version number, version description, version type, CPU architecture and deployment method.
[0088] The second deployment file is generated by obtaining new service information through the application information and version information that have been configured in the first deployment file and by modifying the container type of at least one specified container to the first container type.
[0089] The first deployment file that has been generated needs to configure application information, version information, and service information first. The application information is configured by configuring the application name, application description, application source, application type, project, application icon, and whether to publish to the market. The version information is configured by configuring the version number, version description, version type, CPU architecture, and deployment method. The service information is configured by configuring the service name, number of copies, container, container type, container name, mirror address, and service port number. The first deployment file is generated based on the configured application information, version information, and service information.
[0090] Furthermore, as a refinement and extension of the above-mentioned step S104, that is, using the second deployment file to refine and extend the operation method of deploying the target service to the host to be deployed, by determining the deployment command corresponding to the container type of different deployment files, the service deployment is implemented by executing the deployment command through the first container in the second deployment file, and there is no need to try one by one from multiple commands to determine the deployment command, which makes the speed of deploying the service faster.
[0091] Specifically, the above step S104 may include:
[0092] Step C1: According to the first container type in the second deployment file, obtain the corresponding deployment command.
[0093] Different container types correspond to different deployment commands. Before obtaining the corresponding deployment command according to the first container type in the second deployment file, the correspondence between the container type and the corresponding deployment command is saved, and the deployment command corresponding to the first container type in the second deployment file is obtained through the correspondence.
[0094] Exemplarily, the deployment command corresponding to the Kubernetes container type is the helm install multiappmultiapp command, or the kubectl apply-k command, and the deployment command corresponding to the docker container type is the docker-compose up-d command. The correspondence AA between the Kubernetes container type and the helm install multiapp multiapp command and the kubectl apply-k command is determined, and the correspondence BB between the docker container type and the docker-compose up-d command is determined. The first container type in the second deployment file is the docker container type. In the correspondence AA and the correspondence BB, the deployment command corresponding to the docker container type in the second deployment file is obtained as the docker-compose up-d command.
[0095] Step C2: Execute the deployment command through the first container in the second deployment file to deploy the target service for the host to be deployed.
[0096] Specifically, the first container in the second deployment file obtained in step C1 executes the deployment command to deploy the target service for the host to be deployed.
[0097] The deployment command is executed by starting the first container in the second deployment file to deploy the target service for the host to be deployed.
[0098] Continuing with the example of step C1, the data format corresponding to the second deployment file is a Docker-Compose data format file, and the docker-compose up-d command is executed by starting the docker container in the second deployment file in the Docker-Compose data format to deploy the target service for the host to be deployed.
[0099] Based on the same inventive concept, as an implementation of the above service deployment method, an embodiment of the present invention further provides a service deployment device. Figure 3The structure of the device in the embodiment of the present invention is Figure 1 , see Figure 3 As shown, the device may include:
[0100] A detection module 301 is used to detect whether there is an applicable first deployment file according to the installation environment of the host to be deployed when receiving a deployment request, where the first deployment file is a file used by the generated deployment target service;
[0101] A first deployment module 302 is configured to deploy the target service for the host to be deployed using the first deployment file if the detection module 301 detects that there is a first deployment file applicable to the installation environment of the host to be deployed;
[0102] A modification module 303 is configured to modify the container type of the specified container in the first deployment file according to the installation environment to obtain a second deployment file if the detection module 301 detects that there is no first deployment file applicable to the installation environment of the host to be deployed;
[0103] The second deployment module 304 is used to deploy the target service for the host to be deployed using the second deployment file obtained by the modification module 303.
[0104] exist Figure 3 Based on the present invention, another embodiment of the device is provided, see Figure 4 As shown, Figure 4 The structure of the device in the embodiment of the present invention is Figure 2 , the device may include:
[0105] The detection module 301 includes:
[0106] A searching unit 3011 is used to search, in a first correspondence between a generated deployment file and an installation environment of a corresponding host, whether there is an installation environment that is the same as the installation environment of the host to be deployed;
[0107] The first determining unit 3012 is configured to determine the generated deployment file corresponding to the installation environment that is the same as the installation environment of the host to be deployed as the applicable first deployment file if the searching unit 3011 finds that there is an installation environment that is the same as the installation environment of the host to be deployed;
[0108] The second determining unit 3013 is configured to determine that there is no applicable first deployment file if the searching unit 3011 finds that there is no installation environment identical to the installation environment of the host to be deployed.
[0109] Further, the modification module 303 includes:
[0110] The third determining unit 3031 is used to determine the first container type corresponding to the installation environment of the host to be deployed according to the second correspondence between all installation environments and corresponding container types;
[0111] A parsing unit 3032, configured to parse a container type of at least one specified container in the first deployment file, where different specified containers correspond to different container types;
[0112] A judging unit 3033 is configured to judge whether the first container type exists in the container type of the at least one specified container parsed by the parsing unit 3032;
[0113] A first modifying unit 3034 is configured to not modify the container type of the at least one specified container if the container type of the at least one specified container determined by the determining unit 3033 includes the first container type;
[0114] The second modifying unit 3035 is configured to modify the container type of the at least one specified container to the first container type if the first container type does not exist in the container type of the at least one specified container determined by the determining unit 3033, so as to obtain a second deployment file.
[0115] The second modification unit is specifically used to modify the container type of the at least one specified container in the service information to the first container type to obtain new service information; generate a second deployment file according to the application information, the version information and the new service information, wherein the first deployment file includes the application information, version information and service information of the container type including the specified container corresponding to the target service.
[0116] Furthermore, the second deployment module 304 includes:
[0117] The acquisition unit 3041 is used to acquire a corresponding deployment command according to the first container type in the second deployment file;
[0118] The execution unit 3042 is used to execute the deployment command through the first container in the second deployment file to deploy the target service for the host to be deployed.
[0119] Based on the same inventive concept, an embodiment of the present invention further provides an electronic device. Figure 5 is a structural diagram of an electronic device in an embodiment of the present invention, see Figure 5As shown, the electronic device 50 may include: at least one processor 501; and at least one memory 502 and a bus 503 connected to the processor 501; wherein the processor 501 and the memory 502 communicate with each other through the bus 503; the processor 501 is used to call the program instructions in the memory 502 to execute the service deployment method in one or more of the above-mentioned embodiments.
[0120] It should be noted that the description of the above service deployment device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiment of the service deployment device of the embodiment of the present invention, please refer to the description of the method embodiment of the present invention for understanding.
[0121] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the method in one or more of the above embodiments.
[0122] It should be noted here that the description of the above computer-readable storage medium embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiment of the computer-readable storage medium of the embodiment of the present invention, please refer to the description of the method embodiment of the present invention for understanding.
[0123] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A service deployment method, characterized in that: The method comprises: Upon receiving the deployment request, detecting whether there is an applicable first deployment file according to the installation environment of the host to be deployed, where the first deployment file is a file used by the generated deployment target service; If it exists, deploy the target service for the host to be deployed using the first deployment file; If it does not exist, modify the container type of the specified container in the first deployment file according to the installation environment to obtain a second deployment file; The target service is deployed for the host to be deployed using the second deployment file.
2. The method according to claim 1, characterized in that: The detecting whether there is an applicable first deployment file according to the installation environment of the host to be deployed includes: In the first correspondence between the generated deployment file and the installation environment of the corresponding host, searching whether there is an installation environment that is the same as the installation environment of the host to be deployed; If so, determining the generated deployment file corresponding to the installation environment that is the same as the installation environment of the host to be deployed as the applicable first deployment file; If not present, it is determined that there is no applicable first deployment file.
3. The method according to claim 1, characterized in that The step of modifying the container type of the specified container in the first deployment file according to the installation environment to obtain the second deployment file includes: Determine, according to a second correspondence between all installation environments and corresponding container types, a first container type corresponding to the installation environment of the host to be deployed; Parsing a container type of at least one specified container in the first deployment file, where different specified containers correspond to different container types; Determining whether the first container type exists in the container types of the at least one specified container; If present, the container type of the at least one specified container is not modified; If it does not exist, the container type of the at least one specified container is modified to the first container type to obtain a second deployment file.
4. The method according to claim 3, characterized in that The first deployment file includes application information, version information, and service information including a container type of the specified container corresponding to the target service, and the container type of the at least one specified container is modified to the first container type to obtain a second deployment file, including: Modify the container type of the at least one specified container in the service information to the first container type to obtain new service information; A second deployment file is generated according to the application information, the version information and the new service information.
5. The method according to claim 3, characterized in that: The step of deploying the target service for the host to be deployed by using the second deployment file includes: According to the first container type in the second deployment file, obtain a corresponding deployment command; The deployment command is executed through the first container in the second deployment file to deploy the target service for the host to be deployed.
6. A service deployment device, characterized in that: The device comprises: A detection module, configured to detect whether there is an applicable first deployment file according to the installation environment of the host to be deployed when receiving a deployment request, wherein the first deployment file is a file used by the generated deployment target service; A first deployment module, configured to deploy the target service for the host to be deployed using the first deployment file if it exists; a modification module, configured to modify the container type of the specified container in the first deployment file according to the installation environment if the container type does not exist, so as to obtain a second deployment file; The second deployment module is used to deploy the target service for the host to be deployed using the second deployment file.
7. The device according to claim 6, characterized in that The detection module comprises: A searching unit, configured to search, in a first correspondence between a generated deployment file and an installation environment of a corresponding host, whether there is an installation environment that is the same as the installation environment of the host to be deployed; A first determining unit, configured to determine, if any, a generated deployment file corresponding to the same installation environment as the installation environment of the host to be deployed as an applicable first deployment file; The second determining unit is used to determine that there is no applicable first deployment file if the first deployment file does not exist.
8. The device according to claim 6, characterized in that The modification module comprises: A third determining unit, configured to determine, according to a second correspondence between all installation environments and corresponding container types, a first container type corresponding to the installation environment of the host to be deployed; A parsing unit, configured to parse a container type of at least one specified container in the first deployment file, where different specified containers correspond to different container types; A judging unit, configured to judge whether the first container type exists in the container types of the at least one specified container; a first modification unit, configured to not modify the container type of the at least one specified container, if present; The second modification unit is configured to modify the container type of the at least one specified container to the first container type if the first container type does not exist, so as to obtain a second deployment file.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and at least one memory and bus connected to the processor; The processor and the memory communicate with each other via the bus; the processor is used to call program instructions in the memory to execute the service deployment method as described in any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the service deployment method according to any one of claims 1 to 5.
