How to change Region / Zone in Google Cloud?

后端 未结 4 1892
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 05:15

I am very new to Google Cloud. I was able to setup a wordpress site and am working on it now. However, it appears that my vm instance is using the following asia-east1-a for i

4条回答
  •  心在旅途
    2021-02-05 05:53

    • As described here, project-info metadata can be added per project to specify the default regions and zones. This is used only at the time of initializing gcloud (using gcloud init).

    • In addition, gcloud supports locally setting the default region and zone using the compute/region and compute/zone configurations (which is what you seem to have added to your local gcloud config). When these properties are set, they will override any configuration set in the project-info.

    • Since you have set these properties according to your requirements, I think your defaults are set as long as you're using that gcloud configuration.

    • Do remember that you can always override the zone and region using the --zone and --region arguments to any of the gcloud commands.

    Moving instance from one zone to another

    Changing the default zone/region does not move any of the existing VMs to a new zone. If you wish to move a VM from one zone to another, you can take a snapshot of the persistent disks, launch a new instance in the desired zone using the snapshot and cleanup the resources used by the original VM.

    You can do this using either gcloud or follow a set of steps manually to achieve the same result.

    gcloud compute instances move INSTANCE_NAME --zone SOURCE_ZONE --destination-zone DESTINATION_ZONE
    

    In detail, Compute Engine will:

    • Take snapshots of persistent disks attached to the source instance.
    • Create copies of the persistent disks in the destination zone.
    • For instances moving within the same region, temporarily promote any ephemeral external IP addresses assigned to the instance to a static external IP address.
    • Create a new instance in the destination zone.
    • Attach the newly created persistent disks to your new instance.
    • Assign an external IP address to the new instance. If necessary, demote the address back to an ephemeral external IP address.
    • Delete the snapshots, original disks, and original instance.

    If you want to manually move your instance, you can also perform these steps by hand.

提交回复
热议问题