There two ways you can upgrade or downgrade your VM instances.
a. Stop – configure – start
b. Minimum downtime ( by swapping the disk )
a. This is a very easy method to do this. The main disadvantage of this is, it requires downtime. If you are okay with a 5 – 10 minute of downtime then you can go with this method.
b. If you this to happen almost real time then follow these steps
If you have a Google cloud compute engine VM Instance and wants to upgrade or downgrade
- Take a snapshot of the disk
You can easily detach non-root persistent disks from your instances. It is harder to detach root persistent disks and it is not possible to detach a root persistent disk without deleting the instance.
Before you detach a root persistent disk, consider taking a snapshot of the disk and using it to create a copy of the persistent disk. Since detaching a root persistent disk requires deleting the instance it is attached to, taking a snapshot and creating a new disk altogether might be less destructive for your scenario. ( source – google cloud documentation )
To take a snapshot of the disk click Disk option from left hand side navigation bar. You will get all the disks present in your compute engine. Select the disk you want to take snapshot of. You will see “Create Snapshot” option.
2. Delete the instance
Note : Make sure you have not checked, delete disk when instance is deleted option
Now delete the instance that you want to upgrade. This will delete the instance and detach the root persistence disk.
3. Create a new instance
Click on create instance option, this will bring up a form to configure your instance. You can now set new machine type here. Under Boot Disk option click on “change” button. In the new window under “Snapshot” menu select the snapshot that we have taken in the first step.
This will boot up the instance with the new configuration!
You can change the ip address once you are okay with the new instance.