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/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:
- Network endpoint groups overview
- Internet network endpoint groups overview
- Serverless network endpoint groups overview
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.
- Zonal NEGs with
GCE_VM_IP_PORTendpoints. Supported as backends for the following load balancers:
- Zonal NEGs with
GCE_VM_IP NEGsendpoints. Supported as backends for internal TCP/UDP load balancers.
These zonal NEGs contain one or more internal network endpoints that resolve to a Compute Engine VM's primary IP address. You cannot specify a port with this type of zonal NEG.
GCE_VM_IP NEGs, you can only attach endpoints that belong to a VM's
primary internal IP address in NEG's VPC network. Primary
internal IP addresses from any NIC of a multi-NIC VM can be added to a NEG as
long as the NEG uses the same VPC network as the NIC.
These types of endpoints can only be used as backends in backend services for internal TCP/UDP load balancers.
These zonal NEGs contain one or more internal network endpoints that resolve to a VM's primary internal IP address or an IP address in one of its alias IP ranges. For example, GKE uses NEGs of this type, whose endpoints are an IP address from the node's alias IP range plus a port – a Pod IP address and container port. Each network endpoint is specified using an IP address and port combination.
Because these zonal NEG backends allow you to specify IP addresses and ports, you can distribute traffic in a granular fashion among applications or containers running within VM instances.
To create a unique
GCE_VM_IP_PORT network endpoint for a container or
application running in a
VM, you must either use the primary IP address of the VM or a secondary IP
assigned to the VM using the alias IP address feature. The
software running in the container or the application running in the VM should
be configured to bind to the IP address used by the network endpoint.
GCE_VM_IP_PORT NEGs are especially useful for GKE.
For information on using zonal NEGs with GKE, refer to
Using Container-native Load
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 network, you can omit specifying the subnet. However, a subnet is still associated with the zonal NEG. If you specify an auto mode network but do not 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
GCE_VM_IP_PORT). This determines what types of
endpoints the NEG supports.
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 (NIC) 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.
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 NIC's primary internal IP address or an alias IP on the NIC. The port is your choice.
If you specify just an IP address, the IP address can be either the VM NIC's primary internal IP address or an alias IP on the NIC. The port used is the NEG's default port.
If you omit both, Google Cloud selects the NIC's primary internal IP address and uses the NEG's default port.
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
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
mode or the
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 and you cannot
define a target capacity because internal TCP/UDP load balancers do not support
the target capacity setting.
You cannot use the
UTILIZATION balancing mode with zonal NEG backends.
Internal TCP/UDP Load Balancing
Zonal NEGs with
GCE_VM_IP endpoints can be used as backends for backend
services only for internal TCP/UDP load balancers.
The primary use-cases for NEGs with
GCE_VM_IP endpoints are:
Simplified VM management for internal TCP/UDP load balancers
Like instance groups, you can use the same NEG as a backend for multiple internal TCP/UDP load balancers. Unlike instance groups, a VM endpoint can be a member of multiple NEGs, and each of those NEGs can be used as a backend for one or more internal TCP/UDP load balancers.
GCP_VM_IP zonal NEGs and subsetting to improve
the scalability of internal TCP/UDP 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 TCP/UDP load balancer subsetting.
External HTTP(S), Internal HTTP(S), External TCP/SSL Proxy, and Internal TCP Proxy load balancing
The following illustrations show configuration components for load balancers
where zonal NEGs with
GCE_VM_IP_PORT endpoints are the backends:
To learn more about the architectural requirements of these load balancers, see: * External HTTP(S) load balancer overview * Internal HTTP(S) load balancer overview * External TCP proxy load balancer overview * Internal regional TCP proxy load balancer overview * External SSL proxy load balancer overview
The primary use case for
GCE_VM_IP_PORT NEGs 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
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.
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 provide a way for your GKE cluster to create zonal NEGs with
GCE_VM_IP_PORTendpoints 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:
- You cannot use zonal NEGs with legacy networks.
- A backend service that uses NEGs as backends cannot also use instance groups as backends.
- You can't use zonal NEGs as a backend for External TCP/UDP Network Load Balancing.
GCE_VM_IP zonal NEGs:
- Zonal NEGs with
GCE_VM_IPendpoints are only supported with internal TCP/UDP load balancers.
default-portproperty is not supported for
- You cannot use the console to create or manage
GCE_VM_IPNEGs. Use either
gcloudor the REST API.
- For information about NEG quotas—such as NEGs per project, NEGs per backend service, and endpoints per NEG—see the load balancing quotas page.
- For information about configuring zonal NEGs, see Setting Up zonal network endpoint groups in load balancing.
- For information about using zonal network endpoint groups in Google Kubernetes Engine, see Using container-native load balancing.