How to Change the machine types of a VM instance in GCP?

Changing the machine type of a VM instance:-


How to Change the machine types of a VM instance in GCP?


1If your existing machine is not a good fit for the workloads you run on your VM, change the machine type of that VM. (Vertical Scaling).


2. If your VM does not have a local SSD and is not part of a Managed Instance Group (MIG), you can change the machine type of your VM after stopping it.


3. If your VM has a local SSD, you Cannot stop the VM to change its machine type unless you force it to Stop, which causes you loses all of the data on the local SSD.


4. Changing a machine type might also affect the Sustained use discounts for that VM.


5. You can only change the machine type of a Stopped VM. You cannot change the machine type of a running VM.


6. Take a Snapshots before Updating the Instance Size.   (For all Clouds AWS, GCP Azure).


7. For VMs that do not have a local SSD and are not part of a MIG, you can Change the Machine Type without affecting the following Resources:-


  1. The VMs SSH keys
  2. The VM configuration, such as Metadata.
  3. Persistent disk Data including installed applications and app data.



Steps:


  1. Go to Google Console:

— Compute Engine 

— VM Instances 

— Select the VM 

— Click on 3 dots and stop the VM


— Go to Edit

— Machine Configuration 

— Select the Machine type you want 

— Save


Refresh your Google Console: You will get Updated VM


— Now Start/Resume the VM.





Do the same Using Command Line Interface (CLI): 


Using Cloudshell:


Steps:


  1. Stop the VM first:


gcloud compute instances stop myvm02



  1. Change the machine type:


gcloud compute instances set-machine-type myvm02 --machine-type e2-standard-2 



  1. For custom machine type: You can use


gcloud compute instances set-machine-type myvm01 --machine-type e2-custom-4-2048






🙏 thanks


























Previous
Next Post »