Virtual Machine Clone
Virtual machine cloning refers to creating a replica of a virtual machine at a specific point in time. The cloned virtual machine contains all the configurations, operating systems, applications, and data of the original virtual machine.
Prerequisites
-
To use the virtual machine cloning functionality, its disk must utilize a storage class that supports snapshot features. Virtual machine snapshots save the current state of the virtual machine, which can be used to restore the virtual machine to that point in time in the event of an unexpected failure.
-
The jq package must be installed on the node where the script is to be executed. jq is a lightweight command-line JSON processing tool used for parsing and processing JSON data.
Steps to Operate
Note: All operations below must be performed on the master node of the cluster where the virtual machine resides.
-
Open the CLI tool.
-
Execute the following command to create and open the vm-clone.sh file.
-
Press
iand copy the following content into the vm-clone.sh file. -
Press
shift+:wqto save the file. -
Execute the following command to add execution permissions to the vm-clone.sh file.
-
Execute the following command to run the script file.{#clone}
Parameter Description:
- NAMESPACE: Specify the namespace of the virtual machine to be cloned, replacing the <NAMESPACE> part with this namespace.
- VM_NAME: Specify the name of the virtual machine to be cloned, replacing the <VM_NAME> part with this name.
- VM_CLONE_NAME: Specify the name of the cloned virtual machine, replacing the <VM_CLONE_NAME> part with this name.
-
When a message similar to the following appears, it indicates that the cloning is complete.
Related Operations
View and Start the Cloned Virtual Machine
-
Go to Platform Management.
-
In the left navigation bar, click Virtualization Management > Virtual Machine Images.
-
You will see the cloned virtual machine with the specified name from the Run Script step; the default state of the cloned virtual machine is Stopped.
-
Click on the name of this virtual machine, and the page will redirect to the virtual machine detail page in the Container Platform.
-
Click Start to successfully start the virtual machine.