Cloud native container configuration method and system, electronic equipment and storage medium
By using persistent volume technology in the cloud-native platform, the problem of inconsistent updates to container configuration files is solved, and the real-time consistency and dynamic configuration capabilities of container configuration files are improved.
Patent Information
- Application Number
- CN202511478504.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2026-01-23
AI Technical Summary
In cloud-native platforms, when using ConfigMap for container configuration, inconsistent updates of configuration files across containers lead to a decline in the ability to dynamically configure services.
The container cluster platform requests a persistent volume from the storage system through the configuration center and mounts the configuration file in read-write mode. When deploying the image file, the platform injects the persistent volume identifier and configuration file path to ensure that all containers mount the same persistent volume to obtain a consistent configuration file.
It achieves real-time consistency of container configuration files, improving the dynamic configuration capabilities and update efficiency of business applications.
Smart Images

Figure CN121387352A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of cloud computing, and in particular to a cloud-native container configuration method and system, an electronic device and a storage medium. BACKGROUND
[0002] Cloud-native is a software development and deployment approach that aims to build highly available, reliable and scalable application services by utilizing cloud computing, containerization and microservices. To implement cloud-native technology, a cloud-native platform needs to be built, and the construction of the cloud-native platform cannot be separated from containerization. Containerization is to package business applications and all dependencies together so that they can run in any container-supported environment. In this way, the business program can be started and deployed by running the image without manually running and installing the dependent package.
[0003] Since the core of containerization is to create and run containers using images, cloud-native platforms run business programs by running images. For example, a cloud-native platform is Kubernetes (a container orchestration engine, referred to as K8s). An image running is a pod (container). A business usually runs multiple containers to achieve load balancing to support more parallel business. However, after the container is running, many businesses need to dynamically modify the configuration information in a timely manner to meet the real-time needs of users. In related technologies, ConfigMap (a Kubernetes API (Application Programming Interface) object that stores non-confidential configuration data in the form of key-value pairs) is usually used to update configuration information. However, when using ConfigMap, because each node has its own synchronization period, many container configuration files of containers are not updated synchronously, so that at some moments, the container configuration files of some containers have been updated, while the container configuration files of other containers have not been updated. At this time, the container configuration files of each container are not completely consistent, which reduces the dynamic configuration capability of the business. SUMMARY
[0004] The purpose of the embodiments of the present application is to provide a cloud-native container configuration method and system, an electronic device and a storage medium to improve the consistency of the configuration files obtained by each container running the same business when configuring, and thus improve the dynamic configuration capability of the business. The specific technical solutions are as follows:
[0005] In a first aspect of the embodiments of the present application, a cloud-native container configuration method is provided, and the method comprises:
[0006] The configuration center applies at least one persistent volume to the storage system as a target persistent volume for a target service, and mounts all the target persistent volumes in read-write mode respectively, and writes a first configuration file of the target service to each of the target persistent volumes, the first configuration file being used to indicate an execution mode of the target service;
[0007] The container cluster platform injects an identifier of the target persistent volume, an image file of the target service, and a path of the first configuration file into the second configuration file to obtain an injected second configuration file, the second configuration file being used to indicate a deployment mode of a container for executing the target service, and the path of the first configuration file being used to indicate a position where the configuration file is expected to be mounted into the container;
[0008] The container cluster platform pushes the injected second configuration file to a container cluster;
[0009] Each target node in the container cluster deploys a container running the image file according to the deployment mode in response to the injected second configuration file, and mounts the target persistent volume into the container of each target node according to the mounting position, so that the container of each target node acquires and applies the first configuration file through the target persistent volume.
[0010] In a possible implementation, the method further includes:
[0011] The configuration center writes a new first configuration file to the target persistent volume in response to an update operation on the first configuration file;
[0012] The storage system sends an update notification to the container of each target node in response to being written with the new first configuration file, so that the container of each target node acquires and applies the new first configuration file through the target persistent volume.
[0013] In a possible implementation, the method further includes:
[0014] The container cluster platform sets read-write permissions of each target node for the target persistent volume to read-only permissions, where the read-write permissions of the target node are read-only permissions, and the target node can only read data from the target persistent volume but cannot write data to the target persistent volume.
[0015] In a possible implementation, the configuration center, the container cluster platform, and the storage system are physically isolated from each other.
[0016] In a second aspect, a cloud-native container configuration system is provided, including a configuration center, a storage system, and a container cluster platform.
[0017] The configuration center is configured to apply at least one persistent volume to the target service as a target persistent volume, and mount all the target persistent volumes in a read-write manner, and write a first configuration file of the target service to each target persistent volume, the first configuration file being used to indicate an execution mode of the target service.
[0018] The container cluster platform is configured to inject an identifier of the target persistent volume, an image file of the target service, and a path of the first configuration file into a second configuration file to obtain an injected second configuration file, the second configuration file being used to indicate a deployment mode of a container for executing the target service, and the path of the first configuration file being used to indicate a position where the configuration file is expected to be mounted into the container; and push the injected second configuration file to a container cluster, so that each target node in the container cluster deploys a container running the image file according to the deployment mode in response to the injected second configuration file, and mounts the target persistent volume into the container of each target node according to the mounting position, so that the container of each target node acquires and applies the first configuration file through the target persistent volume.
[0019] In a possible implementation, the configuration center is further configured to write a new first configuration file to the target persistent volume in response to an update operation on the first configuration file; and the storage system is further configured to send an update notification to the container of each target node in response to the new first configuration file being written, so that each container of each target node acquires and applies the new first configuration file through the target persistent volume.
[0020] In a possible implementation, the container cluster platform is further configured to set read-write permissions of each target node for the target persistent volume as read-only permissions, where the read-write permissions of each target node for the target persistent volume are read-only permissions, and each target node can only read data from the target persistent volume but cannot write data to the target persistent volume.
[0021] In a possible implementation, the configuration center, the container cluster platform, and the storage system are physically isolated from each other.
[0022] A third aspect of the embodiment of the application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus.
[0023] The memory is configured to store a computer program.
[0024] The processor is configured to drive the cloud-native container configuration system to implement the cloud-native container configuration method.
[0025] In another aspect of the embodiments of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program is configured to drive the cloud-native container configuration system to implement the cloud-native container configuration method when executed by a processor.
[0026] In another aspect of the embodiments of the present application, a computer program product is provided, and the computer program product comprises instructions which, when executed on a computer, cause the computer to perform the cloud-native container configuration method.
[0027] The cloud-native container configuration method, system, electronic device and storage medium provided by the embodiments of the present application can be used to configure a target business. The configuration center applies a target persistent volume to the target business from a storage system, and mounts the target persistent volume in a read-write mode. In this way, the configuration center can write and store a first configuration file of the target business in the target persistent volume. The container cluster platform injects an identifier of the target persistent volume, an image file of the target business and a path of the first configuration file into a second configuration file of the image of the target business, obtains an injected second configuration file, pushes the injected second configuration file to a container cluster, and deploys a container running the image file according to a deployment mode and mounts the target persistent volume to the container of each target node according to a mounting position. In this way, the container of each target node can obtain and apply the first configuration file in the target persistent volume through the target persistent volume. Since each container is mounted with the target persistent volume and the first configuration file of the target business is written in the target persistent volume, the container mounted with the target persistent volume can obtain and apply the first configuration file through the target persistent volume, without waiting for each container to be configured according to an update cycle. The real-time performance of configuring the first configuration file in each container is achieved. The consistency of the configuration file obtained by each container running the same business during configuration is improved, and the dynamic configuration capability of the business is improved. BRIEF DESCRIPTION OF DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or the prior art description will be briefly introduced.
[0029] Figure 1 The first schematic diagram of the cloud-native container configuration method provided by the embodiments of the present application;
[0030] Figure 2A second schematic diagram of the cloud-native container configuration method provided by the embodiments of the present application;
[0031] Figure 3 A third schematic diagram of the cloud-native container configuration method provided by the embodiments of the present application;
[0032] Figure 4 A flowchart of the cloud-native container configuration method provided by the embodiments of the present application;
[0033] Figure 5 A structural schematic diagram of the cloud-native container configuration system provided by the embodiments of the present application;
[0034] Figure 6 A structural schematic diagram of the electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0035] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
[0036] First, the professional terms in the embodiments of the present application are explained:
[0037] PV (Persistent Volume, persistent volume): a piece of storage in the cluster;
[0038] PVC (Persistent Volume Claim, persistent volume claim): a user's request for storage. When deploying an application service, the configuration file needs to specify the PV to be used. This claim is called PVC.
[0039] Mount: mapping the applied persistent volume as a storage volume to a specified path in the container to achieve data persistence.
[0040] YAML (YAML Ain't Markup Language, a markup language): in Kubernetes, YAML is a core configuration file format used to define and manage cluster resources.
[0041] Configuration center: a component or mechanism in the container orchestration engine used to centrally manage, distribute, and dynamically update application configurations.
[0042] Because in the cloud native platform, there is an uncertain delay problem in updating the container configuration using the core resource object for storing non-sensitive configuration data, the consistency of the configuration files in the containers of the same business is poor, which brings great unreliability to the business running, greatly affects the use experience of the cloud native platform, and affects the update efficiency and dynamic configuration capability of the business. In order to improve the consistency of the configuration files obtained by each container running the same business during configuration, and further improve the dynamic configuration capability of the business, the cloud native container configuration method, system, electronic device and storage medium provided by the embodiments of the present application can be understood. The cloud native platform in the embodiments of the present application can be K8s, or Mesos (a general cluster management framework supporting multiple workloads), or other cloud native platforms, which are not limited by the embodiments of the present application. Hereinafter, the cloud native container configuration method provided by the embodiments of the present application is described taking K8s as an example.
[0043] Referring to Figure 1 , Figure 1 The first schematic diagram of the cloud native container configuration method provided by the embodiments of the present application includes the following steps:
[0044] Step S10, the configuration center applies at least one persistent volume to the storage system for a target business as a target persistent volume, and respectively mounts all target persistent volumes in a read-write manner, and writes a first configuration file of the target business to each target persistent volume;
[0045] The first configuration file is used to indicate the execution mode of the target business;
[0046] Step S20, the container cluster platform injects the identifier of the target persistent volume, the image file of the target business and the path of the first configuration file in the second configuration file to obtain the injected second configuration file;
[0047] The second configuration file is used to indicate the deployment mode of the container executing the target business, and the path of the first configuration file is used to indicate the expected location when the configuration file is mounted into the container;
[0048] Step S30, the container cluster platform pushes the injected second configuration file to the container cluster;
[0049] Step S40, each target node in the container cluster deploys and runs the container with the image file according to the deployment mode in response to the injected second configuration file, and mounts the target persistent volume into the container of each target node according to the mounting position, so that the container of the target node obtains and applies the first configuration file through the target persistent volume.
[0050] With the embodiment of the present application, the configuration center applies a target persistent volume to the storage system for the target service, and mounts the target persistent volume in a read-write manner. In this way, the configuration center can separately write and store the first configuration file of the target service in the target persistent volume. The container cluster platform injects the identifier of the target persistent volume, the image file of the target service, and the path of the first configuration file into the second configuration file of the image of the target service, obtains the injected second configuration file, pushes the injected second configuration file to the container cluster, and each target node in the container cluster deploys and runs the container with the image file according to the deployment mode in response to the injected second configuration file, and mounts the target persistent volume to the container of each target node according to the mounting position, so that the container of each target node can obtain and apply the first configuration file in the target persistent volume through the target persistent volume. Since each container is mounted with the target persistent volume, and the first configuration file of the target service is written in the target persistent volume, the container mounted with the target persistent volume can obtain and apply the first configuration file through the target persistent volume, without waiting for each container to be configured according to the update cycle, achieving the same real-time performance as configuring the first configuration file locally in each container, improving the consistency of the configuration file obtained during configuration in each container running the same service, and further improving the dynamic configuration capability of the service.
[0051] The above steps S10-S40 will be described in detail as follows.
[0052] In the above step S10, the storage system refers to a storage service provided in a cloud platform or a cluster, or a block storage, a file storage, etc. provided by other cloud service providers. Applying at least one persistent volume refers to requesting a piece of persistent storage space from the storage system. The space will not lose data when the container is destroyed, and is used to store data related to the target service that needs to be stored for a long time, such as configuration files, database files, etc. of the target service. The target service is a specific application or service that is currently being deployed or managed, such as a web service, a microservice, etc.
[0053] In K8s, the persistent volume can be applied by predefining a StorageClass (a concept for managing storage resources in K8s), and K8s automatically creates the persistent volume according to the StorageClass, or by applying a PVC.
[0054] The mounting target persistent volume refers to the storage system giving the configuration center the right to directly access the target persistent volume. Directly accessing the target persistent volume refers to accessing the target persistent volume without the processor of the storage system. The mounting mode includes a read-write mode and a read-only mode. In the read-write mode, the configuration center can directly read data in the mounted persistent volume and write data into the mounted persistent volume without the processor of the storage system. In the read-only mode, the configuration center can directly read data in the mounted persistent volume without the processor of the storage system, but cannot write data into the mounted persistent volume.
[0055] After the configuration center mounts the target persistent volume in the read-write mode, the configuration center writes the first configuration file of the target service into the target persistent volume. The first configuration file is used to indicate the execution mode of the target service, including a parameter setting file on which the target service depends, such as a database connection string, a service port, a log configuration, and the like.
[0056] In the above step S20, the container cluster platform, that is, the cloud native platform in the foregoing, is, for example, K8s. The second configuration file is a file owned by the container cluster platform and used to describe user configuration requirements, and the user requirements include but are not limited to the deployment mode of the container of the target service. In K8s, the second configuration file is usually a YAML file, and the YAML file is written by injection when the application is deployed. The YAML file is used to define and manage K8s cluster resources, such as Deployment (deployment), Service (service), and containers.
[0057] The image file of the target service refers to a Docker (an application container engine) image corresponding to the target service to be deployed. The image file of the target service is injected in the YAML configuration, which is used to tell K8s which image file to run.
[0058] The identifier of the target persistent volume can be the name of the target persistent volume, or any other information that can uniquely identify the target persistent volume. For example, if the name of the target persistent volume applied in the above step S10 is “myapp-pvc”, the identifier of the target persistent volume is “myapp-pvc”.
[0059] The path of the configuration file refers to the access path of the configuration file in the container, which determines that the application in the container can correctly read the configuration file. The path of the configuration file can be manually specified or automatically allocated, and the embodiments of the present application do not limit this.
[0060] After the identification of the target persistent volume, the image file of the target service, and the path of the configuration file are injected in the second configuration file, the second configuration file describes how to run the application, including which image (i.e., the image file of the target service) to use, which persistent volume (i.e., the target persistent volume) to mount, and which path (i.e., the path of the configuration file) in the container to mount the configuration file.
[0061] In the step S30, the container cluster is a cluster managed by the container cluster platform, and the container cluster is composed of multiple nodes. The container cluster platform pushes the second configuration file to the container cluster, which can be deployed to the container cluster by a command, such as a K8s cluster deployed by a kubectl apply (a core command for declarative resource management in K8s) command, or deployed to the container cluster by other means.
[0062] In the step S40, each target node in the container cluster deploys and runs the container with the image file according to the deployment manner of the injected second configuration file, which means that the target node creates and runs the container according to the deployment manner indicated by the second configuration file, and pulls the image file specified in the second configuration file to start the service.
[0063] Mounting the target persistent volume to the container of each target node according to the mounting position means mounting the target persistent volume to the specified path of the container of each target node, so that the container can access the first configuration file in the target persistent volume through the specified path. After the container of the target node reads the first configuration file from the target persistent volume mounted by the container, the container can start or configure the service according to the first configuration file.
[0064] It can be understood that the number of nodes in the container cluster is multiple, and the target node can be all nodes in the container cluster, or a specified part of the nodes in the container cluster, or a node scheduled by the container cluster. The container cluster can be randomly scheduled, or scheduled by a load balancing strategy, or scheduled by other means, which is not limited by the embodiments of the present application.
[0065] For example, after the K8s cluster receives the injected YAML file pushed by K8s, the K8s cluster can schedule multiple nodes of the K8s cluster according to the YAML file, run the image file of the target service in the container of the scheduled node, and mount the target persistent volume to the container in the target node according to the path of the configuration file in the YAML file, that is, map the configuration file of the target service from the target persistent volume to the specified path in the container.
[0066] Through the steps S10-S40, each container running the target service can directly access the first configuration file in the container through the mounted target persistent volume, so that the configuration of each container can be completed. It can be understood that, since each container running the same target service mounts the same target persistent volume, it is equivalent that each container running the same target service accesses the same storage space, and therefore, when the first configuration file of the target service needs to be updated, the updated first configuration file can be stored in the target persistent volume, and the container mounting the target persistent volume reacquires the first configuration file through the target persistent volume and applies it.
[0067] Based on this, in a possible implementation, as shown in FIG. 6, a cloud-native container configuration method provided by an embodiment of the present application includes the following steps: Figure 2 FIG. 6 shows a second schematic diagram of a cloud-native container configuration method provided by an embodiment of the present application, and the method includes the following steps:
[0068] Step S10, the configuration center applies at least one persistent volume to a storage system for a target service as a target persistent volume, and mounts all target persistent volumes in a read-write manner, respectively, and writes a first configuration file of the target service to each target persistent volume;
[0069] Step S20, the container cluster platform injects the identifier of the target persistent volume, the image file of the target service, and the path of the first configuration file into the second configuration file to obtain an injected second configuration file;
[0070] Step S30, the container cluster platform pushes the injected second configuration file to a container cluster;
[0071] Step S40, each target node in the container cluster deploys a container running the image file according to a deployment mode in response to the injected second configuration file, and mounts the target persistent volume to the container of each target node according to a mounting position, so that the container of the target node acquires and applies the first configuration file through the target persistent volume.
[0072] Step S501, the configuration center writes a new first configuration file to the target persistent volume in response to an update operation on the first configuration file;
[0073] Step S502, the storage system sends an update notification to the container of each target node in response to the new first configuration file being written, so that the container of each target node acquires and applies the new first configuration file through the target persistent volume.
[0074] Steps S10-S40 are described above, and will not be described here again.
[0075] In step S501, the update operation of the first configuration file can be an operation of manually modifying the configuration file by a developer or an operation of automatically changing the configuration by the configuration center, an operation of dynamically adjusting the configuration parameter according to the runtime strategy, or any other operation that causes the configuration file to change, which is not limited in the embodiments of the present application.
[0076] In step S502, writing the new first configuration file to the target persistent volume can mean storing the new first configuration file in the target persistent volume, or modifying the parameters of the first configuration file in the target persistent volume to obtain the new first configuration file, which is acceptable. It can be understood that in order to distinguish the updated first configuration file, the version identification method can be used for distinction.
[0077] For example, assuming that the first configuration file stored in the target persistent volume is version 1 of the first configuration file, when the operator modifies the first configuration file, sets the version identification of the modified first configuration file to version 2, and inputs the first configuration file update instruction including the version 2 of the first configuration file modified by the operator, the configuration center deletes the version 1 of the configuration file in the target persistent volume and writes the version 2 of the configuration file into the target persistent volume after receiving the configuration file update instruction.
[0078] According to the embodiments of the present application, when the execution mode of the target service needs to be updated, the first configuration file is updated in the target persistent volume, so that each container running the target service can obtain the latest first configuration file in real time. Compared with using the updated first configuration file to configure each container respectively, the consistency and real-time performance of the first configuration file obtained by each container are improved, and the update efficiency of the target service is improved.
[0079] It can be understood that when the target persistent volume is mounted to the container of the target node, it can be mounted in a read-write mode. Since each container does not need to write data to the target storage volume, but only reads the configuration file from the target storage volume, in order to prevent the configuration file from being accidentally modified or damaged and improve the security and stability of the target service, in one possible implementation, the mounting mode of the target persistent volume to the container of the target node can be set to a read-only mode by a pre-declaration manner. For example, in a K8s cluster, the mounting permission of the target persistent volume to the container can be declared as read-only in the container definition, or the mounting permission of the target persistent volume can be predefined as read-only by the StorageClass, or the mounting mode of the target persistent volume to the container can be pre-declared in other ways, which is not limited in the present application.
[0080] In another possible implementation, the target persistent volume can also be set to read-only by subsequent modification. As shown in Figure 3 Fig. 3 shows a third schematic diagram of a cloud-native container configuration method provided by an embodiment of the present application, the method comprising the following steps:
[0081] In step S10, the configuration center applies at least one persistent volume for the target service to the storage system as a target persistent volume, and mounts all target persistent volumes in a read-write manner respectively, and writes a first configuration file of the target service to each target persistent volume;
[0082] In step S20, the container cluster platform injects the identifier of the target persistent volume, the image file of the target service, and the path of the first configuration file into the second configuration file to obtain an injected second configuration file;
[0083] In step S30, the container cluster platform pushes the injected second configuration file to the container cluster;
[0084] In step S40, each target node in the container cluster deploys and runs a container with the image file according to the deployment mode in response to the injected second configuration file, and mounts the target persistent volume to the container of each target node according to the mounting position, so that the container of the target node obtains and applies the first configuration file through the target persistent volume.
[0085] In step S60, the container cluster platform sets the read-write permission of each target node for the target persistent volume to a read-only permission;
[0086] When the read-write permission of the target node is a read-only permission, the target node can only read data from the target persistent volume and cannot write data to the target persistent volume.
[0087] It can be understood that in this embodiment, step S60 is performed after step S40, and when the target persistent volume is mounted to the container in step S40, the mounting mode can not be set, and the mounting mode of the target persistent volume is set through step S60; or the target persistent volume can be mounted to the container in a default mode in step S40, and then the mounting mode of the target persistent volume is modified through step S60, wherein the default mode can be a read-write mode, a read-only mode, or other modes, and the present application does not limit this.
[0088] In the above embodiment, the configuration center, the storage system, and the container cluster platform in the foregoing steps S10-S40 can belong to different modules of the same electronic device, or the configuration center and the storage system can belong to the same electronic device, and the storage system and the container cluster platform can not belong to the same electronic device.
[0089] It can be understood that after the first configuration file of the target service is configured, the storage system and the configuration center may not be needed for a period of time, and in order to save resources, the electronic device to which the storage system and the configuration center belong can be powered off or maintained in a low-power sleep state.
[0090] However, in some scenarios, the storage system may store configuration files of different services, and other services also need to be configured. In this case, if the electronic device to which the storage system and the configuration center belong is powered off or controlled to enter a sleep state after the configuration file of the target service is configured, the normal operation of other services may be affected.
[0091] Therefore, in a possible implementation, the configuration center, the storage system, and the container cluster platform belong to different electronic devices, and the configuration center, the container cluster platform, and the storage system are physically isolated from each other. Thus, even if the configuration center is attacked, the impact on the storage system and the container cluster platform is small, and the security risk is reduced.
[0092] In the following, the configuration center is set in device A, the storage system is set in device B, and the container cluster platform is set in device C. Device A, device B, and device C are different devices. The cloud-native container configuration method provided in the embodiments of the present application is described in detail in combination with specific embodiments.
[0093] As shown in FIG. 1, the cloud-native container configuration method provided in the embodiments of the present application includes the following steps: Figure 4
[0094] ①The configuration center set in device A applies to create a persistent volume, and then mounts the persistent volume in a read-write manner, so as to support the configuration center to read and write data from the target persistent volume (i.e., the configuration center applies to create at least one persistent volume for the target service as the target persistent volume, and mounts all target persistent volumes in a read-write manner in step S10 described above).
[0095] ②When the configuration center applies to create a persistent volume, the interface of the storage system set in device B is called to create a storage address of a unique persistent volume (i.e., the target persistent volume) of the target service in real time.
[0096] ③The configuration file (i.e., the first configuration file) required by the target service, such as app.config, can be an empty file or a file filled with configuration information. The uploaded first configuration file is stored in the target persistent volume.
[0097] If the configuration file needs to be modified later, the app.config is modified through the configuration center, and the modified data is written into the persistent volume created and mounted in ① (i.e., the aforementioned step S501) in real time. After modification, the storage system notifies each node scheduled in step ⑥, so that each node obtains and applies the modified app.config (i.e., the aforementioned step S502).
[0098] ⑤Deploy the image using the container cluster platform. When creating the deployment, fill in the persistent volume information of the configuration file (i.e., the identifier of the target persistent volume) and the configuration file path to be mounted (i.e., the path of the first configuration file) through the container cluster platform. The container cluster platform will automatically inject the above information and read-only permission into YAML (i.e., the aforementioned step S20). Then the container cluster platform pushes the injected YAML to k8s (i.e., the aforementioned step S30).
[0099] ⑥After receiving the YAML file from the container cluster platform, the K8s cluster will schedule nodes to deploy the image. Suppose it is scheduled to node 1 and node 2. These two nodes run the image file defined by the user in YAML, and mount the target persistent volume to the specified directory (i.e., mount the target persistent volume to the container of each target node according to the mounting position in the aforementioned step S40), so that the app.config mounted in the container of node 1 and node 2 simultaneously points to the persistent volume created in ① and ② (i.e., the aforementioned step S40).
[0100] Through the above steps ①-⑥, by modifying the configuration file app.config in the configuration center, the modified configuration file can be written into the target persistent volume in real time, and the container mounted with the target persistent volume can immediately read the app.config data in the target persistent volume.
[0101] Corresponding to the first aspect described above, the second aspect of the embodiments of the present application provides a cloud-native container configuration system, as shown in Figure 5 The structure of the cloud-native container configuration system provided by the embodiments of the present application is shown in the figure, which includes a configuration center 501, a storage system 502, and a container cluster platform 503.
[0102] The configuration center 501 is configured to apply at least one persistent volume to the storage system 502 for a target business as a target persistent volume, and mount all the target persistent volumes in a read-write manner, and write a first configuration file of the target business to each target persistent volume, wherein the first configuration file is used to indicate the execution mode of the target business.
[0103] The container cluster platform 503 is configured to inject the identifier of the target persistent volume, the image file of the target service, and the path of the first configuration file into the second configuration file to obtain an injected second configuration file, where the second configuration file is used to indicate a deployment manner of a container for executing the target service, and the path of the first configuration file is used to indicate a position where the configuration file is expected to be mounted into the container; and the injected second configuration file is pushed to the container cluster, so that each target node in the container cluster deploys the container running the image file according to the deployment manner in response to the injected second configuration file, and mounts the target persistent volume into the container of each target node according to the mounting position, so that the container of each target node acquires and applies the first configuration file through the target persistent volume.
[0104] According to the embodiment of the present application, the configuration center 501 applies for a target persistent volume for the target service from the storage system 502, and mounts the target persistent volume in a read-write manner, so that the configuration center 501 can separately write and store the first configuration file of the target service into the target persistent volume. The container cluster platform 503 injects the identifier of the target persistent volume, the image file of the target service, and the path of the first configuration file into the second configuration file of the target service to obtain an injected second configuration file, and then pushes the injected second configuration file to the container cluster. Each target node in the container cluster deploys the container running the image file according to the deployment manner in response to the injected second configuration file, and mounts the target persistent volume into the container of each target node according to the mounting position, so that the container of each target node can acquire and apply the first configuration file in the target persistent volume through the target persistent volume. Since each container is mounted with the target persistent volume, and the first configuration file of the target service is written into the target persistent volume, the container mounted with the target persistent volume can acquire and apply the first configuration file through the target persistent volume, without waiting for each container to be configured according to an update period, so that the same real-time performance as that of configuring the first configuration file locally in each container is achieved, the consistency of the configuration file acquired by each container during configuration is improved, and the dynamic configuration capability of the service is improved.
[0105] In a possible implementation, the configuration center 501 is further configured to write a new first configuration file into the target persistent volume in response to an update operation on the first configuration file; and the storage system 502 is further configured to send an update notification to the container of each target node in response to the new first configuration file being written, so that each target node acquires and applies the new first configuration file through the target persistent volume.
[0106] In a possible implementation, the container cluster platform 503 is further configured to set read-write permissions of each target node for the target persistent volume to read-only permissions, wherein when the read-write permissions of the target node are read-only permissions, the target node can only read data from the target persistent volume and cannot write data to the target persistent volume.
[0107] In a possible implementation, the configuration center 501, the container cluster platform 503, and the storage system 502 are physically isolated from each other.
[0108] The embodiments of the present application also provide an electronic device, such as Figure 6 As shown in the figure, the electronic device includes a processor 601, a communication interface 602, a memory 603, and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 complete mutual communication through the communication bus 604,
[0109] The memory 603 is configured to store a computer program.
[0110] The processor 601 is configured to drive the cloud-native container configuration system to implement the following steps when executing the program stored in the memory 603:
[0111] The configuration center applies at least one persistent volume to the storage system for a target service as a target persistent volume, and mounts all the target persistent volumes in a read-write manner, and writes a first configuration file of the target service to each target persistent volume, wherein the first configuration file is used to indicate an execution manner of the target service.
[0112] The container cluster platform injects an identifier of the target persistent volume, an image file of the target service, and a path of the first configuration file in a second configuration file to obtain an injected second configuration file, wherein the second configuration file is used to indicate a deployment manner of a container for executing the target service, and the path of the first configuration file is used to indicate an expected location when the configuration file is mounted into the container.
[0113] The container cluster platform pushes the injected second configuration file to a container cluster.
[0114] Each target node in the container cluster deploys a container running the image file according to the deployment manner in response to the injected second configuration file, and mounts the target persistent volume into the container of each target node according to the mounting position, so that the container of the target node acquires and applies the first configuration file through the target persistent volume.
[0115] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.
[0116] The communication interface is used for communication between the terminal and other devices.
[0117] The memory can include a Random Access Memory (RAM) and can also include a non-volatile memory such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the processor.
[0118] The processor mentioned above can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc. It can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.
[0119] In another embodiment provided in the present application, a computer readable storage medium is also provided, and the computer readable storage medium stores a computer program. When the computer program is executed by a processor, the cloud native container configuration system is driven to implement the cloud native container configuration method in any of the above embodiments.
[0120] In another embodiment provided in the present application, a computer program product containing instructions is also provided, and when the computer program product is run on a computer, the computer is caused to execute the cloud native container configuration method in any of the above embodiments.
[0121] In the embodiments described above, all or some of the steps can be implemented by hardware, software, firmware or any combination thereof. When implemented by software, all or some of the steps can be implemented in the form of one or more computer programs or program elements. The computer programs reside (at least temporarily) in a memory of a computer during execution. The memory can be a RAM memory, a flash memory, a ROM memory, an EPROM memory, or any other suitable memory. The memory can be integral to or separate from the computer. The computer programs can be written in any suitable programming language, such as C, C++, Java, Visual Basic, etc. The computer programs can be written in assembly or machine language, if desired. The computer programs can be distributed over network coupled file servers, or can be distributed by any other suitable means.
[0122] It is to be noted that, in the present document, relational terms such as first and second and the like can be used solely to distinguish one entity or action from another entity or action without necessarily implying any actual relationship or order between such entities or actions. Also, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. In addition, terms such as "first" and "second" are used herein only to distinguish one element from another, without necessarily implying any actual relationship or order between such elements.
[0123] Each of the embodiments described in the present specification is described in a related manner, and the same or similar parts between the embodiments can be mutually referred to. Each of the embodiments mainly describes the difference from other embodiments. In particular, for the system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments.
[0124] The above merely provides the preferred embodiments of the application, and not intended to limit the protection scope of the application. Any modification, equivalent replacement, improvement, and the like made within the principle and technical scope of the application shall fall into the protection scope of the application.
Claims
1. A cloud-native container configuration method, characterized in that, The method includes: The configuration center requests at least one persistent volume from the storage system for the target service as the target persistent volume, and mounts all the target persistent volumes in read-write mode respectively. In addition, it writes the first configuration file of the target service to each of the target persistent volumes. The first configuration file is used to indicate the execution mode of the target service. The container cluster platform injects the identifier of the target persistent volume, the image file of the target service, and the path of the first configuration file into the second configuration file to obtain the injected second configuration file. The second configuration file is used to indicate the deployment method of the container executing the target service, and the path of the first configuration file is used to indicate the expected location when the configuration file is mounted in the container. The container cluster platform pushes the injected second configuration file to the container cluster; In response to the injected second configuration file, each target node in the container cluster deploys and runs a container containing the image file according to the deployment method, and mounts the target persistent volume to the container of each target node according to the mount location, so that the container of the target node can obtain and apply the first configuration file through the target persistent volume.
2. The method of claim 1, wherein, The method further includes: In response to an update operation on the first configuration file, the configuration center writes a new first configuration file to the target persistent volume; The storage system, in response to being written with a new first configuration file, sends an update notification to the containers of each of the target nodes, so that the containers of each of the target nodes can obtain and apply the new first configuration file through the target persistent volume.
3. The method of claim 1, wherein, The method further includes: The container cluster platform sets the read and write permissions of each target node for the target persistent volume to read-only. When the read and write permissions of the target node are read-only, the target node can only read data from the target persistent volume and cannot write data to the target persistent volume.
4. The method according to claim 1, characterized in that, The configuration center, the container cluster platform, and the storage system are physically isolated from each other.
5. A cloud-native container configuration system, characterized in that, The system includes a configuration center, a storage system, and a container cluster platform; The configuration center is used to request at least one persistent volume from the storage system for the target service as the target persistent volume, and to mount all the target persistent volumes in read-write mode respectively, and to write the first configuration file of the target service to each of the target persistent volumes, wherein the first configuration file is used to indicate the execution mode of the target service; The container cluster platform is used to inject the identifier of the target persistent volume, the image file of the target service, and the path of the first configuration file into the second configuration file to obtain the injected second configuration file. The second configuration file is used to indicate the deployment method of the container executing the target service, and the path of the first configuration file is used to indicate the expected location when the configuration file is mounted in the container. The injected second configuration file is pushed to the container cluster, so that each target node in the container cluster responds to the injected second configuration file, deploys and runs a container with the image file according to the deployment method, and mounts the target persistent volume to the container of each target node according to the mount location, so that the container of the target node obtains and applies the first configuration file through the target persistent volume.
6. The system according to claim 5, characterized in that, The configuration center is further configured to write a new first configuration file to the target persistent volume in response to an update operation on the first configuration file; the storage system is further configured to send an update notification to the containers of each target node in response to the new first configuration file being written, so that the containers of each target node can obtain and apply the new first configuration file through the target persistent volume.
7. The system according to claim 5, characterized in that, The container cluster platform is further configured to set the read and write permissions of each target node for the target persistent volume to read-only permissions. When the read and write permissions of the target node are read-only, the target node can only read data from the target persistent volume and cannot write data to the target persistent volume.
8. The system according to claim 5, characterized in that, The configuration center, the container cluster platform, and the storage system are physically isolated from each other.
9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; When a processor executes a program stored in memory, it drives a cloud-native container configuration system to implement the steps of the method described in any one of claims 1-4.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, drives the cloud-native container configuration system to implement the steps of the method described in any one of claims 1-4.