Skip to main content
In this guide, you will learn how to set up a backend service–based external (Layer 4) load balancer on Google Kubernetes Engine (GKE). We’ll walk through configuring your gcloud defaults, creating a GKE cluster with HTTP load balancing, deploying an echo server, exposing it via an annotated Service, and verifying traffic distribution across Pods.

Table of Contents

  1. Set the Default Region and Zone
  2. Create the GKE Cluster
  3. Prepare the Deployment Manifest
  4. Prepare the Service Manifest
  5. Deploy the Application and Service
  6. Verify the External Load Balancer
  7. Inspect the Service Configuration
  8. Links and References

1. Set the Default Region and Zone

Configure your default compute zone so that all subsequent gcloud commands target us-west1-a:

2. Create the GKE Cluster

Create a cluster named gke-deep-dive with HTTP load balancing enabled:
This step can take several minutes. Once complete, verify the HTTP load balancing add-on:
Expected output snippet:
Creating clusters and load balancers may incur charges on your GCP account. Monitor your billing dashboard or delete resources when you’re done.

3. Prepare the Deployment Manifest

Save the following Deployment in gke-deep-dive-app.yaml. It launches two replicas of an echo server on port 8080 and configures a readiness probe.
The readiness probe ensures that traffic is only routed to Pods that have successfully started.

4. Prepare the Service Manifest

Save the following Service definition in gke-deep-dive-svc.yaml. The annotation cloud.google.com/l4-rbs: "true" requests a backend service–based external L4 load balancer.

5. Deploy the Application and Service

Apply both manifests and verify resources:
Check Pods and Services:
Example output: Wait for the Service’s EXTERNAL-IP to appear (this may take a few minutes).

6. Verify the External Load Balancer

Retrieve the external IP and test connectivity:
A successful response looks like:
Multiple curl requests should alternate between Pod backends.

7. Inspect the Service Configuration

Describe the Service to confirm load balancer details:
Key fields:
  • Type: LoadBalancer
  • Annotations: cloud.google.com/l4-rbs: “true”
  • Port Mapping: 1729/TCP → 8080/TCP
  • Endpoints: Pod IPs on port 8080
  • External Traffic Policy: Cluster
Sample excerpt:
Your backend service–based external load balancer is now active and distributing traffic across your GKE Pods.

Watch Video