Environment configuration method and device, computer equipment and readable storage medium
By automatically analyzing the application image version and dependencies, the application environment is automatically configured in the cloud computing environment, which solves the challenges of environmental resource management and allocation in cloud computing, improves the efficiency and accuracy of environmental configuration, and supports multi-version parallel development.
Patent Information
- Application Number
- CN202411724610.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-02-11
AI Technical Summary
In cloud computing, the management and allocation of environmental resources becomes a major challenge in the continuous delivery process, especially when multiple versions need to be processed in parallel, and the existing technology requires manual intervention, resulting in low environmental configuration efficiency.
Provides an environment configuration method, analyzes application image version record data when detecting application version updates, obtains current version and dependencies, creates namespaces in the target cluster and sets resource quotas, and configures middleware based on the application's current version and dependencies. , generate the application environment.
It realizes the automated deployment of the application environment, significantly improves the efficiency and accuracy of the application environment construction, ensures the stability and synchronization of the application development environment, and provides a reliable data foundation for the multi-version parallel development of applications.
Smart Images

Figure CN119415142A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to an environment configuration method, apparatus, computer equipment, and readable storage medium. Background Art
[0002] With the development of cloud computing technology, more and more companies are beginning to adopt cloud-native architecture to build and deploy applications. Cloud-native technologies (such as containerization, microservices, and DevOps) make software development and deployment more flexible and efficient. However, in the continuous delivery process, especially when multiple versions need to be processed in parallel, the management and allocation of environmental resources becomes a major challenge.
[0003] In the related art, in order to build an environment that meets the dependencies of a specific application, manual intervention is generally required, including the deployment of related applications and their dependent middleware. Since the configuration steps are relatively cumbersome, the efficiency of the environment configuration is low. Summary of the invention
[0004] Based on this, it is necessary to provide an environment configuration method, apparatus, computer device and readable storage medium that can improve the accuracy and efficiency of environment configuration in response to the above technical problems.
[0005] In a first aspect, the present application provides an environment configuration method, comprising:
[0006] When a version update of an application is detected, the application image version record data is analyzed to obtain the current version and dependency relationship of the application; the dependency relationship includes the application on which the application depends;
[0007] Creating a namespace in the target cluster and setting a resource quota for the namespace, wherein the quota includes a maximum value of computing resources and a maximum value of storage resources;
[0008] In the namespace, configuration is performed based on the current version and dependency relationship of the application and the middleware corresponding to the application to generate an application environment for the application.
[0009] In one embodiment, the method further comprises:
[0010] Matching is performed based on the current version of the application to obtain the image data of the application and the image data of the application's dependent applications.
[0011] In one embodiment, the method further comprises:
[0012] Based on the resource reservation value of the metadata of the application and the replica data that the application needs to start, screening is performed among multiple clusters to determine a target cluster;
[0013] A resource quota of the namespace is determined based on a maximum value of resources in the metadata of the application.
[0014] In one of the embodiments, in the namespace, based on the current version and dependencies of the application and the middleware corresponding to the application, the application environment of the application is generated, including: based on the current version of the application, determining the common middleware and exclusive middleware in the application; based on the current version and dependencies of the application, determining the application and the applications on which the application depends; based on a preset configuration template file, respectively configuring the common middleware and exclusive middleware in the application, the application and the applications on which the application depends to obtain deployed data; and obtaining the application environment of the application based on the deployed data.
[0015] In one embodiment, based on a preset configuration template file, respectively configuring the common middleware and exclusive middleware in the application, the application, and the application on which the application depends to obtain deployed data includes:
[0016] Determine a first configuration template file of a first type corresponding to the public middleware, and replace configuration parameters in the first configuration template file based on configuration parameters of the public middleware to obtain a deployed public middleware;
[0017] Determine a second configuration template file of the first type corresponding to the exclusive middleware, and replace configuration parameters in the second configuration template file based on configuration parameters of the exclusive middleware to obtain the deployed exclusive middleware;
[0018] Determine a third configuration template file of the second type corresponding to the application, and replace configuration parameters in the third configuration template file based on the configuration parameters of the application to obtain a deployed application;
[0019] A fourth configuration template file of the second type corresponding to the dependent application is determined, and configuration parameters in the fourth configuration template file are replaced based on configuration parameters of the dependent application to obtain a deployed dependent application.
[0020] In one embodiment, the environment configuration life cycle; the method further comprises:
[0021] When the life cycle of the application environment exceeds the life cycle of the current version of the application, the namespace where the application environment is located is deleted to release resources used by the namespace.
[0022] In one embodiment, the method further comprises:
[0023] Monitoring the application load of the application in the namespace by a target monitoring tool;
[0024] If it is detected that the application load has changed, the amount of change in the application load is determined, and based on the amount of change in the application load, the resources of the namespace corresponding to the application are expanded or reduced.
[0025] In a second aspect, the present application also provides an environment configuration device, including:
[0026] An analysis module is used to analyze the application image version record data when an application version update is detected to obtain the current version and dependency of the application; the dependency includes the application on which the application depends; a creation module is used to create a namespace in the target cluster and set the resource quota of the namespace, the quota includes the maximum value of computing resources and the maximum value of storage resources; a generation module is used to configure in the namespace based on the current version and dependency of the application and the middleware corresponding to the application to generate an application environment for the application.
[0027] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps described in the above embodiment when executing the computer program.
[0028] In a fourth aspect, the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps described in the above embodiments are implemented.
[0029] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps described in the above embodiments when executed by a processor.
[0030] The above-mentioned environment configuration method, device, computer equipment and readable storage medium, by adopting this method, can respond in time when an application version update is detected, realize automatic deployment of the application environment, significantly improve the efficiency and accuracy of application environment construction, ensure the stability and synchronization of the application development environment, and provide a reliable data foundation for the parallel development of multiple versions of applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0032] FIG1 is a schematic diagram of a flow chart of an environment configuration method in an embodiment;
[0033] FIG2 is a flow chart of steps for determining a resource quota of a namespace in one embodiment;
[0034] FIG3 is a schematic diagram of a flow chart of a step to an application environment in one embodiment;
[0035] FIG4 is a schematic diagram of a process flow of a deployment step in an embodiment;
[0036] FIG5 is a schematic diagram of a process flow of a resource adjustment step in one embodiment;
[0037] FIG6 is a schematic diagram of a flow chart of an environment configuration method in another embodiment;
[0038] FIG7 is a schematic diagram of a system architecture in an environment configuration method in one embodiment;
[0039] FIG8 is a structural block diagram of an environment configuration device in one embodiment;
[0040] FIG. 9 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0042] In one embodiment, as shown in FIG1 , an environment configuration method is provided. This embodiment uses the method applied to a terminal as an example. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. The above-mentioned terminal can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. In this embodiment, the environment configuration method includes the following steps:
[0043] Step 102: When a version update of an application is detected, the application image version record data is analyzed to obtain the current version and dependency relationship of the application.
[0044] The dependency relationship may include an application that has a dependency relationship with the application, that is, an application where an interface that the application needs to call during operation is located or an application that the application needs to access, etc. For example, when a first application needs to access / call an interface of a second application during operation, the dependency relationship of the first application may be that the first application depends on the second application, that is, the dependent application of the first application is the second application. The application image version record data may be data that records various versions of the application image; the current version of the application may be the version of the application that is currently updated.
[0045] Specifically, the terminal may monitor the versions of various applications, and if an application with an updated version is detected, the application with the updated version is determined to be the target application, and the application image version record data of the target application is obtained, and the application image version record data of the target application is analyzed to obtain the current version of the target application and the dependent applications of the target application contained in the record data. That is, when the terminal detects that the application version is updated, it will automatically obtain the application image version record data of the application for analysis to obtain the current version of the application and the dependency relationship of the application.
[0046] Step 104: Create a namespace in the target cluster and set a resource quota for the namespace, where the quota includes a maximum value of computing resources and a maximum value of storage resources.
[0047] The target cluster may be a Kubernetes cluster; the resource quota of the namespace may include a limit value for the maximum usage of various types of resources used by the namespace; and the various types of resources may include computing resources and storage resources.
[0048] Specifically, the terminal can determine the target cluster corresponding to the application based on the application, create a namespace for the application in the target cluster, and configure the quota of the created namespace. The specific process of configuring the quota may include: the terminal determines the maximum usage limit values corresponding to each type of resource corresponding to the application, and based on the maximum usage limit values corresponding to each type of resource, configures the maximum usage limit values of each type of resource in the namespace; for example, each type of resource may include CPU and memory, the CPU quota corresponding to the application may be a first value, and the memory quota may be a second value, the terminal may set the CPU quota in the namespace to the first value, and set the memory quota in the namespace to the second value.
[0049] Step 106: In the namespace, configure based on the current version and dependency of the application and the middleware corresponding to the application to generate an application environment for the application.
[0050] The application environment of an application may be an operating environment in which the application is run to provide services to users. Middleware may include middleware of multiple usage types, such as public middleware shared with other applications and exclusive middleware used only by the current application; middleware may also include multiple service types, such as database middleware and cache service middleware.
[0051] Specifically, the terminal can configure and deploy in the namespace created by the target cluster based on the current version of the application, the dependent applications of the application, and the middleware of the application and the dependent applications, and obtain the application environment for running the application based on the deployed applications, dependent applications and middleware.
[0052] In the above-mentioned environment configuration method, when an application version update is detected, the application image version record data is analyzed to obtain the current version and dependencies of the application. Dependencies include applications that the application depends on. Create a namespace in the target cluster, and set the resource quota of the namespace. The quota includes the maximum value of computing resources and the maximum value of storage resources. In the namespace, based on the current version and dependencies of the application and the middleware corresponding to the application, the application environment of the application is generated. By adopting this method, it is possible to respond in a timely manner when an application version update is detected, realize automatic deployment of the application environment, significantly improve the efficiency and accuracy of application environment construction, ensure the stability and synchronization of the application development environment, and provide a reliable data foundation for the parallel development of multiple versions of applications.
[0053] In an exemplary embodiment, the environment configuration method further includes: performing matching based on the current version of the application to obtain the image data of the application and the image data of the application's dependent applications.
[0054] Specifically, the terminal can match the image data of the application based on the current version of the application. In order to ensure the normal operation of the application, the general test will be processed in the image application data of the application. Then, the terminal can obtain the image data of the application corresponding to the current version of the application in the image database of the application, and determine the dependent application of the application based on the application and the current version of the application; in this way, the terminal can query the image data of the dependent application in the image database of the above application, that is, obtain the image data of the dependent application of the application. The image database of the application can include the image data corresponding to multiple versions of each application.
[0055] In this embodiment, application updates are timely perceived through version information, the accuracy of data acquisition is protected, and processing is performed based on the application's mirror data, which can ensure the stability of application operation and the accuracy of application testing and detection.
[0056] In an exemplary embodiment, as shown in FIG2 , the environment configuration method further includes:
[0057] Step 202 : Based on the resource reservation value of the metadata of the application and the replica data that the application needs to start, multiple clusters are screened to determine a target cluster.
[0058] The metadata of the application may include a resource reservation value and a resource maximum value. The resource reservation value includes the required usage of each type of resource of the application; the resource maximum value may include the maximum usage limit value of each type of resource of the application. The replica data that needs to be started is the amount of data that needs to be pulled up to run the application. Each type of resource may include CPU, memory, and disk space.
[0059] Specifically, the terminal can perform an environmental resource assessment based on the application, for example, based on the resource reservation value contained in the metadata of the application and the amount of replica data that the application needs to start, and screen out the target cluster from multiple pre-configured clusters. For example, the specific screening process can be that the terminal calculates the resource value required by the application based on the resource reservation value contained in the metadata of the application and the amount of replica data that the application needs to start, and determines the remaining resource value corresponding to each cluster in each pre-configured cluster, and determines the target cluster corresponding to the application by the cluster corresponding to the remaining resource value that is greater than the resource value required by the application and closest to the resource value required by the application. The terminal can create a new namespace for the application in the target cluster.
[0060] Step 204: Determine the resource quota of the namespace based on the maximum value of the resource in the metadata of the application.
[0061] Specifically, the terminal can determine the maximum usage limit values corresponding to each type of resource used by the application based on the metadata of the application, and the terminal can configure the maximum usage limit values of each type of resource in the namespace based on the maximum usage limit values corresponding to each type of resource; for example, the maximum usage limit value corresponding to the resource in the metadata can be set as the quota of the resource in the namespace. For example: each type of resource can include CPU and memory, the CPU quota corresponding to the application can be a first value, and the memory quota can be a second value. The terminal can set the CPU quota in the namespace to the first value, and set the memory quota in the namespace to the second value.
[0062] In this embodiment, resource quotas in the namespace of an application may be configured based on the metadata of the application, thereby ensuring reasonable and flexible allocation of resources in each namespace and maximizing the utilization of cluster resources.
[0063] In an exemplary embodiment, as shown in FIG3 , the specific implementation process of the step of “configuring in the namespace based on the current version and dependency relationship of the application and the middleware corresponding to the application to generate the application environment of the application” may include:
[0064] Step 302: Determine the public middleware and exclusive middleware in the application based on the current version of the application.
[0065] The current version of the application may be the latest version of the application when the update is detected. The public middleware in the application may represent the middleware used / called by the application and other middlewares, and the exclusive middleware may be the middleware used only by the application itself, or the middleware used only by the dependent application of the application.
[0066] Specifically, the terminal can obtain the latest version of the current application, and based on the exclusive middleware of the latest version of the application, determine the dependent application corresponding to the latest version of the application, determine the exclusive middleware of the dependent application, and determine the common middleware used by the application and the dependent application of the application. Optionally, the terminal can also determine the common middleware used by the application and other applications, and the terminal can also determine the common middleware used by the dependent application and other applications.
[0067] Step 304: Determine the application and the applications on which the application depends based on the current version and dependency relationship of the application.
[0068] Specifically, the terminal may obtain the latest version of the current application and determine the dependency of the latest version of the application, that is, determine the dependent applications that have a dependency relationship with the application, that is, the terminal needs to determine the applications that need to be called when the application is running.
[0069] Step 306, based on the preset configuration template file, respectively configure the common middleware and exclusive middleware in the application, the application and the application on which the application depends, obtain the deployed data, and obtain the application environment of the application based on the deployed data.
[0070] The preset configuration template file may include a preset configuration template file of the middleware and a preset configuration template file for processing the application; the application environment of the application may be an operating environment for running the application based on user needs.
[0071] Specifically, the terminal deploys the common middleware and exclusive middleware of the application based on the configuration template file corresponding to the middleware to obtain the deployed middleware; the terminal can also deploy the application and the dependent application based on the configuration template file corresponding to the application to obtain the deployed application and the dependent application. The terminal can obtain the application environment of the application based on the deployed middleware, the deployed application and the deployed dependent application, that is, obtain the operating environment for running the application.
[0072] In this embodiment, by configuring the environment based on a pre-configured configuration template file, the reusability of the environment configuration process can be improved, and the efficiency and accuracy of the environment configuration can be improved; and through the parsing mechanism, precise control of traffic interconnection and isolation can be achieved, providing a clear and independent operating environment for parallel development of multiple versions, further accelerating the iteration speed, and ensuring the stability and consistency of the development environment.
[0073] In an exemplary embodiment, as shown in FIG. 4 , the specific processing of the step of “based on a preset configuration template file, respectively configuring the common middleware and exclusive middleware in the application, the application, and the application on which the application depends to obtain deployed data” includes:
[0074] Step 402: determine a first configuration template file of a first type corresponding to the public middleware, and replace configuration parameters in the first configuration template file based on configuration parameters of the public middleware to obtain the deployed public middleware.
[0075] Among them, the first configuration template file of the first type may be a template file for configuring a common middleware, and the first type may be a Statefulset type; the middleware may include a database, a cache service, and the like.
[0076] Specifically, the terminal can describe the deployment process of the public middleware through the Kubernetes orchestration file. The specific deployment process can be that the terminal determines the configuration parameters of the public middleware corresponding to the application, and replaces the parameters in the first configuration template file of the first type with the configuration parameters of the public middleware corresponding to the application to obtain the deployed public middleware.
[0077] Step 404: determine the second configuration template file of the first type corresponding to the exclusive middleware, and replace the configuration parameters in the second configuration template file based on the configuration parameters of the exclusive middleware to obtain the deployed exclusive middleware.
[0078] Among them, the first configuration template file of the first type may be a template file for configuring an exclusive middleware, and the first type may be a Statefulset type.
[0079] Specifically, the terminal can describe the deployment process of the exclusive middleware through the Kubernetes orchestration file. The specific deployment process can be that the terminal determines the configuration parameters of the exclusive middleware corresponding to the application, and replaces the parameters in the second configuration template file of the first type with the configuration parameters of the exclusive middleware corresponding to the application to obtain the deployed exclusive middleware.
[0080] Step 406: determine a third configuration template file of the second type corresponding to the application, and replace configuration parameters in the third configuration template file based on configuration parameters of the application to obtain a deployed application.
[0081] The third configuration template file of the second type may be a template file for configuring an application, and the second type may be a Deployment type.
[0082] Specifically, the terminal can describe the deployment process of the application through the Kubernetes orchestration file. The specific deployment process can be that the terminal determines the configuration parameters of the application corresponding to the application, and replaces the parameters in the third configuration template file of the second type with the configuration parameters of the application corresponding to the application to obtain the deployed application.
[0083] Step 408: determine a fourth configuration template file of the second type corresponding to the dependent application, and replace configuration parameters in the fourth configuration template file based on configuration parameters of the dependent application to obtain a deployed dependent application.
[0084] The fourth configuration template file of the second type may be a template file used to configure dependent applications, and the second type may be a Deployment type.
[0085] Specifically, the terminal can describe the deployment process of the dependent application through the Kubernetes orchestration file. The specific deployment process can be that the terminal determines the configuration parameters of the dependent application corresponding to the application, and replaces the parameters in the fourth configuration template file of the second type with the configuration parameters of the dependent application of the application to obtain the deployed dependent application.
[0086] It should be noted that the present disclosure does not limit the execution order of the above steps 402, 404, 406 and 408. Those skilled in the art can determine it based on the actual needs of the actual application scenario. For example, based on the deployment process of the public middleware and exclusive middleware corresponding to the application, a pipeline of deployment steps corresponding to the application is formed, and the deployed data is obtained based on the execution of the pipeline.
[0087] In this embodiment, by configuring the environment based on a pre-configured configuration template file, the reusability of the environment configuration process can be improved, and the efficiency and accuracy of the environment configuration can be improved.
[0088] In an exemplary embodiment, the environment configuration life cycle. The life cycle may be the effective period of use of the environment. The environment configuration method further includes:
[0089] When the life cycle of the application environment exceeds the life cycle of the current version of the application, the namespace where the application environment is located is deleted to release the resources used by the namespace.
[0090] The application environment may be an operating environment of the application; and the period of the current version of the application may be an operating validity period of the current version of the application.
[0091] Specifically, after generating the application's operating environment, the terminal can configure a life cycle for the application environment. The terminal can monitor the life cycle of each application's application environment. If it is determined that there is an application cycle that exceeds the current version of the application, the terminal deletes the namespace where the application environment of the application is located in the target cluster corresponding to the application, thereby releasing the resources occupied by the namespace.
[0092] In this embodiment, when the application version expires, the expired application environment can be screened out in time, and space release processing can be performed in time to achieve real-time resource adjustment and further improve the utilization efficiency of resources in the cluster.
[0093] In an exemplary embodiment, as shown in FIG5 , the environment configuration method further includes:
[0094] Step 502, monitoring the application load of the application in the namespace through a target monitoring tool;
[0095] The target monitoring tool is used to monitor the real-time load of the application in real time, for example, it can be a built-in monitoring tool of Kubernetes, such as Prometheus, Heapster, etc.
[0096] Specifically, the terminal may monitor the real-time load of the application in the namespace in real time to obtain the real-time load of the application carried by the namespace.
[0097] Step 504: If a change in the application load is detected, the amount of change in the application load is determined, and based on the amount of change in the application load, the resources in the namespace corresponding to the application are expanded or reduced.
[0098] The applied load change amount may be a load increase amount or a load decrease amount.
[0099] Specifically, if the terminal detects that the real-time load of the application has changed, the change amount of the real-time load of the application can be determined, and based on the type of the change amount, the resources in the namespace where the application is located can be expanded or reduced.
[0100] In one example, the terminal can perform a capacity reduction or capacity expansion process when it detects that the real-time application load change of the application exceeds a preset change threshold. For example, when the terminal detects that the load increase exceeds the preset change threshold, it can determine the amount of resources that need to be increased based on the load increase, and expand the resources of the namespace based on the amount of resources that need to be increased; correspondingly, when the terminal detects that the load reduction exceeds the preset change threshold, it can determine the amount of resources that need to be reduced based on the load reduction, and scale the resources of the namespace based on the amount of resources that need to be reduced.
[0101] In this embodiment, the real-time load of the application can be monitored in a timely manner, and the real-time and flexibility of resource adjustment can be achieved, thereby further improving the utilization efficiency of the resources in the cluster.
[0102] In the following, in conjunction with a specific embodiment, a detailed description of the specific implementation process of the above environment configuration method may include:
[0103] First, some technical terms used in this embodiment are introduced:
[0104] Kubernetes (K8s): is an open source container orchestration platform for automating the deployment, expansion, and management of containerized applications. It provides a framework for running distributed systems and supports large-scale deployment of containerized applications.
[0105] Namespace: It is a resource isolation mechanism in Kubernetes. It can logically separate the resources within the cluster and provide independent environments for different teams or projects.
[0106] Image version management: Image version management refers to the process of managing and tracking different versions of container images. Each image has a unique identifier (such as a tag or hash value) to distinguish different versions.
[0107] Automatic deployment: refers to deploying applications to production environments or other environments through automated tools and processes without human intervention.
[0108] DNS resolution mechanism: DNS resolution mechanism refers to the process by which the Domain Name System (Domain Name System) converts domain names into IP addresses. In K8s, the DNS resolution mechanism is used to implement service discovery.
[0109] Traffic isolation: Separate the traffic between different services or applications at the network level to prevent mutual interference.
[0110] Multi-version parallel development: refers to the development of multiple versions simultaneously in a project.
[0111] Continuous Delivery (CD): Continuous delivery is a software engineering practice that ensures that software can be delivered to the production environment at any point in time through automated tools and processes.
[0112] Cloud Native: Cloud Native is an approach to designing and building applications that aims to take full advantage of the benefits of cloud computing, such as elastic scaling, high availability, and automated management.
[0113] The environment configuration method provided in this embodiment relates to the field of cloud computing and continuous delivery technology. This embodiment dynamically creates a namespace and realizes the rapid generation of an application environment through a Kubernetes (K8s) method to solve the problem of inefficiency caused by manually creating and configuring the environment during the parallel version delivery process, and can also avoid problems encountered during the research and development process, including complex, time-consuming, and error-prone manual environment configuration, as well as difficulties in environmental isolation and resource allocation during multi-version parallel development. The environment configuration method provided in this embodiment can automatically build an environment, automatically deploy related applications and their dependent middleware, and ensure the quality and progress of research and development; it can also realize dynamic allocation and management of resources, dynamically adjust resource allocation according to actual needs, so as to optimize resource utilization and reduce waste; it can also realize environmental isolation for multi-version parallel development: in the scenario of supporting the simultaneous development of multiple products or application versions, ensure the isolation of the environment between versions, avoid cross-traffic interference, and ensure development quality and security. That is to say, the environment configuration method provided in this embodiment is a method of dynamic environment delivery based on cloud native, which makes full use of the Namespace isolation characteristics in k8s, combined with image version management and automatic deployment technology, to achieve automatic and rapid construction of the R&D environment, including automated environment deployment and delivery, dynamic resource management, and traffic isolation and multi-version parallel development support; specifically, by analyzing the application image version record, automatically generating and deploying related applications and middleware to the same Namespace, the environment can be quickly built and delivered, human configuration errors can be reduced, and R&D efficiency can be improved. Computing, storage and other resources are dynamically allocated within the Namespace to ensure that each environment intelligently adjusts resources according to real-time load, improve resource utilization efficiency, and shorten the R&D cycle. The k8s DNS resolution mechanism is used to accurately control traffic intercommunication and isolation between different Namespaces, provide a clear and independent operating environment for multi-version parallel development, further accelerate the iteration speed, and ensure the stability and consistency of the development environment.
[0114] As shown in Figure 6, this embodiment includes a resource management module and an automatic deployment module. The resource management module is used to obtain application metadata, image versions, application dependencies, and application resources; the automatic deployment module configures, runs deployment pipelines, and synchronizes pipeline status, creates namespaces and sets quotas, deploys middleware and applications, and exposes services through pipeline execution in Kubernetes.
[0115] The resource management module can dynamically allocate computing resources (such as CPU, memory) and storage resources (such as disk space) in the Kubernetes cluster, ensuring that each environment intelligently adjusts resources according to real-time load. In addition, this module is also responsible for managing resource quotas within the namespace to ensure effective use of resources.
[0116] Operation 1, namespace creation: When a new version is available, the resource management module automatically detects the need for version update and creates a new namespace in the Kubernetes cluster.
[0117] Operation 2, namespace management: Set resource quotas (such as CPU, memory, disk space, etc.) for the newly created namespace to ensure that resources in each namespace are reasonably allocated. Specifically, dynamically adjust the computing resources (such as CPU, memory) in the namespace according to the actual load of the application; use Kubernetes built-in monitoring tools (such as Prometheus, Heapster) to monitor the application load in the namespace; automatically scale up and down (Horizontal Pod Autoscaler, HPA) according to the load to ensure sufficient resources and no waste.
[0118] Operation 3, resource quota management: Set resource quotas for each namespace to ensure that the resources within the namespace do not exceed the predetermined range; set the maximum CPU and memory usage of the namespace; when the namespace is no longer in use, automatically recycle the resources within the namespace and release them for use in other environments.
[0119] The automatic deployment module can automatically generate and deploy related applications and middleware in the new namespace to achieve rapid construction and delivery of the environment. In addition, this module is also responsible for reducing human configuration errors and improving R&D efficiency. The automatic deployment module mainly uses the capabilities of the pipeline to achieve automation.
[0120] Specifically, when a version update of an application is detected, the terminal can automatically identify the current version of the application and its dependencies by analyzing the application image version record; and match the image data of the application and the image data of its dependent applications according to the current version information of the application.
[0121] In this way, the terminal can create a new namespace in the cluster and automatically generate and deploy related applications under the newly created namespace. For example, the deployment process of the application can be described through the Kubernetes orchestration file. Usually, the application and dependent applications are deployed using a Deployment-type template configuration file. At the same time, in order to meet the access requirements within the cluster, Service resources are also configured for each service.
[0122] For example, the middleware required by the application (such as database, cache service, etc.) can be automatically deployed. Consistent with the application, the middleware deployment is described by the Kubernetes orchestration file. The template configuration file for deploying the specific middleware can use the Statefulset type.
[0123] The environment configuration method provided in this embodiment can reduce the manual configuration steps through automated processes, thereby reducing the possibility of errors; use templated configuration files to simplify the configuration steps in the deployment process; create and manage different configuration templates, and select appropriate templates according to the requirements of different versions; use variable replacement technology to replace variables in the template with actual values, further improving the efficiency and speed of environment configuration.
[0124] As shown in FIG. 7 , the automated process of dynamically creating an environment process in the environment configuration method of this embodiment is as follows:
[0125] The process begins.
[0126] Application dependency analysis, specifically, determining the application updated by the current version and the dependent applications of the application. Obtaining the application image version, specifically, obtaining the image data of the application and the image data of the dependent applications of the application. Environmental resource assessment, specifically, determining the resource reservation value and the replica data to be started based on the metadata of the application, and determining the target cluster based on the above data, the target cluster is used to create the namespace corresponding to the application. Create a namespace and set a quota, create a new namespace in the container cluster, set a resource quota for the namespace based on the maximum value of each type of resource in the metadata of the application, which may include a quota for computing resources and a quota for storage resources. Configure public middleware services. Deploy exclusive middleware services. Deploy dependent applications. Deploy version applications. Associate with continuous delivery environment. Configure automatic destruction tasks, specifically, configure the life cycle for the environment of the generated application, and the terminal can automatically delete the namespace in the cluster container when the life cycle is exceeded. Deleting the namespace can release the memory, that is, the resources used by the namespace can be released. Task end.
[0127] The resource management module in the above embodiment obtains application dependencies, image versions and resource data through application metadata. The automated deployment module dynamically generates a deployment pipeline according to the content to be deployed, and triggers the pipeline execution. Finally, the application deployment is implemented by calling the interface provided by Kuberenetes through the pipeline. The environment deployment method provided in this embodiment realizes automated environment deployment and delivery, significantly improves the speed of environment construction, reduces human configuration errors, and improves R&D efficiency; the namespace provides a flexible environment isolation mechanism, which can create or destroy the environment at any time as needed; it can also realize dynamic resource management to ensure that each environment intelligently adjusts resources according to real-time load, thereby improving resource utilization efficiency.
[0128] Furthermore, the environment deployment method provided in this embodiment uses the DNS resolution mechanism to achieve traffic isolation, providing a clear and independent operating environment for multi-version parallel development, further accelerating the iteration speed; ensuring the stability and consistency of the development environment, and providing strong support for multi-version parallel development.
[0129] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0130] Based on the same inventive concept, the embodiment of the present application also provides an environment configuration device for implementing the environment configuration method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more environment configuration device embodiments provided below can refer to the limitations on the environment configuration method above, and will not be repeated here.
[0131] In an exemplary embodiment, as shown in FIG8 , an environment configuration device 800 is provided, including:
[0132] The analysis module 802 is used to analyze the application image version record data when detecting the application version update, and obtain the current version and dependency relationship of the application; the dependency relationship includes the application that the application depends on;
[0133] A creation module 804 is used to create a namespace in the target cluster and set a resource quota for the namespace, where the quota includes a maximum value of computing resources and a maximum value of storage resources;
[0134] The generation module 806 is used to configure and generate an application environment for the application in the namespace based on the current version and dependency relationship of the application and the middleware corresponding to the application.
[0135] In one of the embodiments, the device further includes: a data acquisition module, configured to perform matching based on the current version of the application to obtain the image data of the application and the image data of the application's dependent applications.
[0136] In one of the embodiments, the device also includes: a screening module, which is used to screen multiple clusters based on the resource reservation value of the application's metadata and the replica data that the application needs to start, and determine the target cluster; a first determination module, which is used to determine the resource quota of the namespace based on the maximum value of the resources in the application's metadata.
[0137] In one of the embodiments, the generation module is specifically used to: determine the common middleware and exclusive middleware in the application based on the current version of the application; determine the application and the application on which the application depends based on the current version and dependencies of the application; configure the common middleware and exclusive middleware, the application and the application on which the application depends, respectively, based on a preset configuration template file, to obtain deployed data, and obtain the application environment of the application based on the deployed data.
[0138] In one of the embodiments, the generation module is specifically used to: determine a first configuration template file of the first type corresponding to the public middleware, and replace the configuration parameters in the first configuration template file based on the configuration parameters of the public middleware to obtain the deployed public middleware; determine a second configuration template file of the first type corresponding to the exclusive middleware, and replace the configuration parameters in the second configuration template file based on the configuration parameters of the exclusive middleware to obtain the deployed exclusive middleware; determine a third configuration template file of the second type corresponding to the application, and replace the configuration parameters in the third configuration template file based on the configuration parameters of the application to obtain the deployed application; determine a fourth configuration template file of the second type corresponding to the dependent application, and replace the configuration parameters in the fourth configuration template file based on the configuration parameters of the dependent application to obtain the deployed dependent application.
[0139] In one of the embodiments, the environment configures a life cycle; the device also includes: a deletion module, which is used to delete the namespace where the application environment is located when the life cycle of the application environment exceeds the cycle of the current version of the application to release the resources used by the namespace.
[0140] In one of the embodiments, the device also includes: a monitoring module, which is used to monitor the application load of the application in the namespace through a target monitoring tool; a second determination module, which is used to determine the amount of change in the application load if a change in the application load is detected, and to expand or reduce the resources of the namespace corresponding to the application based on the amount of change in the application load.
[0141] Each module in the above environment configuration device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0142] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG9. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store application data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an environment configuration method is implemented.
[0143] Those skilled in the art will understand that the structure shown in FIG. 9 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0144] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above embodiments when executing the computer program.
[0145] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above embodiments are implemented.
[0146] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above embodiments are implemented.
[0147] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0148] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0149] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0150] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An environment configuration method, characterized in that: The method comprises: When a version update of an application is detected, the application image version record data is analyzed to obtain the current version and dependency relationship of the application; the dependency relationship includes the application on which the application depends; Creating a namespace in the target cluster and setting a resource quota for the namespace, wherein the quota includes a maximum value of computing resources and a maximum value of storage resources; In the namespace, configuration is performed based on the current version and dependency relationship of the application and the middleware corresponding to the application to generate an application environment for the application.
2. The method according to claim 1, characterized in that: The method further comprises: Matching is performed based on the current version of the application to obtain the image data of the application and the image data of the application's dependent applications.
3. The method according to claim 1, characterized in that: The method further comprises: Based on the resource reservation value of the metadata of the application and the replica data that the application needs to start, screening is performed among multiple clusters to determine a target cluster; A resource quota of the namespace is determined based on a maximum value of resources in the metadata of the application.
4. The method according to claim 1, characterized in that: The step of configuring in the namespace based on the current version and dependency of the application and the middleware corresponding to the application to generate the application environment of the application includes: Based on the current version of the application, determine the public middleware and the exclusive middleware in the application; Determine the application and the applications on which the application depends based on the current version and dependency relationship of the application; Based on a preset configuration template file, the common middleware and exclusive middleware in the application, the application and the application on which the application depends are configured respectively to obtain deployed data, and the application environment of the application is obtained based on the deployed data.
5. The method according to claim 4, characterized in that The configuration of the public middleware and exclusive middleware in the application, the application and the application on which the application depends are configured based on the preset configuration template file to obtain deployed data, including: Determine a first configuration template file of a first type corresponding to the public middleware, and replace configuration parameters in the first configuration template file based on configuration parameters of the public middleware to obtain a deployed public middleware; Determine a second configuration template file of the first type corresponding to the exclusive middleware, and replace configuration parameters in the second configuration template file based on configuration parameters of the exclusive middleware to obtain the deployed exclusive middleware; Determine a third configuration template file of the second type corresponding to the application, and replace configuration parameters in the third configuration template file based on the configuration parameters of the application to obtain a deployed application; A fourth configuration template file of the second type corresponding to the dependent application is determined, and configuration parameters in the fourth configuration template file are replaced based on configuration parameters of the dependent application to obtain a deployed dependent application.
6. The method according to any one of claims 1 to 5, characterized in that: The environment configuration life cycle; the method also includes: When the life cycle of the application environment exceeds the life cycle of the current version of the application, the namespace where the application environment is located is deleted to release resources used by the namespace.
7. The method according to claim 1, characterized in that The method further comprises: Monitoring the application load of the application in the namespace by a target monitoring tool; If it is detected that the application load has changed, the amount of change in the application load is determined, and based on the amount of change in the application load, the resources of the namespace corresponding to the application are expanded or reduced.
8. An environment configuration device, characterized in that: The device comprises: An analysis module, configured to analyze the application image version record data when a version update of the application is detected, to obtain the current version and dependency relationship of the application; the dependency relationship includes the application on which the application depends; A creation module, used to create a namespace in the target cluster and set a resource quota for the namespace, wherein the quota includes a maximum value of computing resources and a maximum value of storage resources; A generation module is used to configure in the namespace based on the current version and dependency relationship of the application and the middleware corresponding to the application to generate an application environment for the application.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Message forwarding method and device, electronic equipment and storage medium
CN120710973A