Application upgrading method and device, equipment and computer readable storage medium
By executing upgrade scripts within containers, the high development cost of upgrade interfaces for bare-metal applications is resolved. This enables application upgrades without the need for dedicated interfaces, reducing development costs and minimizing coupling.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
- Filing Date
- 2022-06-27
- Publication Date
- 2026-07-21
AI Technical Summary
In business scenarios where bare-metal applications and containerized applications coexist, existing technologies require the development and upgrade of interfaces through software platforms, resulting in high R&D costs and excessive coupling.
By obtaining the target container image and container configuration file, a target upgrade container is created, and an upgrade script is executed within it. This leverages the automatic execution feature of containers to upgrade applications, avoiding the need to develop a dedicated upgrade interface.
It reduced R&D costs, enabled seamless upgrades of bare-metal deployed applications, and reduced coupling with the platform.
Smart Images

Figure CN114936036B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of container technology, and more particularly to an application upgrade method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] As product architectures become increasingly complex, some applications in all-in-one machine projects cannot be deployed using containers, such as status applications and hardware information acquisition applications. This leads to business scenarios where bare-metal applications and containerized applications coexist. Currently, upgrading bare-metal applications requires a software platform. The drawback of this approach is that the software platform needs to develop interfaces for application upgrades, which can result in high coupling between the interface functionality and the application, increasing development costs. Summary of the Invention
[0003] The main objective of this invention is to provide an application upgrade method, apparatus, device, and computer-readable storage medium, aiming to propose an upgrade scheme for bare-metal deployment applications based on container technology, which eliminates the need to develop corresponding upgrade interfaces for different applications, thereby reducing R&D costs.
[0004] To achieve the above objectives, the present invention provides an application upgrade method, the method comprising the following steps:
[0005] Obtain the target container image, which is created by packaging the upgrade script and upgrade files of the application to be upgraded;
[0006] Obtain a container configuration file for creating a target upgrade container, wherein the container configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container;
[0007] The target upgrade container is created based on the target container image and the container configuration file, and the upgrade script, which serves as a startup script, is executed in the target upgrade container to upgrade the application to be upgraded using the upgrade file.
[0008] Optionally, the container configuration file may also include a mapping between the target upgrade container's directory and the host machine's directory;
[0009] The step of upgrading the application to be upgraded by executing the upgrade script using the upgrade file includes:
[0010] The upgrade script is executed to locate the host directory according to the mapping relationship. The storage location of the application file of the application to be upgraded is obtained by locating the host directory. The upgrade file is then used to update the application file stored in the storage location in order to upgrade the application to be upgraded.
[0011] Optionally, the container configuration file may further include namespace configuration information, which is used to configure the target upgrade container and the host machine to share a namespace;
[0012] The step of upgrading the application to be upgraded by executing the upgrade script using the upgrade file includes:
[0013] The application files of the application to be upgraded are updated using the upgrade file by executing the upgrade script.
[0014] The upgrade script is executed to query the application process information of the application to be upgraded from the process information of the host machine for the first time.
[0015] If the application process information of the application to be upgraded is found for the first time, the application process of the application to be upgraded is terminated by executing the upgrade script;
[0016] The upgrade script is executed to query the application process information of the application to be upgraded from the process information of the host machine again.
[0017] If the application process information of the application to be upgraded is found again within the preset time period, the upgrade of the application to be upgraded is confirmed to be completed.
[0018] Optionally, the method further includes:
[0019] The application process status of the application to be upgraded is queried periodically, and the application process of the application to be upgraded is restarted when it is detected that the application process of the application to be upgraded is in a terminated state.
[0020] Optionally, the method further includes:
[0021] If the application process information of the application to be upgraded is not found on the first attempt, or if the application process information of the application to be upgraded is not found again within a preset time period, then return to the step of creating the target upgrade container based on the target container image and the container configuration file.
[0022] Optionally, the application upgrade method is applied to a cloud platform deployed on a host machine, and the step of obtaining the target container image includes:
[0023] Obtain the upgrade script and upgrade file of the application to be upgraded uploaded by the user terminal, and package the upgrade script and upgrade file to create a target container image; or,
[0024] Obtain the target container image uploaded by the user terminal, wherein the target container image is created by packaging the upgrade script and the upgrade file of the application to be upgraded.
[0025] Optionally, the application upgrade method is applied to a cloud platform deployed on a host machine, and the step of obtaining the container configuration file used to create the target upgrade container includes:
[0026] Obtain the container configuration file uploaded by the user terminal for creating the target upgrade container; or,
[0027] Obtain the container configuration file used to create the target upgrade container, which is orchestrated based on the online orchestration function provided by the cloud platform in the user terminal.
[0028] To achieve the above objectives, the present invention also provides an application upgrade device, the application upgrade device comprising:
[0029] The first acquisition module is used to acquire the target container image, which is created by packaging the upgrade script and upgrade files of the application to be upgraded.
[0030] The second acquisition module is used to acquire a container configuration file for creating a target upgrade container, wherein the container configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container;
[0031] An upgrade module is used to create a target upgrade container based on the target container image and the container configuration file, and to execute the upgrade script, which serves as a startup script, in the target upgrade container to upgrade the application to be upgraded using the upgrade file.
[0032] To achieve the above objectives, the present invention also provides an application upgrade device, the application upgrade device comprising: a memory, a processor, and an application upgrade program stored in the memory and executable on the processor, wherein the application upgrade program, when executed by the processor, implements the steps of the application upgrade method as described above.
[0033] Furthermore, to achieve the above objectives, the present invention also proposes a computer-readable storage medium storing an application upgrade program, which, when executed by a processor, implements the steps of the application upgrade method described above.
[0034] In this invention, a target container image is obtained, which is created by packaging the upgrade script and upgrade files of the application to be upgraded. A container configuration file for creating the target upgrade container is also obtained. This configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container. The target upgrade container is created based on the target container image and the container configuration file. The upgrade script, serving as the startup script, is executed within the target upgrade container, and the upgrade files are used to upgrade the application to be upgraded. This invention, by configuring the upgrade script of the application to be upgraded as the startup script of the container, and leveraging the feature that the startup script is automatically executed after container creation, allows for application upgrades without the need to develop corresponding upgrade interfaces for different applications, thus reducing development costs. Attached Figure Description
[0035] Figure 1 This is a schematic diagram of the hardware operating environment involved in the embodiments of the present invention;
[0036] Figure 2 This is a flowchart illustrating the first embodiment of the application upgrade method of the present invention;
[0037] Figure 3 This is a schematic diagram of an application upgrade system architecture according to an embodiment of the application upgrade method of the present invention;
[0038] Figure 4 This is a schematic diagram of an application upgrade process according to an embodiment of the application upgrade method of the present invention;
[0039] Figure 5 This is a schematic diagram of the functional modules of a preferred embodiment of the application upgrade device of the present invention.
[0040] 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
[0041] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0042] like Figure 1 As shown, Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of the present invention.
[0043] It should be noted that the upgrade device used in this embodiment of the invention can be a smartphone, personal computer, server, or other similar device, and no specific limitations are imposed here. At least one first camera unit is installed at the entrance of the cleaning area of the construction site, and at least one second camera unit is installed at the exit of the cleaning area.
[0044] like Figure 1 As shown, the application upgrade device may include: a processor 1001, such as a CPU; a network interface 1004; a user interface 1003; a memory 1005; and a communication bus 1002. 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 Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as a disk drive. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0045] Those skilled in the art will understand that Figure 1 The device structure shown does not constitute a limitation on the application upgrade device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0046] like Figure 1 As shown, the memory 1005, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application upgrade program. The operating system is a program that manages and controls the device's hardware and software resources, supporting the operation of application upgrade programs and other software or programs. Figure 1 In the device shown, the user interface 1003 is mainly used for data communication with the client; the network interface 1004 is mainly used for establishing a communication connection with the server; and the processor 1001 can be used to call the application upgrade program stored in the memory 1005 and perform the following operations:
[0047] Obtain the target container image, which is created by packaging the upgrade script and upgrade files of the application to be upgraded;
[0048] Obtain a container configuration file for creating a target upgrade container, wherein the container configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container;
[0049] The target upgrade container is created based on the target container image and the container configuration file, and the upgrade script, which serves as a startup script, is executed in the target upgrade container to upgrade the application to be upgraded using the upgrade file.
[0050] Furthermore, the container configuration file also includes a mapping relationship between the target upgrade container's directory and the host machine's directory;
[0051] The operation of upgrading the application to be upgraded by executing the upgrade script and using the upgrade file includes:
[0052] The upgrade script is executed to locate the host directory according to the mapping relationship. The storage location of the application file of the application to be upgraded is obtained by locating the host directory. The upgrade file is then used to update the application file stored in the storage location in order to upgrade the application to be upgraded.
[0053] Furthermore, the container configuration file also includes namespace configuration information, which is used to configure the target upgrade container and the host machine to share a namespace;
[0054] The operation of upgrading the application to be upgraded by executing the upgrade script and using the upgrade file includes:
[0055] The application files of the application to be upgraded are updated using the upgrade file by executing the upgrade script.
[0056] The upgrade script is executed to query the application process information of the application to be upgraded from the process information of the host machine for the first time.
[0057] If the application process information of the application to be upgraded is found for the first time, the application process of the application to be upgraded is terminated by executing the upgrade script;
[0058] The upgrade script is executed to query the application process information of the application to be upgraded from the process information of the host machine again.
[0059] If the application process information of the application to be upgraded is found again within the preset time period, the upgrade of the application to be upgraded is confirmed to be completed.
[0060] Furthermore, the processor 1001 can also be used to call the application upgrade program stored in the memory 1005 and perform the following operations:
[0061] The application process status of the application to be upgraded is queried periodically, and the application process of the application to be upgraded is restarted when it is detected that the application process of the application to be upgraded is in a terminated state.
[0062] Furthermore, the processor 1001 can also be used to call the application upgrade program stored in the memory 1005 and perform the following operations:
[0063] If the application process information of the application to be upgraded is not found on the first query, or if the application process information of the application to be upgraded is not found again within a preset time period, then the operation of creating the target upgrade container based on the target container image and the container configuration file will be returned.
[0064] Furthermore, the application upgrade method is applied to a cloud platform deployed on a host machine, and the operation of obtaining the target container image includes:
[0065] Obtain the upgrade script and upgrade file of the application to be upgraded uploaded by the user terminal, and package the upgrade script and upgrade file to create a target container image; or,
[0066] Obtain the target container image uploaded by the user terminal, wherein the target container image is created by packaging the upgrade script and the upgrade file of the application to be upgraded.
[0067] Furthermore, the application upgrade method is applied to a cloud platform deployed on a host machine, and the operation of obtaining the container configuration file used to create the target upgrade container includes:
[0068] Obtain the container configuration file uploaded by the user terminal for creating the target upgrade container; or,
[0069] Obtain the container configuration file used to create the target upgrade container, which is orchestrated based on the online orchestration function provided by the cloud platform in the user terminal.
[0070] Based on the above structure, various embodiments of the application upgrade method are proposed.
[0071] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the application upgrade method of the present invention.
[0072] This invention provides an embodiment of an application upgrade method. It should be noted that although the flowchart shows a logical order, in some cases, the steps shown or described may be executed in a different order. In this embodiment, the executing entity of the application upgrade method can be a smartphone, personal computer, server, or other device; no limitation is imposed in this embodiment. The executing entity is omitted from the description in this embodiment. In this embodiment, the application upgrade method includes the following steps:
[0073] Step S10: Obtain the target container image, which is created by packaging the upgrade script and upgrade files of the application to be upgraded.
[0074] In this embodiment, the application that needs to be upgraded is referred to as the application to be upgraded. The upgrade script and upgrade file can be written by technical personnel according to the upgrade requirements of the application to be upgraded. By executing the upgrade script, the application to be upgraded can be upgraded using the upgrade file. Currently, when the application to be upgraded is a bare-metal deployed application, it is necessary to develop an upgrade interface adapted to the application to be upgraded on the software platform, which results in high R&D costs. To solve this problem, this embodiment proposes an application upgrade scheme based on container technology.
[0075] Specifically, you can first obtain a container image (hereinafter referred to as the target container image) created by packaging the upgrade script and upgrade files of the application to be upgraded. In container technology, containers can be used to run applications. A container is a running instance created from a container image; it is a collection of processes with view isolation, limited resources, and an independent file system. A container image is a special file system that provides the programs, libraries, resources, configuration files, and other files required for container runtime.
[0076] In specific implementations, the target container image can be created by packaging the upgrade script and upgrade files after obtaining them, or it can be created directly from another device after packaging the target container image based on the upgrade script and upgrade files. It should be noted that in specific implementations, the target container image can be created or obtained from another device only when an upgrade is needed for the application to be upgraded, such as upon receiving an upgrade command. Alternatively, the target container image can be pre-packaged and created or obtained from another device and stored in an image repository, then retrieved from the image repository when an upgrade is needed for the application to be upgraded. In this embodiment, the method of creating the target container image based on the upgrade script and upgrade files is not limited; for example, a container image creation tool can be used to create it.
[0077] Step S20: Obtain a container configuration file for creating a target upgrade container, wherein the container configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container;
[0078] In this embodiment, the application to be upgraded is upgraded by creating a container. For distinction, the container created when upgrading the application is referred to as the target upgrade container. A container configuration file for creating the target upgrade container is obtained. This configuration file contains configuration information needed when creating the container, such as configuration information for configuring the resources the container can use. In this embodiment, to complete the application upgrade based on container technology, the container configuration file includes configuration information for configuring the upgrade script of the file to be upgraded as the startup script of the target upgrade container. This ensures that the upgrade script is automatically executed when the startup script is automatically executed after the target upgrade container is created, thus upgrading the application. The container configuration file may also include other configuration information, which is not limited in this embodiment. For example, in one embodiment, the container configuration file may include the name or ID of the target container image. After obtaining the container configuration file, the target container image can be obtained from the image repository based on the container configuration file, and then the target upgrade container can be created.
[0079] In specific implementations, either technicians can compile container configuration files online and then obtain the completed online container configuration files, or technicians can compile container configuration files on other devices and then obtain the container configuration files from those other devices.
[0080] Step S30: Create the target upgrade container based on the target container image and the container configuration file, and execute the upgrade script, which serves as the startup script, in the target upgrade container to upgrade the application to be upgraded using the upgrade file.
[0081] After obtaining the target container image and container configuration file, a target upgrade container can be created based on them. In a specific implementation, creating the target upgrade container can involve passing the target container image and container configuration file to the container creation interface provided by the underlying framework for container management, and then calling this interface to create the target upgrade container. After creation, the container automatically executes a startup script. In this embodiment, this feature of containers is utilized; the upgrade script of the application to be upgraded is configured as the startup script of the target upgrade container through the container configuration file. This ensures that after the target upgrade container is created, the upgrade script is automatically executed within the target upgrade container, thereby upgrading the application to be upgraded using the upgrade files. Depending on the upgrade requirements of the application to be upgraded, technicians can write different upgrade scripts to achieve different upgrade processes; however, this embodiment does not impose any restrictions on the specific implementation.
[0082] In this embodiment, a target container image is obtained, which is created by packaging the upgrade script and upgrade files of the application to be upgraded. A container configuration file for creating the target upgrade container is also obtained. This configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container. The target upgrade container is created based on the target container image and the container configuration file. The upgrade script, serving as the startup script, is executed within the target upgrade container, and the upgrade files are used to upgrade the application to be upgraded. In this embodiment, by configuring the upgrade script of the application to be upgraded as the container's startup script, and leveraging the feature that the startup script is automatically executed after container creation, the upgrade script is executed through the container to upgrade the application. This achieves the upgrade of bare-metal deployed applications without developing corresponding upgrade interfaces for different applications, reducing development costs.
[0083] Based on the first embodiment described above, a second embodiment of the application upgrade method of the present invention is proposed. In this embodiment, the step S30 of upgrading the application to be upgraded by executing the upgrade script using the upgrade file includes:
[0084] Step S301: The host machine directory is located by executing the upgrade script according to the mapping relationship. The storage location of the application file of the application to be upgraded is obtained by searching the host machine directory. The application file stored in the storage location is updated using the upgrade file to upgrade the application to be upgraded.
[0085] In this embodiment, when upgrading the application to be upgraded requires updating the application files of the application to be upgraded using an upgrade file, the container configuration file may also include a mapping relationship between the directory of the target upgrade container and the host machine directory.
[0086] Since the application to be upgraded is deployed on bare metal, its application file is located in the host machine's directory. The upgrade script is executed in the target upgrade container, and its visibility is limited to the target upgrade container's directory. Therefore, to ensure that the upgrade script can find and update the application file on the host machine, a mapping relationship between the target upgrade container's directory and the host machine's directory is configured in the container configuration file. Based on this mapping relationship, when the upgrade script is executed, the storage location of the application file to be upgraded can be obtained by searching for the application file in the host machine's directory. The upgrade script is then used to update the application file stored in that location using the upgrade file, thereby achieving the purpose of upgrading the application to be upgraded.
[0087] In other implementations, other methods may be used to enable the application file of the application to be upgraded to be found when the upgrade script is executed in the target upgrade container.
[0088] Further, in one embodiment, step S30, which involves upgrading the application to be upgraded using the upgrade file by executing the upgrade script, includes:
[0089] Step S302: Update the application files of the application to be upgraded using the upgrade file by executing the upgrade script;
[0090] In some scenarios, updating the application files of the application to be upgraded may not promptly update the services provided by the application. The upgraded services can only be provided upon the next startup of the application based on the updated application files. In this embodiment, to improve the deployment speed of the upgraded services, a monitoring and termination function for the application process is added to the upgrade script. Furthermore, to enable the upgrade script to monitor the application process, namespace configuration information is included in the container configuration file. This namespace configuration information is used to configure the shared namespace between the target upgrade container and the host machine.
[0091] Specifically, the application files of the application to be upgraded are first updated using the upgrade file by executing an upgrade script in the target upgrade container.
[0092] Step S303: Query the application process information of the application to be upgraded from the process information of the host machine for the first time by executing the upgrade script;
[0093] Since the application to be upgraded is deployed on bare metal, its application process information is only visible in the host machine's namespace. However, the upgrade script is executed in the target upgrade container, and its visibility is limited to the target upgrade container's namespace. Therefore, in order to enable the application process information of the application to be upgraded to be queried when the upgrade script is executed, the target upgrade container and the host machine are configured to share a namespace in the container configuration file. When the upgrade script is executed, if the application to be upgraded is running, the application process information of the application to be upgraded running in the host machine environment can be queried.
[0094] The query for application process information after the application files of the application to be upgraded have been updated is called the first query, to distinguish it from subsequent queries.
[0095] Step S304: If the application process information of the application to be upgraded is found for the first time, the application process of the application to be upgraded is terminated by executing the upgrade script.
[0096] If the application process information of the application to be upgraded is found during the first query, it means that the application to be upgraded is in a running state. In order to quickly deploy the upgraded service, the application process of the application to be upgraded can be terminated by executing the upgrade script.
[0097] Step S305: Query the application process information of the application to be upgraded from the process information of the host machine again by executing the upgrade script;
[0098] The purpose of terminating the application process of the application to be upgraded is to trigger the automatic startup function of the application to be upgraded or to trigger manual startup of the application to be upgraded, so that the application to be upgraded can quickly start based on the updated application files to provide the upgraded services.
[0099] After terminating the application process of the application to be upgraded, the application process information of the application to be upgraded can be queried again from the process information of the host machine by executing the upgrade script. The purpose is to determine whether the application to be upgraded has been restarted.
[0100] Step S306: If the application process information of the application to be upgraded is found again within a preset time period, then the upgrade of the application to be upgraded is completed.
[0101] If the application process information of the application to be upgraded is found again within the preset time period, it indicates that the application to be upgraded has been restarted, and at this point, it can be confirmed that the upgrade of the application to be upgraded is complete. The preset time period can be set as needed and is not limited in this embodiment. Further, in one embodiment, after confirming that the upgrade of the application to be upgraded is complete, the upgrade script can be terminated normally.
[0102] Furthermore, in one embodiment, the method further includes:
[0103] Step S40: Periodically query the application process status of the application to be upgraded, and restart the application process of the application to be upgraded when the application process of the application to be upgraded is detected to be in a terminated state.
[0104] In this embodiment, to further improve the deployment speed of services after the application to be upgraded is upgraded, the application process status of the application to be upgraded can be queried periodically. When the application process of the application to be upgraded is detected to be terminated, it is restarted. This ensures that if the application process of the application to be upgraded is terminated when the upgrade script is executed, it can be restarted after a certain period of time. Therefore, when the application process information of the application to be upgraded is queried again when the upgrade script is executed, the application process information of the application to be upgraded can be found within a preset time period, thereby quickly completing the upgrade of the application to be upgraded. Regularly querying the application process status of the application to be upgraded means querying the application process status at regular intervals. This interval is less than a preset time period, but the specific interval can be set as needed and is not limited in this embodiment.
[0105] In a specific implementation, if a daemon process for the application deployed on the bare metal is also deployed in the bare metal environment (this process queries the status of the application at regular intervals and automatically starts the application when it is found to have terminated), then the operation corresponding to step S40 can be performed through the daemon process of the application to be upgraded.
[0106] Furthermore, in one embodiment, the method further includes:
[0107] Step S50: If the application process information of the application to be upgraded is not found on the first query, or if the application process information of the application to be upgraded is not found again within a preset time period, then return to the step of creating the target upgrade container based on the target container image and the container configuration file.
[0108] If the application process information of the application to be upgraded is not found on the first query after updating the application files of the application to be upgraded by executing the upgrade script, or if the application process information of the application to be upgraded is not found within the preset time after terminating the application process by executing the upgrade script, it indicates that an abnormality may have occurred during the upgrade process, resulting in the upgrade failure. In this case, the target upgrade container can be created again based on the target container image and container configuration file, so as to upgrade the application to be upgraded again by executing the upgrade script. By trying again, the success rate of the application upgrade can be improved.
[0109] Furthermore, in other implementations, if the application process information of the application to be upgraded is not found on the first attempt, or if the application process information of the application to be upgraded is not found again within a preset time period, a prompt message can be output to inform the technicians that the upgrade has failed, so that the technicians can understand the upgrade result and then investigate the reason for the upgrade failure.
[0110] Furthermore, based on the first and / or second embodiments described above, a third embodiment of the application upgrade method of the present invention is proposed. In this embodiment, step S10 includes:
[0111] Step S101: Obtain the upgrade script and upgrade file of the application to be upgraded uploaded by the user terminal, and package the upgrade script and the upgrade file to create a target container image;
[0112] In this embodiment, the application upgrade method can be applied to a cloud platform deployed on the host machine. Specifically, the cloud platform can be a cloud platform providing container services, such as the Docker cloud platform; however, this embodiment does not impose any limitations.
[0113] Specifically, the cloud platform can obtain the target container image by having the user upload the upgrade script and upgrade files of the application to be upgraded on the user's terminal, and then the cloud platform can package and create the target container image based on the upgrade script and upgrade files.
[0114] The user terminal can be a personal computer, a smartphone, or other terminal, and this embodiment does not impose any restrictions.
[0115] Step S102: Obtain the target container image uploaded by the user terminal, wherein the target container image is created by packaging the upgrade script and the upgrade file of the application to be upgraded.
[0116] Alternatively, technicians can remotely connect to the cloud platform via a user terminal and upload the target container image to the cloud platform. Technicians can either directly upload a pre-created target container image from another device to the user terminal, or upload the upgrade script and upgrade files to the user terminal, where the container image creation tool provided on the user terminal will package and create the target container image.
[0117] In this embodiment, by applying the upgrade method of this embodiment to the cloud platform deployed on the host machine, technicians can remotely deploy the target container image on the cloud platform, and then remotely upgrade the application to be upgraded deployed on the host machine without having to go to the data center for upgrades, thus reducing labor costs. Furthermore, the upgrade can be completed directly by publishing the container image through the cloud platform, reducing the risk of on-site misoperation.
[0118] Further, in one embodiment, step S20 includes:
[0119] Step S201: Obtain the container configuration file uploaded by the user terminal for creating the target upgrade container;
[0120] In this embodiment, the application upgrade method can be applied to a cloud platform deployed on the host machine. Specifically, the cloud platform can be a cloud platform providing container services, such as the Docker cloud platform; however, this embodiment does not impose any limitations.
[0121] The cloud platform can obtain container configuration files in several ways. Specifically, it can obtain container configuration files uploaded by user terminals. In other words, technicians can connect to the cloud platform via user terminals and upload container configuration files to the platform. Alternatively, technicians can directly upload pre-configured container configuration files from other devices to the user terminal, or they can configure the container configuration files within the user terminal itself.
[0122] Step S202: Obtain the container configuration file for creating the target upgrade container, which is orchestrated based on the online orchestration function provided by the cloud platform in the user terminal.
[0123] Alternatively, the cloud platform can provide online orchestration functionality for container configuration files. Technicians can use the online orchestration functionality provided by the cloud platform on the user terminal to orchestrate container configuration files, and after orchestration is completed, the cloud platform will save the container configuration file for subsequent application upgrades.
[0124] In this embodiment, by applying the upgrade method of this embodiment to the cloud platform deployed on the host machine, technicians can remotely deploy container configuration files on the cloud platform, thereby remotely upgrading the application to be upgraded deployed on the host machine without having to go to the data center for upgrades, reducing labor costs. Furthermore, the upgrade can be completed directly by publishing the container image through the cloud platform, reducing the risk of on-site misoperation.
[0125] Furthermore, in one embodiment, such as Figure 3 As shown, a system architecture for application upgrades is provided.
[0126] 1. Technicians can use the container image creation module on their local PC to package and create a target container image based on the upgrade script and upgrade files (also known as deliverables) of the application to be upgraded.
[0127] 2. Import the target container image into the cloud platform deployed on the host machine using the container image import module.
[0128] 3. Upload the orchestrated container configuration file to the cloud platform via the upgraded container deployment module and trigger the application upgrade task. Technical personnel can choose to perform online orchestration on the cloud platform or upload the orchestrated container configuration file to the cloud platform.
[0129] 4. The cloud platform calls the underlying Kubernetes through the container upgrade module to create (publish) the target upgrade container based on the target container image and container configuration file.
[0130] 5. After the target upgrade container is created, the startup script, i.e., the upgrade script, is executed automatically, and the execution will be as follows: Figure 4 The upgrade process is illustrated; the updated deliverables involve updating the application files of the application to be upgraded using the upgrade files.
[0131] 6. The application's daemon process is deployed in a bare-metal environment. It periodically checks the status of the application process. If it finds that the application process has been stopped by the upgrade script, it will restart the application process, thus completing the restart after updating the application results.
[0132] The application of the upgrade method in this embodiment can achieve the following technical effects:
[0133] 1) For applications deployed on the host machine and applications deployed in containers, upgrades can be performed remotely through the cloud platform.
[0134] 2) All upgrade-related scripts and deliverables are packaged within the upgrade container image, thus standardizing and normalizing the upgrade deliverables.
[0135] 3) Upgrades can be completed directly by publishing container images through the cloud platform, reducing the risk of on-site misoperation.
[0136] 4) Reduce the coupling between bare-metal application upgrades and the platform, eliminating the need to develop additional interfaces for application upgrades.
[0137] Furthermore, embodiments of the present invention also propose an application upgrade device, referring to... Figure 5 The application upgrade device includes:
[0138] The first acquisition module 10 is used to acquire the target container image, which is created by packaging the upgrade script and upgrade files of the application to be upgraded.
[0139] The second acquisition module 20 is used to acquire a container configuration file for creating a target upgrade container, wherein the container configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container;
[0140] Upgrade module 30 is used to create the target upgrade container based on the target container image and the container configuration file, and to execute the upgrade script, which serves as a startup script, in the target upgrade container to upgrade the application to be upgraded using the upgrade file by executing the upgrade script.
[0141] Furthermore, the container configuration file also includes a mapping relationship between the target upgrade container's directory and the host machine's directory;
[0142] The upgrade module 30 is also used for:
[0143] The upgrade script is executed to locate the host directory according to the mapping relationship. The storage location of the application file of the application to be upgraded is obtained by locating the host directory. The upgrade file is then used to update the application file stored in the storage location in order to upgrade the application to be upgraded.
[0144] Furthermore, the container configuration file also includes namespace configuration information, which is used to configure the target upgrade container and the host machine to share a namespace;
[0145] The upgrade module 30 is also used for:
[0146] The application files of the application to be upgraded are updated using the upgrade file by executing the upgrade script.
[0147] The upgrade script is executed to query the application process information of the application to be upgraded from the process information of the host machine for the first time.
[0148] If the application process information of the application to be upgraded is found for the first time, the application process of the application to be upgraded is terminated by executing the upgrade script;
[0149] The upgrade script is executed to query the application process information of the application to be upgraded from the process information of the host machine again.
[0150] If the application process information of the application to be upgraded is found again within the preset time period, the upgrade of the application to be upgraded is confirmed to be completed.
[0151] Furthermore, the application upgrade device also includes:
[0152] The startup module is used to periodically query the application process status of the application to be upgraded, and restart the application process of the application to be upgraded when it is detected that the application process of the application to be upgraded is in a terminated state.
[0153] Furthermore, the upgrade module 30 is also used for:
[0154] If the application process information of the application to be upgraded is not found on the first query, or if the application process information of the application to be upgraded is not found again within a preset time period, then the operation of creating the target upgrade container based on the target container image and the container configuration file will be returned.
[0155] Furthermore, the application upgrade method is applied to a cloud platform deployed in the host machine, and the first acquisition module 10 is also used for:
[0156] Obtain the upgrade script and upgrade file of the application to be upgraded uploaded by the user terminal, and package the upgrade script and upgrade file to create a target container image; or,
[0157] Obtain the target container image uploaded by the user terminal, wherein the target container image is created by packaging the upgrade script and the upgrade file of the application to be upgraded.
[0158] Furthermore, the application upgrade method is applied to a cloud platform deployed in the host machine, and the first acquisition module 20 is also used for:
[0159] Obtain the container configuration file uploaded by the user terminal for creating the target upgrade container; or,
[0160] Obtain the container configuration file used to create the target upgrade container, which is orchestrated based on the online orchestration function provided by the cloud platform in the user terminal.
[0161] The extended content of the specific implementation of the application upgrade device of the present invention is basically the same as the various embodiments of the application upgrade method described above, and will not be repeated here.
[0162] Furthermore, embodiments of the present invention also propose a computer-readable storage medium storing an application upgrade program, wherein the application upgrade program, when executed by a processor, implements the steps of the application upgrade method described below.
[0163] The various embodiments of the application upgrade device, system, and computer-readable storage medium of the present invention can be referred to the various embodiments of the application upgrade method of the present invention, which will not be repeated here.
[0164] 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 apparatus 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 apparatus. 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 apparatus that includes that element.
[0165] 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.
[0166] 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, in essence, 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 ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0167] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. An application upgrade method, characterized in that, The method includes the following steps: Obtain the target container image, which is created by packaging the upgrade script and upgrade files of the application to be upgraded. The application to be upgraded is deployed on a bare metal machine, the target container image is deployed on a cloud platform on the host machine, and the upgrade script and upgrade files of the application to be upgraded are uploaded to the cloud platform by the user terminal. Obtain a container configuration file for creating a target upgrade container, wherein the container configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container, a mapping relationship between the directory of the target upgrade container and the host machine directory, and a shared namespace between the target upgrade container and the host machine, and the container configuration file is in the cloud platform; The target upgrade container is created based on the target container image and the container configuration file, and the upgrade script, which serves as a startup script, is executed in the target upgrade container. The upgrade script is used to upgrade the application to be upgraded deployed on the host machine using the upgrade file. The step of upgrading the application to be upgraded by executing the upgrade script using the upgrade file includes: The upgrade script is executed to locate the host directory according to the mapping relationship. The storage location of the application file of the application to be upgraded is obtained by locating the host directory. The upgrade file is then used to update the application file stored in the storage location in order to upgrade the application to be upgraded.
2. The application upgrade method as described in claim 1, characterized in that, The container configuration file also includes namespace configuration information, which is used to configure the target upgrade container to share a namespace with the host machine. The step of upgrading the application to be upgraded by executing the upgrade script using the upgrade file includes: The application files of the application to be upgraded are updated using the upgrade file by executing the upgrade script. The upgrade script is executed to query the application process information of the application to be upgraded from the process information of the host machine for the first time. If the application process information of the application to be upgraded is found for the first time, the application process of the application to be upgraded is terminated by executing the upgrade script; The upgrade script is executed to query the application process information of the application to be upgraded from the process information of the host machine again. If the application process information of the application to be upgraded is found again within the preset time period, the upgrade of the application to be upgraded is confirmed to be completed.
3. The application upgrade method as described in claim 2, characterized in that, The method further includes: The application process status of the application to be upgraded is queried periodically, and the application process of the application to be upgraded is restarted when it is detected that the application process of the application to be upgraded is in a terminated state.
4. The application upgrade method as described in claim 2, characterized in that, The method further includes: If the application process information of the application to be upgraded is not found on the first attempt, or if the application process information of the application to be upgraded is not found again within a preset time period, then return to the step of creating the target upgrade container based on the target container image and the container configuration file.
5. The application upgrade method as described in claim 1, characterized in that, The application upgrade method is applied to a cloud platform deployed on a host machine, and the step of obtaining the target container image includes: Obtain the upgrade script and upgrade file of the application to be upgraded uploaded by the user terminal, and package the upgrade script and upgrade file to create a target container image; or, Obtain the target container image uploaded by the user terminal, wherein the target container image is created by packaging the upgrade script and the upgrade file of the application to be upgraded.
6. The application upgrade method as described in any one of claims 1 to 5, characterized in that, The application upgrade method is applied to a cloud platform deployed on a host machine, and the step of obtaining the container configuration file used to create the target upgrade container includes: Obtain the container configuration file uploaded by the user terminal for creating the target upgrade container; or, Obtain the container configuration file used to create the target upgrade container, which is orchestrated based on the online orchestration function provided by the cloud platform in the user terminal.
7. An application upgrade device, characterized in that, The application upgrade device includes: The first acquisition module is used to acquire the target container image, which is created by packaging the upgrade script and upgrade files of the application to be upgraded. The application to be upgraded is deployed on a bare metal machine, the target container image is deployed on a cloud platform on the host machine, and the upgrade script and upgrade files of the application to be upgraded are uploaded to the cloud platform by the user terminal. The second acquisition module is used to acquire a container configuration file for creating a target upgrade container. The container configuration file includes configuration information for configuring the upgrade script as the startup script of the target upgrade container, a mapping relationship between the directory of the target upgrade container and the host machine directory, and a shared namespace between the target upgrade container and the host machine. The container configuration file is in the cloud platform. An upgrade module is used to create a target upgrade container based on the target container image and the container configuration file, and to execute the upgrade script, which serves as a startup script, in the target upgrade container. By executing the upgrade script, the application to be upgraded deployed on the host machine is upgraded using the upgrade file. The upgrade module is further configured to: execute the upgrade script to locate the host directory according to the mapping relationship, obtain the storage location of the application file of the application to be upgraded by locating the host directory, and update the application file stored in the storage location using the upgrade file to upgrade the application to be upgraded.
8. An application upgrade device, characterized in that, The application upgrade device includes: a memory, a processor, and an application upgrade program stored in the memory and executable on the processor, wherein when the application upgrade program is executed by the processor, it implements the steps of the application upgrade method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an application upgrade program, which, when executed by a processor, implements the steps of the application upgrade method as described in any one of claims 1 to 6.