In my google-cloud project prj1, there's an instance instance-1 and I want to move it from us-central1-a to europe-west2 zone using the following command.
$ gcloud compute instances move instance-1 --zone us-central1-a --destination-zone europe-west2
gives the following error:
ERROR: (gcloud.compute.instances.move) Project [prj1] not found: The resource 'projects/prj1/zones/europe-west2' was not found
Why does it say 'not defined' for my project?
It seems I miss some steps but I'm stuck at this point.
Within GCP, there is the concept of regions and zones. A region is a geography (eg. Central US or West Europe) while zones are disparate data centers within those regions which are physically separate and hence less likely to simultaneously be down due to an event. When we create a compute engine, we create it within a region and associated with a specific zone in that region. Using the gcloud compute instances move command, we can move a compute engine from one zone to another within the same region. If what you want to do is to move the instance from one region to another, this command can not be used. Google documents a recipe for moving a compute engine from one region to another here:
https://cloud.google.com/compute/docs/instances/moving-instance-across-zones#moving_an_instance_manually
Notice in that example they are moving from europe-west1-a to us-west1-b.
See also:
Regions and Zones
Related
I have completed a basic lab in Qwiklabs platform. But I still don't get the difference between these set of commands.
To see what your default region and zone settings are, run the following commands:
gcloud config get-value compute/zone
gcloud config get-value compute/region
Identify your default region and zone
gcloud compute project-info describe --project <your_project_ID>
Google Cloud has regions, which are geographic areas. Within a region are zones, which are large data centers. A typical region has three or more zones within a region.
As of today, there are 28 regions and 85 zones. In addition, there are 146 network edge locations that are important for CDNs and network entry points into the Google Cloud network. Seven more regions are planned, raising the total number of regions to 35.
When you launch a service you need to specify the zone (usually). Some commands require specifying the region.
The CLI has variables to remember your preferred region and zone. These options can be modified via command-line options when executing individual commands.
gcloud config set
Cloud locations
Compute Engine Regions and zones
I am breaking out in a sweat now.
I wanted to move a VM to a different zone within the same region. I run
gcloud compute instances move move-this-vm --zone xxxx --destination-zone xxxx
I checked on the VM after the command has run, it has disappeared!! I can't find it. I did
gcloud compute instances list
It is not listed. It is not shown on the web console either.
I have created a machine image of a VM before move so I am not worried about data lost. However, I am bizzared.
Is this a common glitch for moving VM using the CLI? In this scenario, what can I do to retrieve the VM? Why does it happen?
I have a Compute Engine instance on Google Cloud on zone europe-west3-c. In last several days, when I try to start it I get following message:
The zone 'projects/PROJECT/zones/europe-west3-c' does not have enough resources available to fulfill the request. Try a different zone, or try again later.
Since I've been trying to connect for several days, I decided to move the instance between zones. I tried with this API: https://cloud.google.com/compute/docs/reference/rest/v1/projects/moveInstance
But I get this error:
404: Invalid resource usage: 'Instance is a UEFI-enabled instance and does not support MoveInstance.'.
I really need this computing instance for my work so any quick help would be very much appriciated!
Using the following gcloud command you can move an instance automatically. However, When possible, use the moveInstances API to save yourself some work, but there are some scenarios where using the moveInstances API is not an option.
gcloud compute instances move example-instance-1 --zone us-central1-b --destination-zone us-central1-f
Whenever possible, move an instance automatically using the moveInstance API, which handles all the steps for moving an instance for you. However, if you cannot use the API, you can perform the move manually.
You can create image or snapshot from the instance disk then you can create new instance from the image or also you can create instance from snapshot. You can create a new VM in any region/zone.
Another way you can detaching the VM disk using the following gcloud command:
gcloud compute instances detach-disk Instance-Name --disk=Disk-Name --zone Disk-zone
Now if you go to Compute Engine > Disks > Click the name of VM disk > Manage disk > CREATE INSTANCE; creating new instance you can change or move the VM instance to your chosen region/zone.
After executing
gcloud compute instances move instance-ba --zone us-east1-b --destination-zone us-east1-c
and waiting for about 5 minutes the following error was thrown
Moving gce instance instance-ba...failed.
ERROR: (cloud.compute.instances.move) Code: '6562453592928582321'
and the instance was gone from the web interface as well as from zone us-east1-b and us-east1-c
I tried to start the instance with
cloud compute instances start instance-ba --zone us-east1-b
and
cloud compute instances start instance-ba --zone us-east1-c
but none was working.
Thank you in advance for your help.
I have to say that this instance is quite important and I appreciate every input to solve this issue.
Edit
In the Stackdriver Logging I am seeing the following commands executed alternating:
Compute Engine setDiskAutoDelete us-east1-b:instance-ba
compute.instances.setDiskAutoDelete
As it seems the instance has been deleted from us-east1-b but not transferred to us-east1-c.
I do not see any error at all. All logs have severity "INFO" or lower.
Edit 2
I recall my steps which preceeded the moving error as follows
I tried adding a second Tesla P100 to my instance which gave at startup the error that the resources are not enough to fulfill the request
I tried moving the instance which gave the "TERMINATED" error so I
tried to reset the machine with the reset command which gave the "instance not ready" error
I removed the second Tesla P100 so that I could start the machine
I did the restart command over and over until it worked and the machine was able to start
Since I needed a second GPU I tried to moved this instance (without the second GPU) from us-east1-b to us-east1-c which finally did not work and gave the error
Edit 3
After some research I found that the procedure actually made a snapshot from my instance and the data is not lost.
However I will keep this question updated concerning the error and the response to it from google.
According to the documentation, you have a short specification for when to use the manual or the automatic move. As the procedure says, use the manual move when:
"Your VM is not RUNNING."
"You are moving your VM to a different region and your VM belongs to a subnetwork."
"Your instance has GPUs or local SSDs attached."
In your case, you had one GPU attached to your instance. So the correct way to move it is the following:
Stop your instance
Edit the instance, on the “Machine type” click customize and select “none” numbers of GPU. More details here.
Start your instance
Use the gcloud command to move the instance between zones:
$ gcloud compute instances move example-instance --zone us-central1-a --destination-zone us-central1-f
Once the instance is migrated stop it again.
Add the GPU and start the instance.
Keep in mind that every zone has different GPUs available and new projects have limits for GPUs.
"To protect Compute Engine systems and users, new projects have a global GPU quota, which limits the total number of GPUs you can create in any supported zone. When you request a GPU quota, you must request a quota for the GPU models that you want to create in each region, and an additional global quota for the total number of GPUs of all types in all zones."
Using gcloud, I used to be able to move instances between the regions. Surprisingly, I couldn't do that anymore..!
The command I used:
cloud compute instances move instance-4 --zone us-east1-b --destination-zone asia-east1-b
I get the following error message:
ERROR: (gcloud.compute.instances.move) Some requests did not succeed:
- Instances belonging to subnetworks cannot be moved interregionally.
Unfortunately, there isn't enough description about this error. Have Google changed the way moving instances is done? I know I can create a snapshot of the VM and start it in the new region but I wanted to use the 'move' command specifically. Is there something I didn't pay attention to?
Thanks
I believe that command is to move between zones in the same region. I believe you have to use instant image and recreate in a different region.
Best of luck.
T