Google Virtual NIC (gVNIC) is a virtual network interface designed specifically for Compute Engine.
On Compute Engine, you can use gVNIC on any supported public images. Alternatively, the Linux driver can be built and installed from source.
Previously, virtual machine (VM) instances that ran on Compute Engine used a virtual network interface based on the virtIO specification. For better networking performance and to support additional features, Google uses gVNIC as its default virtual network interface. For example, gVNIC is required to support higher network bandwidths such as the 50-100 Gbps speeds that can be used for distributed workloads on VMs that have attached GPUs. Also, gVNIC is required when working with some VM shapes that are meant for optimal performance when using VMs.
Before you begin
- If you want to use the command-line examples in this guide:
- Install or update to the latest version of the gcloud command-line tool.
- Set a default region and zone.
- If you want to use the API examples in this guide, set up API access.
Operating system support
For a list of supported operating systems, see Operating system details.
Use on non-supported operating systems
If you want to use gVNIC on an operating system that is not currently supported, you can manually configure and install gVNIC by using the following procedures:
- For Linux VMs, see Linux kernel driver Compute Engine Virtual Ethernet.
- For Windows VMs, see Windows driver for Compute Engine Virtual Ethernet.
Limitations
- Setting
--network-interface=nic-type=GVNIC
or"nicType": "GVNIC"
is currently not supported for instance templates.
Creating a VM that uses gVNIC
You can create VMs using either the
gcloud
command-line tool, or the
Compute Engine API.
gcloud
Select an image or image family that supports gVNIC. For more information, see Operating system details.
Using the image or image family selected in the previous step, create an image and tag this image with
GVNIC
. To create the image, use thegcloud compute images create
command.gcloud compute images create IMAGE_NAME \ [--source-image-family=SOURCE_IMAGE_FAMILY | --source-image=SOURCE_IMAGE] \ --source-image-project=SOURCE_IMAGE_PROJECT \ --guest-os-features=GVNIC
Replace the following:
IMAGE_NAME
: the name of the image that you want to create.SOURCE_IMAGE
orSOURCE_IMAGE_FAMILY
: Specify one of the following:SOURCE_IMAGE
: required version of a public image. For example,--image rhel-8-v20210122
.SOURCE_IMAGE_FAMILY
: an image family. This creates the VM from the most recent, non-deprecated OS image. For example, if you specify--image-family rhel-8
, Compute Engine creates a VM from the latest version of the OS image in the RHEL 8 image family.
SOURCE_IMAGE_PROJECT
: the name of the project that contains the source image.
Example
To create a RHEL 8 image using the latest image from the Compute Engine
rhel-8
image family, run the following command:gcloud compute images create IMAGE_NAME \ --source-image-family=rhel-8 \ --source-image-project=rhel-cloud \ --guest-os-features=GVNIC
Replace
IMAGE_NAME
with the name of your image.Use the image, created in the previous step, to create the VM. To create a VM, use the
gcloud compute instances create
command and specify the--network-interface=nic-type=GVNIC
flag.gcloud compute instances create VM_NAME \ --zone=ZONE \ --image=IMAGE_NAME \ --image-project=YOUR_IMAGE_PROJECT \ --network-interface=nic-type=GVNIC
Replace the following:
VM_NAME
: the name of the new VM.ZONE
: the zone to create the VM in.IMAGE_NAME
: the image that was created in the previous step.YOUR_IMAGE_PROJECT
: the name of your project that contains the image.
Example
To create RHEL 8 VM in zone
us-west1-b
using an image namedmy-rhel-8
that is in my projectmy-project-12345
, run the following command:gcloud compute instances create my-rhel-vm \ --zone=us-west1-b \ --image=my-rhel-8 \ --image-project=my-project-12345 \ --network-interface=nic-type=GVNIC
Things to consider
The
--network-interface
flag has sub-level flags such as the following:--address
--network
--network-tier
--subnet
--private-network-ip
For a full list see, the
--network-interface
flag.Verify that Compute Engine created the VM and that the
nicType is
set toGVNIC
.gcloud compute instances describe VM_NAME \ --zone=ZONE
Replace the following:
VM_NAME
: the name of the VM.ZONE
: the zone that VM is created in.
API
Select an image or image family that supports gVNIC For more information, see Operating system details.
Using the image or image family selected in the previous step, create an image and tag this image with
GVNIC
. To create the image, use theimages.insert
method.POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/images { "name": "IMAGE_NAME", "sourceImage": "projects/SOURCE_IMAGE_PROJECT/global/images/IMAGE", }
Replace the following:
IMAGE_NAME
: the name of the image that you want to create.IMAGE
orIMAGE_FAMILY
: specify one of the following:IMAGE
: required version of a public image. For example,"sourceImage": "projects/debian-cloud/global/images/rhel-8-v20210122"
IMAGE_FAMILY
: an image family. This creates the VM from the most recent, non-deprecated OS image. For example, if you specify"sourceImage": "projects/debian-cloud/global/images/family/rhel-8"
, Compute Engine creates a VM from the latest version of the OS image in the RHEL 8 image family.
SOURCE_IMAGE_PROJECT
: the name of the project that contains the source image.
Use the
instances.insert
method to create a VM using an image that supports gVNIC and specify the"nicType": "GVNIC"
parameter.POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances { "name": "VM_NAME", "networkInterfaces":[ { "network": NETWORK, "nicType": "GVNIC", "subnet": SUBNET_NAME, } ], "disks": [ { "initializeParams": { "sourceImage": "projects/YOUR_IMAGE_PROJECT/global/images/IMAGE" }, "boot": true } ], }
Replace the following:
PROJECT_ID
: the ID of the project to create the VM in.ZONE
: the zone to create the VM in.VM_NAME
: the name of the new VM.NETWORK
: the URL of the network resource for this VM. If neither the network nor the subnetwork is specified, the default networkglobal/networks/default
is used.IMAGE_NAME
: the image that was created in the previous step.YOUR_IMAGE_PROJECT
: the name of your project that contains the image.SUBNET_NAME
: name of the subnet. The network is inferred from the specified subnet. This is an optional field.
Verifying that gVNIC is enabled
Linux
On your Linux VM instance, run the following commands:
sudo lshw -class network
The output resembles the following:
*-network description: Ethernet interface product: Compute Engine Virtual Ethernet [gVNIC] vendor: Google, Inc. physical id: 4 bus info: pci@0000:00:04.0 logical name: eth0 version: 00 serial: 42:01:0a:8a:00:04 width: 32 bits clock: 33MHz capabilities: msix bus_master cap_list ethernet physical configuration: broadcast=yes driver=gve driverversion=1.0.0 ip=10.138.0.4 latency=0 link=yes multicast=yes resources: irq:11 memory:c0102000-c0102fff memory:c0101000-c010103f memory:c0000000-c00fffff
Windows
- On your Windows VM Instance, open the Device Manager.
- Under Network Adapters, you should see:
"Google Ethernet Adapter"
Troubleshooting
To troubleshoot gVNIC, see Troubleshooting Google Virtual NIC.
What's next
- Connect to your instance.
- Add persistent disks to your new instance.