CN117369940A - Method and device for dynamically migrating persistent storage resources based on K8S cluster - Google Patents

Method and device for dynamically migrating persistent storage resources based on K8S cluster Download PDF

Info

Publication number
CN117369940A
CN117369940A CN202311108776.0A CN202311108776A CN117369940A CN 117369940 A CN117369940 A CN 117369940A CN 202311108776 A CN202311108776 A CN 202311108776A CN 117369940 A CN117369940 A CN 117369940A
Authority
CN
China
Prior art keywords
cluster
persistent
target
data
storage resource
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311108776.0A
Other languages
Chinese (zh)
Inventor
杨建春
徐辉
吴鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Clp Tongshang Digital Technology Shanghai Co ltd
Original Assignee
Clp Tongshang Digital Technology Shanghai Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Clp Tongshang Digital Technology Shanghai Co ltd filed Critical Clp Tongshang Digital Technology Shanghai Co ltd
Priority to CN202311108776.0A priority Critical patent/CN117369940A/en
Publication of CN117369940A publication Critical patent/CN117369940A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for dynamically migrating persistent storage resources based on a K8S cluster, wherein the method comprises the following steps: acquiring available storage resource information of a K8S cluster; determining a target node to be migrated according to the available storage resource information, and creating a target persistent volume at the target node; migrating data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool; updating the application program configuration of the target node according to the migrated data, and verifying and cleaning the data in the target persistent volume according to the updated application program configuration; the invention realizes the dynamic migration of the persistent storage resources under the K8S cluster, ensures the consistency of data, and ensures that the aspects of application performance, migration durability and the like are not affected.

Description

Method and device for dynamically migrating persistent storage resources based on K8S cluster
Technical Field
The invention relates to the technical field of K8S clusters, in particular to a method and a device for dynamically migrating persistent storage resources based on a K8S cluster.
Background
LocalPV (Local Persistent Volume ) is a persistent volume storage type in Kubernetes (K8S for short) that binds storage directly to local storage media on a host node, rather than accessing remote storage over a network. It has the following characteristics and advantages:
1. low delay: since the LocalPV is directly connected to the local storage medium on the host node, a lower storage access latency can be achieved, which is very advantageous for some applications with higher performance requirements.
2. High throughput: the LocalPV avoids the overhead of accessing remote storage through a network, can realize higher storage throughput, and is suitable for a workload which needs a large amount of data reading and writing.
3. Is applicable to a particular workload: localPV is commonly used for workloads that require direct manipulation of storage media, such as databases or distributed file systems.
4. High reliability: local storage is typically highly reliable and redundant because they are typically based on RAID or other redundant storage technologies. This makes LocalPV very useful for some applications where data reliability is a high requirement.
However, localPV also has some limitations and disadvantages:
1. limited mobility: because the LocalPV is directly bound to the local storage medium on the host node, it does not have cross-node migratability. This means that when the node where the Pod is located fails or needs to migrate, the data on the LocalPV may be lost or inaccessible.
2. Limited extensibility: localPV is typically limited to storage on a single node, and thus cannot achieve extensibility across multiple nodes. If greater storage capacity or higher scalability is desired, other types of storage solutions, such as network storage, may need to be considered.
3. Configuration complexity: the use of LocalPV requires manual configuration and requires storage media on a particular node. This may increase the complexity of management and configuration.
4. Data security and persistence: since LocalPV does not provide data replication or backup functionality, node failure or storage medium failure may result in data loss. When using LocalPV, backup and restore policies for data need to be considered.
Thus, careful consideration of workload requirements and constraints is required in deciding to use LocalPV and ensuring that appropriate measures are taken in terms of data security and reliability.
Disclosure of Invention
The invention aims to solve the technical problem that the invention provides a method and a device for dynamically migrating persistent storage resources based on a K8S cluster to solve the problem that the persistent storage resources under the K8S cluster cannot realize dynamic migration.
The technical scheme adopted for solving the technical problems is as follows:
in a first aspect, the present invention provides a method for dynamically migrating persistent storage resources based on a K8S cluster, including:
acquiring available storage resource information of a K8S cluster;
determining a target node to be migrated according to the available storage resource information, and creating a target persistent volume at the target node;
migrating data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool;
updating the application program configuration of the target node according to the migrated data, and verifying and cleaning the data in the target persistent volume according to the updated application program configuration.
In one implementation, obtaining available storage resource information for a K8S cluster includes:
and periodically collecting resource measurement indexes of each node, and analyzing to obtain the available storage resource information of the K8S cluster, wherein the resource measurement indexes comprise: CPU usage, memory usage, disk I/O, network I/O, and file system information.
In one implementation, the periodically collecting the resource metric index of each node, analyzing to obtain the available storage resource information of the K8S cluster includes:
calculating the resource measurement of each node through an operation model to obtain different scores;
judging whether the measurement index of the corresponding node is an available storage resource according to the scoring;
if the score is 0, judging the corresponding node as unavailable storage resource;
and if the score is 1, judging the corresponding node as the available storage resource.
In one implementation, the creating, at the target node, a target persistent volume includes:
generating persistent volume information of mounting information corresponding to a local persistent volume of the target node according to the available storage resource information;
generating a mounting script according to the persistent volume information, and executing corresponding mounting operation through the mounting script;
binding the local persistent volume with a persistent volume claim request to obtain the target persistent volume.
In one implementation, the migration of data to be migrated in a source persistent volume to the target persistent volume by a backup and migration tool includes:
and migrating the data to be migrated in the source persistent volume to the target persistent volume through the backup and migration tool, triggering the job resource through an HTTP POST request, and carrying out data synchronization after the target node mounts the catalog.
In one implementation, the updating the application configuration of the target node according to the migrated data includes:
and when the data to be migrated is successfully migrated, generating a new workload mode of the application program of the target node, mounting a local persistent volume of the target node, and executing pod creation, pod starting and pod running processes.
In one implementation, the verifying and cleaning the data in the target persistent volume according to the updated application configuration includes:
according to the updated application program configuration, verifying whether the application program can normally access and use the new persistent volume, ensuring the integrity and consistency of data, and verifying the functions of the application program;
and deleting the old persistent volume and the persistent volume claim request according to the verification result, and deleting the left-over workload data.
In a second aspect, the present invention provides a device for dynamically migrating persistent storage resources based on a K8S cluster, including:
the acquisition module is used for acquiring the available storage resource information of the K8S cluster;
the target persistent volume creation module is used for determining a target node to be migrated according to the available storage resource information and creating a target persistent volume at the target node;
the data migration module is used for migrating data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool;
and the verification and cleaning module is used for updating the application program configuration of the target node according to the migrated data and verifying and cleaning the data in the target persistent volume according to the updated application program configuration.
In a third aspect, the present invention provides a terminal comprising: the system comprises a processor and a memory, wherein the memory stores a K8S cluster-based persistent storage resource dynamic migration program, and the K8S cluster-based persistent storage resource dynamic migration program is used for realizing the operation of the K8S cluster-based persistent storage resource dynamic migration method according to the first aspect when being executed by the processor.
In a fourth aspect, the present invention further provides a medium, where the medium is a computer readable storage medium, where the medium stores a K8S cluster-based persistent storage resource live migration program, where the K8S cluster-based persistent storage resource live migration program is used to implement the operations of the K8S cluster-based persistent storage resource live migration method according to the first aspect when the K8S cluster-based persistent storage resource live migration program is executed by a processor.
The technical scheme adopted by the invention has the following effects:
the method and the device can determine the target node to be migrated according to the available storage resource information by acquiring the available storage resource information of the K8S cluster, and create the target persistent volume at the target node; migrating the data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool, updating the application program configuration of the target node according to the migrated data, and verifying and cleaning the data in the target persistent volume according to the updated application program configuration; the invention realizes the dynamic migration of the persistent storage resources under the K8S cluster, ensures the consistency of data, and ensures that the aspects of application performance, migration durability and the like are not affected.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to the structures shown in these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for dynamically migrating persistent storage resources based on a K8S cluster in one implementation of the invention.
FIG. 2 is a schematic diagram of data migration in one implementation of the invention.
Fig. 3 is a functional schematic of a terminal in one implementation of the invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more clear and clear, the present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
At present, the local persistent volume has the defects of limited migration, limited expansibility, configuration complexity, poor data security and durability and the like, so that operations such as copying, synchronization and coordination among nodes of dynamic migration of the local persistent volume are complicated, and consistency of migration data and runnability of application programs are difficult to ensure; thus, existing migration schemes for local persistent volumes also have difficulty in achieving dynamic migration of local persistent volume data.
In view of the above problems, in the embodiment of the present invention, a method for dynamically migrating persistent storage resources based on a K8S cluster is provided, where the method may determine a target node to be migrated according to available storage resource information by acquiring the available storage resource information of the K8S cluster, and create a target persistent volume at the target node; migrating the data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool, updating the application program configuration of the target node according to the migrated data, and verifying and cleaning the data in the target persistent volume according to the updated application program configuration; therefore, the embodiment of the invention can realize the dynamic migration of the persistent storage resources under the K8S cluster, ensure the consistency of data, and ensure that the aspects of application performance, migration durability and the like are not affected.
Exemplary method
As shown in fig. 1, an embodiment of the present invention provides a method for dynamically migrating persistent storage resources based on a K8S cluster, including the following steps:
and step S100, obtaining the available storage resource information of the K8S cluster.
In this embodiment, dynamic migration of LocalPV (i.e., local persistent volumes) is a challenging technical problem in Kubernetes clusters (i.e., K8S clusters). Because the LocalPV is directly bound to the local storage medium on the host node, operations such as copying, synchronization, coordination between nodes, and the like, which involve data, become complicated in the live migration. At present, kubernetes clusters do not support dynamic migration of LocalPV in a native manner, and the effects of data consistency, performance influence, migration time and the like in the dynamic migration process can be solved through the dynamic migration method and the coordination system in the embodiment.
In the embodiment, the main scheme is a process of realizing static pv (i.e. persistent volume) dynamic migration based on a Kubernetes cluster; where the persistent volume (PersistentVolume, PV) is a block of Storage in a cluster, it may be prepared in advance by an administrator or dynamically using a Storage Class (Storage Class). Persistent volumes are cluster resources as nodes are cluster resources. PV persistent volumes are implemented using Volume plug-ins as is common with Volume, except that they have a lifecycle independent of any Pod container using PV. Thus, implementation details of storage are described in the API object, whether it is NFS, iSCSI, or cloud platform specific storage systems behind it.
In this embodiment, a new operator is created mainly under the local pv mode of the kubernetes cluster, taking the fact that the pod container cannot dynamically drift as a criterion, so as to realize automatic and manual migration of the pod container to other working nodes, and after the nodes are manually selected or the weight nodes are automatically calculated, the pod after the file transfer is executed to reload the file.
Specifically, in one implementation of the present embodiment, step S100 includes the steps of:
step S101, periodically collecting resource metric indexes of each node, and analyzing to obtain available storage resource information of the K8S cluster, where the resource metric indexes include: CPU usage, memory usage, disk I/O, network I/O, and file system information.
In this embodiment, it is necessary to ensure that there are enough storage resources available in the kubernetes cluster: that is, before the dynamic migration of the PV, it is first ensured that there are enough storage resources available on the target node to avoid errors in the data during the dynamic migration process.
In determining available storage resources, a cAdvisor (Container Advisor, container optimization tool) may be used to gather information about container and host resource usage. cAdvisor is an open-source vessel monitoring and performance analysis tool widely used in the Kubernetes cluster. The cAdvisor periodically gathers the resource metrics of the container and host through proxy processes running on each node and provides an HTTP interface for other components (e.g., kubelet components) to query.
The Kubelet component may use the interface of the cAdvisor to obtain real-time metric data of the node resources. cAdvisor provides a rich resource metric that includes, but is not limited to, the following:
1. CPU utilization: the CPU usage of the container and host includes: total CPU usage, CPU usage per container, etc.
2. Memory utilization rate: the memory use cases of the container and the host include: total memory usage, memory usage per container, etc.
3. Disk I/O: disk read and write operations and throughput for containers and hosts.
4. Network I/O: network traffic, bandwidth, and number of connections for the container and host.
5. File system: disk usage (system disk and data disk), file system type, and container file system information.
Specifically, in one implementation of the present embodiment, step S101 includes the steps of:
step S101a, calculating the resource measurement of each node through an operation model to obtain different scores;
step S101b, judging whether the measurement index of the corresponding node is an available storage resource according to the grading;
step S101c, if the score is 0, determining that the corresponding node is an unavailable storage resource;
in step S101d, if the score is 1, it is determined that the corresponding node is an available storage resource.
In this embodiment, the container optimization tool collects information of available storage resources on each node in the kubernetes cluster, specifically: calculating the resource measurement of each node through the operation model, and further judging whether each node is an available storage resource in a grading mode; the calculation mode of the operation model is as follows: calculating cpu usage rate, memory usage rate, disk io usage rate (e.g., additional mounted disk exists [ 0, 1 ] whether disk types are consistent [ 0, 1 ] data directory exists [ 0, 1 ]).
And judging whether each node is available according to the score of each node calculated by the operation model, if the score is 0, representing that the node is unavailable, and if the score is 1, representing that the node is available.
In the embodiment, the container optimization tool is used for collecting the available storage resource information on each node in the kubernetes cluster, so that enough storage resources on the target node can be ensured to be available, errors of data in the dynamic migration process are avoided, and the stability in the data migration process is ensured.
As shown in fig. 1, in an implementation manner of the embodiment of the present invention, the method for dynamically migrating persistent storage resources based on the K8S cluster further includes the following steps:
step S200, determining a target node to be migrated according to the available storage resource information, and creating a target persistent volume at the target node.
In this embodiment, the interface of the cadaver can be used by the Kubelet component to obtain these metric data to understand the real-time resource usage of the container and host on the node. And carrying out scheduling decision, resource management and performance analysis by using the data, and finally selecting a proper migration target node.
Specifically, in one implementation of the present embodiment, step S200 includes the steps of:
step S201, persistent volume information of mounting information corresponding to the local persistent volume of the target node is generated according to the available storage resource information.
In this embodiment, after selecting a suitable migration target node, a new target PV may be created on the target node, so as to migrate the data of the source node to the newly created target PV under the local PV mode of kubernetes cluster, with the criteria that the pod container cannot dynamically drift.
In the process of creating a new target PV, first, PV information including mounting information of the target localpv is generated using the available resource information acquired in step S100:
the PV in the above example defines a local storage volume with a capacity of 50Gi, and can only be read and write accessed on one node, i.e. the 192.168.100.100 node. The recovery strategy of the persistent storage volume is Retain, the storage class is named as local-storage, and the storage path is/data/local/pv.
It is worth mentioning that the above code is only one example and in actual use, appropriate configuration and adjustment can be made as required to create a new target PV.
Step S202, generating a mounting script according to the persistent volume information, and executing corresponding mounting operation through the mounting script.
In this embodiment, after generating pv information including the mounting information of the target local pv, the mounting script may be automatically generated according to the generated information, specifically as follows:
when the mounting script is automatically generated, related information of the original localpv is mainly acquired through a kube-apiserver component (the kube-apiserver component is one of core components of Kubernetes and is one of control plane components in Kubernetes clusters and is used for providing services of Kubernetes API), and the specific acquisition modes include that the size of a data disk is included, and information such as catalogues in a mounting repod are as follows:
the above example is a shell script for creating a file and then mounting the file to a designated mounting point, first, the script uses parameters as paths to create a new file using commands $1/data0/k8spv/data0touch $1; next, the file is truncated to a specified size (e.g., 50 GB) using the command; then, creating an ext4 file system on the file using the command; if the mount point directory does not exist, the script prints a message "not exist, creating the directory using the command; finally, the file is mounted to a designated mounting point by using the command; the last line of commands is used to display the disk space usage of the mount point.
It is worth mentioning that to execute the script, a command may be run in the terminal to create a file of 50GB size and mount it to the directory. Note that: before executing the script, it is necessary to ensure that there are sufficient rights (e.g., running the script using sud).
And step S203, binding the local persistent volume with a persistent volume claim request to obtain the target persistent volume.
In this embodiment, pv needs to be bound to pvc (i.e. persistent volume claim request) by script; wherein the persistent volume claim (PersistentVolumeClaim, PVC) expresses a user request for storage. Conceptually similar to Pod containers. Pod containers consume node resources, while PVC claims consume PV resources. The Pod container may request a certain number of resources (e.g., CPU and memory); likewise, a PVC claim may also request a particular size and access mode (e.g., may require that a PV volume be capable of being mounted in one of ReadWriteOnce, readOnlyMany or ReadWriteMany modes).
While PVC allows users to consume abstract storage resources, it is common for users to want pv volumes with different attributes (e.g., capabilities) for different problems. The cluster administrator needs to be able to provide pvs of different nature, and the differences between these pv volumes are not limited to just volume size and access patterns, but also cannot expose to the user these details of how the volumes are implemented. To meet such demands, there are storage class (Storageclass) resources.
In this embodiment, the specific operation of binding pv to pvc is as follows:
the above example is a configuration file of persistent volume declaration (persistence volume claim) of a Kubernetes cluster for declaring requirements and access patterns for storage resources.
In this configuration file, the name of the persistent volume declaration, here "myclaim", is specified using core API version 1 of the Kubernetes cluster, which can be modified as needed; and, specification details of persistent volume declarations are defined below:
defining an access mode, wherein the access mode indicates that the persistent volume can only be mounted by a single node in a read-write mode;
specifying a demand for storage resources, representing a request having a storage capacity of at least 50 GB;
the name of the storage class, here "local-storage", is specified. The storage class defines the nature and configuration of storage for providing persistent volumes that meet demand.
By way of example above, a persistent volume declaration may be created that tells the Kubernetes cluster to need a persistent volume of at least 50GB capacity that can be read and written to by a single node, and use a storage class named "local-storage". The Kubernetes cluster would dynamically allocate the corresponding persistent volume to meet this requirement based on this statement, and then bind this persistent volume into the Pod container.
The present embodiment determines the state and connection information of migrating Local PVs by creating a target persistent volume at a target node, the state and connection information including: the mount status of the storage volume, the mount point of the file system, the associated Pod, or the connection of the application. Based on the state and connection information of the migrated Local PV, it may be further ensured that related Kubernetes objects are migrated and updated correctly during the migration process, so as to ensure that the application can be connected to the target Local PV correctly.
As shown in fig. 1, in an implementation manner of the embodiment of the present invention, the method for dynamically migrating persistent storage resources based on the K8S cluster further includes the following steps:
and step S300, migrating the data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool.
In this embodiment, data consistency between the source LocalPV and the target LocalPV can be ensured by appropriate data replication and synchronization policies. Any differences or delays in the data replication process can be controlled and accounted for to ensure the integrity of the migrated data.
Specifically, in one implementation of the present embodiment, step S300 includes the steps of:
step S301, migrating data to be migrated in a source persistent volume to the target persistent volume through the backup and migration tool, triggering a job resource through an HTTP POST request, and performing data synchronization after the target node mounts a directory.
In this embodiment, different methods may be used to backup and migrate data, depending on the size and complexity of the data.
In one implementation of the present embodiment, a tool (e.g., rsync or Velero) is used to copy data from a source PV to a target PV in a consistent and integrity manner. Ensuring that data consistency and integrity is maintained during migration. When migration occurs, a job resource is triggered by webhook (a mechanism for pushing data to a predefined URL by an HTTP request when a specific event occurs), and data synchronization is performed after a target node mounts a directory. (the mirror image contains authentication information of all nodes, and variable information "< source_dir >", "< target_dir >" is acquired through steps S100, S200).
Specifically, the operations of backing up and migrating data are:
the above example is a Kubernetes Job's profile defining a task (Job) and specifying the specifications and parameters it performs.
The configuration file describes a task called "rsync-job" that runs in a separate Pod containing a container called "rsync-container". The container uses the specified rsync mirror and executes the specified rsync command to synchronize the contents of source directory < source_dir > into target directory < target_dir >.
In the above example, the tasks need to be created and run by replacing < rsync-image > and < source_dir >, < target_dir > with the actual values and then applying the configuration file to the Kubernetes cluster using commands.
As, in the process of dynamically migrating Local PV to data replication and synchronization, a certain migration time and performance impact may be introduced; the migration time depends on the size of the data volume, the network bandwidth and the employed data replication method, among other things. In this embodiment, by using the rsync mechanism, it is realized that the existing files of the sender and the receiver are checked, and only the part with variation is transmitted, so as to reduce the migration process time, thereby reducing the migration time and the performance impact.
As shown in fig. 1, in an implementation manner of the embodiment of the present invention, the method for dynamically migrating persistent storage resources based on the K8S cluster further includes the following steps:
step S400, updating the application program configuration of the target node according to the migrated data, and verifying and cleaning the data in the target persistent volume according to the updated application program configuration.
In this embodiment, the usability and fault tolerance of the application program need to be considered when performing the live migration. Thus, some policies may be employed to keep the application partially or fully available, e.g., judging the migration progress by the job during the migration, creating a new pod only after the job is completed, but the old pod is not immediately deleted, but traffic is cut off, waiting for the old pod to be deleted after the new pod is fully operational. Rollback and recovery policies are set by such mechanisms to cope with problems and failures that may occur during migration.
Specifically, in one implementation of the present embodiment, step S400 includes the following steps:
and step S401, when the data to be migrated is successfully migrated, generating a new workload mode of the application program of the target node, mounting a local persistent volume of the target node, and executing a pod creation, a pod starting and a pod running process.
In this embodiment, once the data is successfully migrated, a new workload mode may be generated, and by mounting a local pv and normally creating a pod, starting, running an operation process, an update process of application configuration is implemented.
Step S402, verifying whether the application program can normally access and use the new persistent volume according to the updated application program configuration, ensuring the integrity and consistency of data, and verifying the functions of the application program;
step S403, deleting the old persistent volume and the persistent volume claim request according to the verification result, and deleting the left-over workload data.
In this embodiment, after updating the application configuration, it is necessary to verify whether the application can normally access and use the new PV. Ensure the integrity and consistency of the data and verify the functionality of the application. If everything is normal, old PVs and PVC can be safely deleted, and the left-over workload is deleted, so that the verification and cleaning process after data migration is realized.
As shown in fig. 2, in an application scenario, the static pv dynamic migration process based on Kubernetes cluster includes:
1. generating a Local PV at a destination node;
2. synchronizing the pv content to the destination node by rsync;
3. creating a new workload and mounting a target pv;
4. old pod and Local PV are deleted.
The application scenarios in this embodiment are as follows: under the localpv mode of kubernetes clusters, a new operator is created on the criterion that the pod container cannot dynamically drift, so that automatic and manual migration of the pod container to other working nodes is realized, after nodes are manually selected or weight nodes are automatically calculated, the pod after file transfer is executed to re-mount the file.
The following technical effects are achieved through the technical scheme:
according to the embodiment, by acquiring the available storage resource information of the K8S cluster, a target node to be migrated can be determined according to the available storage resource information, and a target persistent volume is created at the target node; migrating the data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool, updating the application program configuration of the target node according to the migrated data, and verifying and cleaning the data in the target persistent volume according to the updated application program configuration; the embodiment realizes the dynamic migration of the persistent storage resources under the K8S cluster, ensures the consistency of data, and ensures that the aspects of application performance, migration durability and the like are not affected.
Exemplary apparatus
Based on the above embodiment, the present invention further provides a device for dynamically migrating persistent storage resources based on a K8S cluster, including:
the acquisition module is used for acquiring the available storage resource information of the K8S cluster;
the target persistent volume creation module is used for determining a target node to be migrated according to the available storage resource information and creating a target persistent volume at the target node;
the data migration module is used for migrating data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool;
and the verification and cleaning module is used for updating the application program configuration of the target node according to the migrated data and verifying and cleaning the data in the target persistent volume according to the updated application program configuration.
Based on the above embodiment, the present invention further provides a terminal, and a functional block diagram thereof may be shown in fig. 3.
The terminal comprises: the system comprises a processor, a memory, an interface, a display screen and a communication module which are connected through a system bus; wherein the processor of the terminal is configured to provide computing and control capabilities; the memory of the terminal comprises a storage medium and an internal memory; the storage medium stores an operating system and a computer program; the internal memory provides an environment for the operation of the operating system and computer programs in the storage medium; the interface is used for connecting external equipment such as mobile terminals, computers and other equipment; the display screen is used for displaying corresponding information; the communication module is used for communicating with a cloud server or a mobile terminal.
The computer program, when executed by a processor, is configured to implement the operations of a K8S cluster-based persistent storage resource live migration method.
It will be appreciated by those skilled in the art that the functional block diagram shown in fig. 3 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the terminal to which the present inventive arrangements may be applied, and that a particular terminal may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a terminal is provided, including: the system comprises a processor and a memory, wherein the memory stores a K8S cluster-based persistent storage resource dynamic migration program, and the K8S cluster-based persistent storage resource dynamic migration program is used for realizing the operation of the K8S cluster-based persistent storage resource dynamic migration method when being executed by the processor.
In one embodiment, a storage medium is provided, wherein the storage medium stores a K8S cluster-based persistent storage resource live migration program, which when executed by a processor is configured to implement the operations of the K8S cluster-based persistent storage resource live migration method as described above.
Those skilled in the art will appreciate that implementing all or part of the above-described methods may be accomplished by way of a computer program comprising instructions for the relevant hardware, the computer program being stored on a non-volatile storage medium, the computer program when executed comprising the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory.
In summary, the invention provides a method and a device for dynamically migrating persistent storage resources based on a K8S cluster, wherein the method comprises the following steps: acquiring available storage resource information of a K8S cluster; determining a target node to be migrated according to the available storage resource information, and creating a target persistent volume at the target node; migrating data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool; updating the application program configuration of the target node according to the migrated data, and verifying and cleaning the data in the target persistent volume according to the updated application program configuration; the invention realizes the dynamic migration of the persistent storage resources under the K8S cluster, ensures the consistency of data, and ensures that the aspects of application performance, migration durability and the like are not affected.
It is to be understood that the invention is not limited in its application to the examples described above, but is capable of modification and variation in light of the above teachings by those skilled in the art, and that all such modifications and variations are intended to be included within the scope of the appended claims.

Claims (10)

1. The utility model provides a method for dynamically migrating persistent storage resources based on a K8S cluster, which is characterized by comprising the following steps:
acquiring available storage resource information of a K8S cluster;
determining a target node to be migrated according to the available storage resource information, and creating a target persistent volume at the target node;
migrating data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool;
updating the application program configuration of the target node according to the migrated data, and verifying and cleaning the data in the target persistent volume according to the updated application program configuration.
2. The K8S cluster-based persistent storage resource live migration method of claim 1, wherein obtaining the available storage resource information of the K8S cluster comprises:
and periodically collecting resource measurement indexes of each node, and analyzing to obtain the available storage resource information of the K8S cluster, wherein the resource measurement indexes comprise: CPU usage, memory usage, disk I/O, network I/O, and file system information.
3. The method for dynamically migrating persistent storage resources based on a K8S cluster according to claim 2, wherein the periodically collecting resource metric indexes of each node, analyzing to obtain available storage resource information of the K8S cluster, includes:
calculating the resource measurement of each node through an operation model to obtain different scores;
judging whether the measurement index of the corresponding node is an available storage resource according to the scoring;
if the score is 0, judging the corresponding node as unavailable storage resource;
and if the score is 1, judging the corresponding node as the available storage resource.
4. The K8S cluster-based persistent storage resource live migration method of claim 1, wherein the creating a target persistent volume at the target node comprises:
generating persistent volume information of mounting information corresponding to a local persistent volume of the target node according to the available storage resource information;
generating a mounting script according to the persistent volume information, and executing corresponding mounting operation through the mounting script;
binding the local persistent volume with a persistent volume claim request to obtain the target persistent volume.
5. The K8S cluster-based persistent storage resource live migration method of claim 1, wherein the migration of data to be migrated in a source persistent volume to the target persistent volume by a backup and migration tool comprises:
and migrating the data to be migrated in the source persistent volume to the target persistent volume through the backup and migration tool, triggering the job resource through an HTTP POST request, and carrying out data synchronization after the target node mounts the catalog.
6. The K8S cluster-based persistent storage resource live migration method of claim 1, wherein the updating the application configuration of the target node according to the migrated data comprises:
and when the data to be migrated is successfully migrated, generating a new workload mode of the application program of the target node, mounting a local persistent volume of the target node, and executing pod creation, pod starting and pod running processes.
7. The K8S cluster-based persistent storage resource live migration method of claim 1, wherein verifying and cleaning data in the target persistent volume according to the updated application configuration comprises:
according to the updated application program configuration, verifying whether the application program can normally access and use the new persistent volume, ensuring the integrity and consistency of data, and verifying the functions of the application program;
and deleting the old persistent volume and the persistent volume claim request according to the verification result, and deleting the left-over workload data.
8. A K8S cluster-based persistent storage resource live migration apparatus, comprising:
the acquisition module is used for acquiring the available storage resource information of the K8S cluster;
the target persistent volume creation module is used for determining a target node to be migrated according to the available storage resource information and creating a target persistent volume at the target node;
the data migration module is used for migrating data to be migrated in the source persistent volume to the target persistent volume through a backup and migration tool;
and the verification and cleaning module is used for updating the application program configuration of the target node according to the migrated data and verifying and cleaning the data in the target persistent volume according to the updated application program configuration.
9. A terminal, comprising: the computer-readable storage medium comprises a processor and a memory, wherein the memory stores a K8S cluster-based persistent storage resource live migration program, and the K8S cluster-based persistent storage resource live migration program is used for realizing the operations of the K8S cluster-based persistent storage resource live migration method according to any one of claims 1 to 7 when the K8S cluster-based persistent storage resource live migration program is executed by the processor.
10. A computer readable storage medium storing a K8S cluster based persistent storage resource live migration program which, when executed by a processor, is operable to implement the K8S cluster based persistent storage resource live migration method of any of claims 1-7.
CN202311108776.0A 2023-08-31 2023-08-31 Method and device for dynamically migrating persistent storage resources based on K8S cluster Pending CN117369940A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311108776.0A CN117369940A (en) 2023-08-31 2023-08-31 Method and device for dynamically migrating persistent storage resources based on K8S cluster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311108776.0A CN117369940A (en) 2023-08-31 2023-08-31 Method and device for dynamically migrating persistent storage resources based on K8S cluster

Publications (1)

Publication Number Publication Date
CN117369940A true CN117369940A (en) 2024-01-09

Family

ID=89402986

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311108776.0A Pending CN117369940A (en) 2023-08-31 2023-08-31 Method and device for dynamically migrating persistent storage resources based on K8S cluster

Country Status (1)

Country Link
CN (1) CN117369940A (en)

Similar Documents

Publication Publication Date Title
US11153380B2 (en) Continuous backup of data in a distributed data store
US11409705B2 (en) Log-structured storage device format
US11120152B2 (en) Dynamic quorum membership changes
US10474547B2 (en) Managing contingency capacity of pooled resources in multiple availability zones
US10929428B1 (en) Adaptive database replication for database copies
US11199971B2 (en) Managing operational parameters for migrating data for resized volumes
US20210084103A1 (en) Live Migration Of Clusters In Containerized Environments
EP3039548B1 (en) Partition tolerance in cluster membership management
US8918392B1 (en) Data storage mapping and management
US8818951B1 (en) Distributed file system having separate data and metadata and providing a consistent snapshot thereof
US10162722B2 (en) Virtual machine aware replication method and system
US11314444B1 (en) Environment-sensitive distributed data management
US20230409381A1 (en) Management and orchestration of microservices
US10922303B1 (en) Early detection of corrupt data partition exports
US10852996B2 (en) System and method for provisioning slave storage including copying a master reference to slave storage and updating a slave reference
CN111078121A (en) Data migration method, system and related components of distributed storage system
US10599622B2 (en) Implementing storage volumes over multiple tiers
US10620871B1 (en) Storage scheme for a distributed storage system
CN110825704A (en) Data reading method, data writing method and server
EP2186013B1 (en) Sharing volume data via shadow copies
US11704289B2 (en) Role reversal of primary and secondary sites with minimal replication delay
CN117369940A (en) Method and device for dynamically migrating persistent storage resources based on K8S cluster
JP2013161383A (en) Information processing device, information processing method, program and information processing system
US11983147B2 (en) Deduplicating data integrity checks across systems

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination