'Adding a VM instance to a group with a legacy network

I have an unmanaged instance group in Google Cloud associated with the default network (a legacy network). The other day a colleague made a mistake and removed one of the VMs from the group, and now we cannot add it back. When we try to do it, Google Cloud asks for a subnet which we cannot find how to create for this default network. Does anybody know how to create a subnet for a legacy default network? Is there a way to go around this?



Solution 1:[1]

As you can see in the following GCP’s official documentation, “Legacy networks have a single global IP address range that cannot be divided into subnets. VPC networks are divided into subnets. Each Google Cloud region can have one or more subnets in a VPC network”.

The option you have at this point is to replace your legacy network with a VPC network, and there are two ways to do it according to this official GCP’s documentation:

  1. Using the Single-region conversion tool: Use the gcloud or API single-region conversion tool. This tool converts a legacy network to a custom mode VPC network. Before starting the conversion, all Google Cloud resources in the legacy network must be in a single region. If the legacy network contains resources in multiple regions, including stopped VMs, the conversion fails. After the conversion, the subnet in the new network has the same internal IP address range as the entire legacy network. After the conversion is complete, you can use all features that VPC networks offer, such as creating regional subnets. For more information about the conversion, see Converting a single-region legacy network to a VPC network.

  2. Doing it through a Manual migration: Recreate resources in your legacy network in a VPC network. You can use this official documentation.

Once that your legacy network is migrated to the new VPC network, you are going to be able to add your removed instance back.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jofre