Zonal network endpoint groups overview

A network endpoint group (NEG) is a configuration object that specifies a group of backend endpoints or services. Zonal NEGs are zonal resources that represent collections of either IP addresses or IP address and port combinations for Google Cloud resources within a single subnet.

NEGs are useful because they allow you to create logical groupings of IP addresses and ports representing software services instead of entire VMs. IP addresses for microservices (running in Google Cloud VMs) managed by other orchestrators like Apache Mesos or Cloud Foundry can be endpoints.

For information about other NEG types see:

There are two types of zonal NEGs, depending on the type of network endpoints that make up the NEG. The two types of zonal NEGs support different use cases and load balancer types.

NEGs with GCE_VM_IP endpoints

Passthrough Network Load Balancers support zonal NEGs with GCE_VM_IP endpoints. These zonal NEGs contain one or more endpoints represented using the primary internal IPv4 address of a Compute Engine VM's network interface.

Even though Google Cloud uses an IP address to represent the endpoint, the purpose of a GCE_VM_IP endpoint is to identify the network interface itself. The network interface must be in the NEG's subnet.

Because a GCE_VM_IP endpoint identifies a network interface, you cannot specify a port with a GCE_VM_IP endpoint.

These types of endpoints can only be used as backends in backend services for internal passthrough Network Load Balancers and external passthrough Network Load Balancers.

NEGs with GCE_VM_IP_PORT endpoints

These zonal NEGs contain one or more of the following IP address or IP address and destination port combinations:

  • The primary internal IPv4 address of a VM network interface
  • The primary internal IPv4 address of a VM network interface plus a destination port number
  • An internal IPv4 address from the alias IP address range assigned to a VM network interface
  • An internal IPv4 address from the alias IP address range assigned to a VM network interface plus a destination port number

The network interface containing the GCE_VM_IP_PORT endpoint must be in the NEG's subnet. When you omit a port number from a GCE_VM_IP_PORT endpoint, Google Cloud uses the NEG's default port number for the endpoint.

Because these zonal NEG backends let you specify IP addresses and ports, you can distribute traffic in a granular fashion among applications or containers running within VM instances—container-native load balancing. GKE uses GCE_VM_IP_PORT endpoints for:

You can create self-managed load balancers that use zonal NEGs whose GCE_VM_IP_PORT endpoints are managed by GKE. For details, see Container-native load balancing through standalone zonal NEGs.

Application Load Balancers and proxy Network Load Balancers support zonal NEGs with GCE_VM_IP_PORT endpoints.

Endpoint specification

When you create a NEG, you select a zone, a network, and a subnet. Every endpoint IP address must be in the same subnet as the zonal NEG.

If the network you select is an auto mode VPC network, you can omit specifying the subnet. However, a subnet is still associated with the zonal NEG. If you specify an auto mode VPC network but don't specify a subnet when creating a zonal NEG, the subnet it uses is the automatically created subnet in the region that contains the zone that you selected for the zonal NEG.

The type of zonal NEG you create is specified when you create the NEG (either GCE_VM_IP or GCE_VM_IP_PORT). This determines what types of endpoints the NEG supports.

GCE_VM_IP_PORT zonal NEGs

The following must be true for GCE_VM_IP_PORT zonal NEGs:

  • You must specify the name for each VM endpoint.

  • Each endpoint VM must be located in the same zone as the NEG.

  • Every endpoint in the NEG must be a unique IP address and port combination. A unique endpoint IP address and port combination can be referenced by more than one NEG.

  • Each endpoint VM must have a network interface in the same VPC network as the NEG. Endpoint IP addresses must be associated with the same subnet specified in the NEG.

  • Each NEG supports up to the maximum number of endpoints per NEG. The endpoints can be distributed among that many unique VMs or all located on one VM.

For GCE_VM_IP_PORT NEGs, when adding an endpoint you can choose to specify an IP address and port, just an IP address, or neither:

  • If you specify an IP address and port, the IP address can be either the VM's primary internal IP address on the network interface or an alias IP on the network interface. The port is your choice.

  • If you specify just an IP address, the IP address can be either the VM's primary internal IP address on the network interface or an alias IP address on the network interface. The port used is the NEG's default port.

  • If you omit both, Google Cloud selects the VM's primary internal IP address and uses the NEG's default port.

GCE_VM_IP zonal NEGs

The following must be true for GCE_VM_IP zonal NEGs:

  • You must specify the name for each VM endpoint.

  • Each endpoint VM must be located in the same zone as the NEG.

  • Every endpoint in a GCE_VM_IP NEG must be a unique IP address. A unique endpoint IP address can be referenced by more than one NEG.

  • Each GCE_VM_IP NEG is always associated with a network and subnetwork. When you add an endpoint, you can choose to specify an IP address, or not. If an IP address is specified, it must be set to the primary internal IP address of the attached VM instance that matches the subnetwork of the NEG. The primary internal IP address from any network interface of a multi-NIC VM instance can be added to a NEG as long as it matches the NEG subnetwork.

  • Each NEG supports up to the maximum number of endpoints per NEG. The endpoints must be distributed among all unique VMs. Multiple endpoints cannot be located on a single VM because a VM cannot have more than one network interface associated with the same subnet.

Load balancing with zonal NEGs

Zonal NEGs can be used as backends for backend services in a load balancer. When you use a zonal NEG as a backend for a backend service, all other backends in that backend service must also be zonal NEGs of the same type (either all GCE_VM_IP or GCE_VM_IP_PORT). You cannot use instance groups and zonal NEGs as backends in the same backend service.

You can add the same network endpoint to more than one zonal NEG. You can use the same zonal NEG as a backend for more than one backend service.

GCE_VM_IP_PORT zonal NEGs can use either the RATE balancing mode or the CONNECTION balancing mode, depending on the backend service protocol. Supported load balancers require defining a target capacity.

GCE_VM_IP zonal NEGs must use the CONNECTION balancing mode. Additionally, internal passthrough Network Load Balancers and external passthrough Network Load Balancers don't support the target capacity setting.

Passthrough Network Load Balancers

Zonal NEGs with GCE_VM_IP endpoints can be used as backends for backend services only for internal passthrough Network Load Balancers and external passthrough Network Load Balancers.

See the following sections for the primary use-cases for NEGs with GCE_VM_IP endpoints.

Flexible endpoint grouping

Like instance groups, you can use the same NEG as a backend for multiple passthrough Network Load Balancers. Unlike instance groups, a NEG endpoint can be a member of multiple NEGs, and each of those NEGs can be used as a backend for one or more passthrough Network Load Balancers. Compared to instance groups, you aren't constrained by the fact that a VM instance can only be a part of a single instance group.

The following figure shows a sample internal passthrough Network Load Balancer architecture with a shared VM.

Internal passthrough Network Load Balancers with overlapping `GCE_VM_IP` zonal NEGs.
Internal passthrough Network Load Balancers with overlapping zonal NEGs (click to enlarge).

Non-nic0 interfaces as backend endpoints

Zonal NEGs with GCE_VM_IP endpoints allow load balancing to non-nic0 network interfaces of VMs. This can be useful when integrating with third-party appliance VMs that typically reserve nic0 for management operations. With GCE_VM_IP NEGs, any non-nic0 network interface of the same VM can be attached to a NEG backend of a passthrough Network Load Balancer.

GKE subsetting

GKE uses GCE_VM_IP zonal NEGs and subsetting to improve the scalability of internal passthrough Network Load Balancers in the following way:

Without subsetting, GKE creates one unmanaged instance group per zone, consisting of the cluster's nodes from all node pools in that zone. These zonal instance groups are used as backends for one or more internal LoadBalancer Services (and for external Ingresses that don't use NEGs themselves).

With subsetting, GKE creates GCE_VM_IP zonal NEGs for each internal LoadBalancer Service. The same endpoint can be a member of more than one zonal NEG. Unlike instance groups, Google Cloud can load balance to more multiple zonal NEGs that contain the same endpoint.

Subsetting more efficiently distributes traffic to internal LoadBalancer Services in clusters with more than 250 nodes. For example, a 300-node GKE cluster might have one internal LoadBalancer Service with 25 nodes in a NEG because there are 25 serving Pods for that Service. Not all 300 nodes need to be added to an instance group backend for this Service.

Note that quotas for NEGs, forwarding rules, backend services, and other Google Cloud networking resources still apply.

For more details, see Using internal passthrough Network Load Balancer subsetting.

Application Load Balancers and proxy Network Load Balancers

The following illustrations show configuration components for load balancers where zonal NEGs with GCE_VM_IP_PORT endpoints are the backends:

Zonal network endpoint groups in load balancing.
Zonal network endpoint groups in load balancing (click to enlarge).

To learn more about the architectural requirements of these load balancers, see:

The primary use case for GCE_VM_IP_PORT zonal NEGs is container-native load balancing so that you can distribute traffic directly to containers running on VMs—for example, to Pod IP addresses in GKE clusters.

Container-native load balancing enables load balancers to target Pods directly and to make load distribution decisions at the Pod-level instead of at the VM-level.

The following example demonstrates how load balancers distribute traffic among microservices running in containers on your VMs. The VMs are configured to use alias IP ranges from their subnets, and those ranges are the addresses used by the containers.

Load balancing zonal network endpoint groups with containers.
Load balancing zonal network endpoint groups with containers (click to enlarge).

There are two ways to configure container-native load balancing: either use NEGs managed by GKE Ingress, or use standalone NEGs.

  • Kubernetes Ingress with NEGs (Recommended)

    When NEGs are used with Ingress, the Ingress controller facilitates the creation of all aspects of an HTTP(S) load balancer. This includes creating the virtual IP address, forwarding rules, health checks, firewall rules, and more. To learn how to configure this, see Container-native load balancing through Ingress.

    Ingress is the recommended way to use NEGs for container-native load balancing as it has many features that simplify the management of NEGs. Alternatively, you can create a proxy load balancer manually but still have GKE manage NEG endpoint membership, as described in the next point (Standalone NEGs).

    For instructions about how to set up a load balancer through Ingress, see Container-native load balancing through Ingress.

  • Standalone NEGs

    Standalone NEGs provide a way for your GKE cluster to create zonal NEGs with GCE_VM_IP_PORT endpoints representing Pod IP addresses and container ports, while giving you the flexibility to configure the load balancer components outside of GKE.

    For examples on using standalone zonal NEGs with GKE, see:

Limitations

  • You cannot use zonal NEGs with legacy networks.
  • A backend service that uses NEGs as backends cannot also use instance groups as backends.

Limitations for GCE_VM_IP zonal NEGs:

  • Zonal NEGs with GCE_VM_IP endpoints are only supported with internal passthrough Network Load Balancers and external passthrough Network Load Balancers.
  • The default-port property is not supported for GCE_VM_IP zonal NEGs.

Quotas

  • For information about NEG quotas—such as NEGs per project, NEGs per backend service, and endpoints per NEG—see the load balancing quotas page.

What's next