Deploy VM with Multiple Network Interfaces in Google Cloud (Solution)

Deploy VM with Multiple Network Interfaces in Google Cloud (Solution)

Overview

  • Labs are timed and cannot be paused. The timer starts when you click Start Lab.

  • The included cloud terminal is preconfigured with the gcloud SDK.

  • Use the terminal to execute commands and then click Check my progress to verify your work.

Challenge scenario

You work for a company that is migrating its on-premises application to Google Cloud. The application consists of several components that require different network configurations for optimal performance and security. You need to deploy a VM instance with multiple network interfaces to facilitate communication across these different network segments.

You decide to create a VM instance with multiple network interfaces, each connected to a different subnet within the different VPC networks. This configuration allows the VM to communicate efficiently with various components of the application ecosystem.

You have already configured with pre-created VPC networks and their subnetworks:

  • VPC network 1: my-vpc1

    • Subnetwork: subnet-a
  • VPC network 2: my-vpc2

    • Subnetwork: subnet-b

Click Check my progress to verify the objective.

Create a VM Instance with Multiple Network Interfaces.


Solution of Lab

curl -LO raw.githubusercontent.com/ePlus-DEV/storage/refs/heads/main/labs/deploy-vm-with-multiple-network-interfaces-in-google-cloud-solution/lab.sh
source lab.sh

Script Alternative

export ZONE=$(gcloud compute project-info describe --format="value(commonInstanceMetadata.items[google-compute-default-zone])")

gcloud compute instances create multi-nic-vm --zone="$ZONE" --machine-type=e2-medium --network-interface=network=my-vpc1,subnet=subnet-a --network-interface=network=my-vpc2,subnet=subnet-b