Skip to main content
In this tutorial, you’ll learn how to set up container-native load balancing for your GKE applications using Ingress and Network Endpoint Groups (NEGs). We’ll cover:
  1. Creating a custom subnet in your VPC
  2. Provisioning a VPC-native GKE cluster with IP aliasing
  3. Deploying a simple HTTP server
  4. Exposing it via Ingress backed by a NEG
  5. Viewing the resulting Load Balancer and NEGs
  6. Scaling the deployment and validating load balancing
This end-to-end guide uses Google Cloud Platform commands, Kubernetes manifests, and Console walkthroughs.

1. Create a custom subnet

First, create a /24 subnet in the default VPC in us-west1:
You can verify the new subnet under VPC networks > default VPC in the Cloud Console.
Choose a CIDR range that doesn’t overlap with your existing networks. This subnet will host both Pods and Services via secondary IP ranges.

2. Provision a VPC-native GKE cluster

Set your Compute region and zone, then create a GKE cluster with IP aliasing enabled on the custom subnet:
Cluster provisioning typically takes 10–15 minutes. Verify that two secondary IP ranges (for Pods and Services) appear under your subnet.
The image shows a Google Cloud Platform interface displaying details of a VPC subnet named "gke-deep-dive-subnet," including its IP ranges, region, and other network settings.

3. Deploy the HTTP server application

We’ll deploy a basic HTTP server that responds with its Pod hostname.

3.1 Deployment manifest

Create a file named gke-deep-dive-app.yaml:
Apply and verify:

3.2 Service manifest

Expose the Deployment as a ClusterIP Service annotated for NEGs. Save as gke-deep-dive-svc.yaml:
Apply and confirm:

3.3 Ingress manifest

Create gke-deep-dive-ing.yaml to route HTTP traffic via Ingress:
Apply the Ingress:
An EXTERNAL-IP may take a few minutes to appear. Wait until it’s provisioned before testing.
Once you have the IP, browse to:
You should see the hostname of the serving Pod.

3.4 Resource manifest overview


4. View Load Balancer and NEG

In the Cloud Console, go to Network services > Load balancing. You’ll see an HTTP(S) Load Balancer created for your Ingress:
The image shows a Google Cloud Platform interface for managing network services, specifically focusing on load balancing. It includes options for creating and managing load balancers, with details about backend services and protocols.
Click the Load Balancer name to view both frontend and backend configurations:
The image shows a Google Cloud Platform interface displaying load balancer details, including frontend and backend configurations, protocols, and network tiers. It provides information about host and path rules, backend services, and health checks.
Select the backend service to inspect the NEG:
The image shows a Google Cloud Platform interface displaying details of a network endpoint group, including network endpoints, scope, subnet, and a list of endpoints with their IP addresses and health status.

5. Scale and verify load balancing

Increase the Deployment to three replicas:
Refresh your browser at the Ingress IP. You’ll see responses cycling through the three Pod hostnames, demonstrating container-native load balancing via Ingress + NEGs.

Watch Video