-3

Is there a sample gccloud script to migrate a machine from general-purpose to compute-optimised ? Its a webserver so I'd rather the new machine keeps the IP also. Downtime 10-20 min is OK.

Boppity Bop
  • 752
  • 3
  • 11
  • 34
  • 1
    Resizing Compute Engine instances is well documented. Please update your question with a problem that you are experiencing that is not covered by the documentation. I am voting to close this question and downvoting for showing no reasonable effort in solving your task before posting this question. – John Hanley Oct 31 '21 at 12:17
  • infinite knowledge can be gained with infinite amount of time – Boppity Bop Nov 03 '21 at 14:50

1 Answers1

0

Changing VM type in gcloud requires setting default region and zone for the project, stopping VM, changing type:

# set defaults
gcloud compute project-info add-metadata \
  --metadata google-compute-default-region=us-east4,google-compute-default-zone=us-east4-c

# check it was set (see commonInstanceMetadata section)
gcloud compute project-info describe --project YOURPROJECTNAME

# reinit gcloud to enable new defaults
gcloud init

# change machine type
gcloud compute instances stop VMNAME

gcloud compute instances set-machine-type VMNAME --machine-type e2-highcpu-4

gcloud compute instances start VMNAME

Note: you need static IP to be 100% sure IP wont change afterwards

Boppity Bop
  • 752
  • 3
  • 11
  • 34