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.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Table of Contents
- Set the Default Region and Zone
- Create the GKE Cluster
- Prepare the Deployment Manifest
- Prepare the Service Manifest
- Deploy the Application and Service
- Verify the External Load Balancer
- Inspect the Service Configuration
- 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 namedgke-deep-dive with HTTP load balancing enabled:
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 ingke-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 ingke-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:| Resource | NAME | READY | STATUS | PORT(S) |
|---|---|---|---|---|
| Pod | gke-deep-dive-app-xxx | 1/1 | Running | |
| Service | gke-deep-dive-svc | 1729:31546/TCP |
EXTERNAL-IP to appear (this may take a few minutes).
6. Verify the External Load Balancer
Retrieve the external IP and test connectivity:curl requests should alternate between Pod backends.
7. Inspect the Service Configuration
Describe the Service to confirm load balancer details:- 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