Cloning is an art!
Duplicating your VM is an excellent way to fast-track your project without human error. There are some reasons you may want to clone your VM for a quick application setup.
Update: Google has made it a lot easier now to clone the VM.
Create Similar Approach
- Login to GCP and go to VM instances under Compute Engine.
- Click on the respective VM to be cloned.
- On top, you will see a create a similar button.
- Adjust the necessary (name, machine type, etc.) according to the requirement
- Click on create
The following I wrote when the “CREATE SIMILAR” button didn’t exist.
Lately, I set up my tools website on one Google Cloud VM and had to set up another one for high availability, and cloning was a life-saver.
Not only was it faster, but also I didn’t have to go through all the configurations, and installation manually, which has excellent room for missing/human error.
You may want to consider cloning VM if:
- You want to save time.
- You should set up a replica for another reason.
- Have to set up multiple instances for high-availability
- Want to avoid manual work/human error
If you are in a situation to duplicate the Google Cloud Virtual Machine, then here is how you can do it.
This is two steps process. First, where you create a snapshot, and next, you use that snapshot to create a VM instance.
You can do this while VM is running. This will ensure you don’t have any downtime and have the same replica of the existing VM.
- Go to VM instances under Computer Engine
- Click on Snapshots at the left navigation
- Click Create Snapshot
- Enter the name and select the source disk of the VM, which you want to get it cloned.
It will take a few seconds (based on the disk size), and you will get a confirmation on completion. You can see the newly created snapshot in the list.
Now, it’s time to create an instance from the snapshot.
- Go inside the snapshot from the list and click “Create Instance.”
- Enter the new instance details
Note: Google will not show you the existing VM instance configuration like CPU/Memory, so you got to ensure they are at your needs level.
You may also need to select firewall configuration as if you want to allow HTTP or HTTPS traffic.
- Click create once you have changed the configuration settings.
It will take a few seconds based on the disk size, and once done, and you will see the newly created VM in the list.
To confirm the VM is cloned with the data, log into newly created VM, and verify.
I found this is the quickest way to ensure VM on Google Cloud Platform is duplicated.
If you are interested in learning GCP, then I would recommend taking this Architecting with Google Cloud course.