VPC

VPC in GCP is quite a different policy compared with AWS. First of all, you don't need to set the CIDR prefix to VPC. In other words, you can't set CIDR to VPC. Instead, you just add one or some subnets to the VPC. Because you have to set certain CIDR blocks with a subnet, GCP VPC is therefore identified as a logical group of subnets, and subnets within VPC can communicate with each other.

Note that GCP VPC has two subnet modes, either auto or custom. If you choose auto, it will create some subnets on each region with predefined CIDR blocks. For example, type the following command:

$ gcloud compute networks create my-auto-network --subnet-mode auto

This will create 18 subnets as shown in the following screenshot (because, as of December 2018, GCP has 18 regions):

Auto mode VPC is probably good to start with. However, in auto mode, you can't specify the CIDR prefix and 18 subnets from all regions might not fit your use case. For example, connect to your on–premise data center via VPN. Another example is creating subnets on a specific region only.

In this case, choose custom mode VPC, then you can create subnets with the desired CIDR prefix manually. Type the following command to create a custom mode VPC:

//create custom mode VPC which is named my-custom-network
$ gcloud compute networks create my-custom-network --subnet-mode custom

Because custom mode VPC won't create any subnets, as shown in the following screenshot, let's add subnets onto this custom mode VPC:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset