The Kubernetes LoadBalancer Service
How one small setting turns a group of hidden, ever-changing containers into a steady, public front door that real users can reach, explained from zero.
Imagine you built a wonderful shop. The shelves are full, the staff is trained, and the tills work perfectly. But the shop is at the end of a private road with no sign, no street number, and a gate that only staff can open. Nobody can walk in. It does not matter how good the shop is if customers cannot find the door.
That is exactly the situation your application is in when you first run it inside Kubernetes. Your program is alive and healthy, but it lives on a private network inside the cluster. To let the outside world in, you need a public address, a doorman who shares visitors fairly between your workers, and a way to keep the door open even when workers come and go. In Kubernetes, one of the simplest ways to get all three is a Service of type LoadBalancer.
In this guide you will learn what a LoadBalancer Service is, why it exists, how it works step by step, how traffic really travels through it, how it differs from its cousins, and how professionals run it safely in production. Every new word will be explained the first time it appears.
1The Problem: Apps Trapped Inside a Cluster
Before we meet the solution, let us feel the problem. A tool only makes sense when you understand the pain it removes.
What is Kubernetes, in one minute?
A container is a small, sealed box that holds a program and everything the program needs to run. Running one container on one computer is easy. Running thousands of them across hundreds of computers is very hard. Kubernetes is the free, open-source system that does this hard work for you. It started life inside Google, which had been running containers at giant scale for years, and it was shared with the world in 2014. Today it is looked after by the Cloud Native Computing Foundation and is used by companies of every size.
A group of computers managed by Kubernetes is called a cluster. Each computer in the cluster is called a node. Your containers run inside small wrappers called Pods. A Pod is the smallest thing Kubernetes runs, and it usually holds one container.
Why Pods cannot simply be “visited”
Every Pod receives its own private address, called an IP address, from the cluster’s internal network. This sounds helpful, but there are three catches.
- The address is private. It only works inside the cluster. Someone on the internet cannot type it into a browser.
- The address is temporary. When a Pod crashes, gets updated, or is moved to another node, Kubernetes creates a new Pod with a brand new address. The old one is gone forever.
- There are many Pods. A busy app might have twenty copies running at once. A visitor should not have to choose one.
Think of a huge office building where workers are moved to a different desk every morning without warning. If a customer wrote down a worker’s desk number, it would be wrong by tomorrow. What the customer really needs is one permanent reception phone number. The receptionist knows who sits where today and passes the call to the right person. A Kubernetes Service is that receptionist, and a LoadBalancer Service is the receptionist with a public phone number printed on the building’s sign.
Pods are short-lived and private. Users need something long-lived and public. The gap between those two facts is the whole reason LoadBalancer Services exist.
2Building Blocks You Need First
Eight small ideas carry the whole story. Learn these and everything later will feel natural.
Pod
A small wrapper around one or more containers. It is the unit Kubernetes runs and replaces. Think of it as a single worker in the shop.
Node
One computer in the cluster, real or virtual. Pods live on nodes the way workers sit in rooms of a building.
Labels and Selectors
Labels are sticky notes on Pods, such as “app is shop”. A selector is a rule that says “find every Pod with this note”. This is how a Service knows which Pods belong to it.
Service
A permanent name and address in front of a changing group of Pods. It hides the churn behind a stable front.
Endpoints
The live list of Pod addresses that currently match a Service’s selector. Kubernetes keeps this list fresh automatically. Modern clusters store it in objects called EndpointSlices.
kube-proxy
A helper program on every node. It writes the traffic rules that send packets aimed at a Service toward a real Pod.
Control Plane
The brain of the cluster. It holds the API server (the front desk for all requests) and the controllers that keep reality matching what you asked for.
Cloud Controller Manager
The part of the brain that talks to your cloud company, such as AWS, Google Cloud or Azure, to order things like load balancers and disks.
A label and selector work like colored wristbands at a festival. Everyone with a green wristband belongs to the “food stall team”. The Service does not memorize names. It simply says “send visitors to anyone wearing green”, and the list updates itself as people join or leave.
3The Service Family and Where LoadBalancer Fits
Kubernetes offers several kinds of Service. Each one builds on the one before it, like floors of a building.
| Type | Who can reach it | What it gives you | Typical use |
|---|---|---|---|
| ClusterIP | Only things inside the cluster | A stable private address | Databases and internal APIs |
| NodePort | Anyone who can reach a node | A high-numbered port opened on every node | Quick tests and building blocks |
| LoadBalancer | The public internet or a private network | A real external load balancer with its own address | Front doors for apps |
| ExternalName | Things inside the cluster | A nickname pointing to an outside DNS name | Reaching outside services by a friendly name |
The floors of the building
A LoadBalancer Service is not a separate invention. It is built on top of the others. When you ask for a LoadBalancer, Kubernetes first gives you a ClusterIP (the internal receptionist). It then opens a NodePort on each node (a side door on every floor). Finally, it asks the cloud to build a load balancer outside the cluster that sends visitors to those side doors. Each layer depends on the one beneath it.
One detail for the curious: newer Kubernetes versions let you switch off the NodePort step for certain cloud setups that can send traffic straight to Pods. This is a special case. For learning, remember the three floors.
A NodePort alone is not a good public door. Node addresses can change, ports are ugly, and you would have to share traffic between nodes yourself. The LoadBalancer type removes all three problems.
4What a LoadBalancer Service Really Is
Let us define it in plain words, then look at exactly what it promises and what it does not.
A load balancer is a traffic manager. Many visitors arrive at one address, and the load balancer spreads them across several workers so that no single worker is overwhelmed. If a worker falls ill, the load balancer notices and stops sending visitors there.
A LoadBalancer Service in Kubernetes is a request written down in your cluster’s records. It says: “Please give this group of Pods a public front door that shares visitors fairly.” Kubernetes itself does not contain a full-strength load balancer machine. Instead, it asks the environment it lives in, usually a cloud company, to build one and then connects everything together.
Picture a big shopping mall with one main entrance and a friendly guard. Shoppers do not pick a shop at the door. The guard looks at which shops have space and points each shopper to one. If a shop closes for cleaning, the guard simply stops pointing people there. The cloud load balancer is that guard, and the Kubernetes Service is the list of shops the guard is allowed to send people to.
What you get
- A stable external address. It is either a number (an IP address) or a DNS name, depending on the cloud. It does not change when Pods change.
- Fair sharing of visitors across healthy nodes and Pods.
- Health checking, so broken targets are skipped.
- Hands-off setup. You describe the Service once; the cloud pieces are created and updated for you.
What it does not do
- It does not read web addresses like “/cart” or “/login” and route by them. It works at the level of connections (TCP and UDP), not web pages. That smarter routing is the job of Ingress or Gateway API, which we compare later.
- It does not work everywhere out of the box. On a laptop cluster with no cloud behind it, the external address can stay stuck on “pending” forever until you add a helper.
- It does not encrypt anything by itself. Security is a separate design choice.
5Architecture and Components
Here is the full picture. Follow the arrows from the user on the left to the Pods on the right.
flowchart LR
U["User on the Internet"] --> DNS["DNS Name"]
DNS --> CLB["Cloud Load Balancer with Public Address"]
subgraph K8S["Kubernetes Cluster"]
direction LR
subgraph N1["Worker Node 1"]
NP1["NodePort"] --> KP1["kube-proxy Rules"]
KP1 --> P1["Pod A"]
end
subgraph N2["Worker Node 2"]
NP2["NodePort"] --> KP2["kube-proxy Rules"]
KP2 --> P2["Pod B"]
KP2 --> P3["Pod C"]
end
SVC["LoadBalancer Service"]
CCM["Cloud Controller Manager"]
API["API Server"]
API --> SVC
API --> CCM
end
CLB --> NP1
CLB --> NP2
CCM -. creates and updates .-> CLB
Reading the diagram
There are two separate flows here, and mixing them up is a common beginner mistake.
The traffic flow is the path a visitor’s request takes: from the user, to a DNS name, to the cloud load balancer, to a NodePort on one of the nodes, through the kube-proxy rules, and finally to a Pod. This path is used thousands of times per second.
The control flow is the dotted line. It is how the load balancer got created in the first place. You submit a Service to the API server, the Cloud Controller Manager notices it, and it talks to the cloud provider to build and maintain the load balancer. This path is used only when something changes, like a new Service or an updated setting.
Meet each component
Cloud Load Balancer
A managed machine or service run by the cloud company. It owns the public address, accepts connections, checks target health, and spreads the load.
DNS Name
The friendly name people type, such as a shop’s website address. It points to the load balancer’s address so users never memorize numbers.
Service Object
The written request stored in the cluster. It holds the selector, the ports and any special settings for the load balancer.
Cloud Controller Manager
The translator between Kubernetes language and cloud language. It contains the service controller that watches for LoadBalancer requests.
NodePort and kube-proxy
The side door on every node and the rule-writer behind it. Together they carry visitors from the node’s door to a real Pod.
Pods
The workers that actually answer the request. They can sit on any node and be replaced at any time.
6How It Works Internally: Building the Front Door
What happens between “I wrote the Service” and “my app has a public address”? Let us walk through it slowly.
sequenceDiagram
participant Dev as Developer
participant API as API Server
participant CCM as Cloud Controller Manager
participant Cloud as Cloud Provider
Dev->>API: Create a Service of type LoadBalancer
API-->>CCM: A new Service was added
CCM->>Cloud: Please build a load balancer
Cloud-->>CCM: Done, here is the public address
CCM->>API: Save the address in the Service status
Dev->>API: Read the Service
API-->>Dev: External address is ready
You submit the request
You give the API server a Service that names a selector, one or more ports, and the type LoadBalancer. The API server checks it and stores it in the cluster’s database.
Kubernetes prepares the inner layers
A private ClusterIP is assigned. A NodePort is chosen from the allowed range. The list of matching Pod addresses starts being tracked.
The service controller notices
Inside the Cloud Controller Manager, a watcher sees the new LoadBalancer Service. It reads which nodes are healthy and what settings you asked for.
The cloud is asked to build
The controller calls the cloud provider’s own ordering system. The cloud creates a load balancer, opens a listener on your ports, and points it at the nodes’ NodePorts. This can take from several seconds to a few minutes.
The address is written back
When the cloud replies, the controller writes the new IP address or DNS name into the Service’s status. Until then, you will see the external address shown as “pending”.
A never-ending checking loop begins
Kubernetes controllers work like a caretaker who keeps comparing “what was asked” with “what exists”. If a node joins or leaves, the controller updates the load balancer’s target list. If you delete the Service, the cloud load balancer is deleted too, so you stop paying for it.
Ordering a load balancer is like asking a hotel concierge to book you a taxi service for your guests. You do not call the taxi company yourself. You leave a note at the desk, the concierge phones the company, and later the concierge writes the booking number on your note. If a guest room is closed, the concierge quietly updates the taxi company’s list. That concierge is the Cloud Controller Manager.
If the external address stays “pending” for a long time, the request reached Kubernetes but nobody fulfilled it. Common reasons are a cluster with no cloud connection, missing permissions for the controller, or a used-up quota of load balancers in your cloud account.
7Data Flow: The Life of One Request
Let us follow a single visitor, from typing a web address to seeing a page, and watch how each layer hands the request forward.
The name becomes a number
The visitor’s device asks DNS for the shop’s address. DNS answers with the address of the cloud load balancer.
A connection reaches the load balancer
The device opens a connection to that address. The load balancer, which lives outside your cluster, accepts it.
A healthy node is chosen
The load balancer looks at its list of nodes and picks one that passed its latest health check. Different connections may go to different nodes.
The node’s side door is used
The connection arrives at the chosen node on the NodePort number. The operating system on that node hands it to the rules written by kube-proxy.
The destination is rewritten
The rules pick one Pod from the Service’s live list and change the packet’s destination to that Pod’s private address. This trick is called destination address translation. The operating system remembers the choice so the rest of the conversation keeps going to the same Pod.
The Pod answers
The Pod builds the page, and the answer travels back along the same path in reverse. The visitor sees the page and never knows how many hops were involved.
How kube-proxy writes its rules
kube-proxy has a few ways of doing its job. The classic method uses a long list of packet-matching rules in the Linux kernel, known as iptables. A second method, called IPVS, uses a table built for load balancing, which handles very large numbers of Services more efficiently. Newer versions also offer a mode based on nftables, the modern successor to iptables. Some clusters skip kube-proxy completely and let a networking add-on such as Cilium do the same work with a technology called eBPF. You do not need to master any of these to use a LoadBalancer Service. Just know that a small, fast rule table on every node is what turns “Service address” into “real Pod”.
Because these rules sit inside the operating system kernel, forwarding is very fast. No extra program has to copy every byte of your traffic, which is why this design handles heavy load well.
A data flow with an important detail: the lifecycle of a connection
A connection has a beginning, a middle and an end. The load balancer picks the target when the connection starts. It does not move the connection midway. This is why, when you remove a Pod, existing long connections to it can be cut, and why graceful shutdown settings matter. We return to this in the best practices chapter.
8Traffic Policy, Client Addresses and Health Checks
One small setting decides whether traffic takes an extra hop and whether your app can see who the real visitor is.
Every Service has a setting called externalTrafficPolicy. It has two possible values, and understanding them will save you many hours of confusion.
flowchart LR
subgraph CL["Policy: Cluster (default)"]
LB1["Load Balancer"] --> NA["Node A with no local Pod"]
NA -->|"extra hop"| PB["Pod on Node B"]
LB1 --> NB["Node B with a Pod"]
NB --> PB
end
subgraph LO["Policy: Local"]
LB2["Load Balancer"] -. health check fails .-> NC["Node C with no local Pod"]
LB2 --> ND["Node D with a Pod"]
ND --> PD["Pod on Node D"]
end
Cluster (default)
- Every node accepts traffic, even if it has no matching Pod.
- Load is spread evenly across all Pods in the cluster.
- Traffic may hop to another node, adding a little delay.
- The original visitor address can be replaced by the node’s address on the way.
Local
- Only nodes that hold a matching Pod pass the health check.
- No extra hop, so traffic is a little faster.
- The visitor’s real address is kept, which helps with logging and allow-lists.
- Spread can be uneven if Pods are not evenly placed across nodes.
Why the visitor’s address matters
Many apps want to know who is calling. A bank may want to block certain countries. A security tool may want to count failed logins per visitor. If the address is replaced along the way, every visitor looks like it came from one of your own nodes. With the Local policy, or with a load balancer that passes the original address along using a small extra label called the PROXY protocol, your app can see the truth.
How health checks fit in
The cloud load balancer checks each node regularly, like a teacher calling the register. With the Local policy, Kubernetes opens a special health-check port on each node that answers “yes” only if a healthy local Pod exists. With the Cluster policy, the check is simpler and mostly tells the load balancer that the node itself is alive.
Cluster policy is a hospital reception that will accept any patient and then walk them across the building to the right ward. Local policy is a reception that only sends you to a floor where the doctor is actually in the room, so no walking is needed, but some floors will look empty. Choose based on whether you value even spread or a short, honest path.
There is also a setting for sticking a visitor to the same Pod based on their address, called session affinity. It works, but it is a blunt tool. Prefer apps that can handle any Pod answering any request.
9LoadBalancer on the Big Clouds
The Service looks the same everywhere, but what gets built behind it depends on where your cluster lives.
Amazon EKS
Older setups often produced a Classic Load Balancer. Modern setups use the AWS Load Balancer Controller to create a Network Load Balancer, which is faster and keeps connections at layer 4. With the right network add-on, it can send traffic straight to Pod addresses and skip the NodePort hop.
Google Kubernetes Engine
A LoadBalancer Service creates a Google Cloud network load balancer with a regional external address. Google can also use its own container-aware networking to send traffic to Pods more directly in some configurations.
Azure Kubernetes Service
The Service creates or updates an Azure Load Balancer and gives it a public IP address. Azure lets you ask for an internal, private load balancer instead using a Service annotation.
DigitalOcean, Oracle, Alibaba and more
Most major providers ship their own controller. The idea is identical: one Service in, one managed load balancer out, each with its own price and features.
Annotations: the cloud-specific notes
The Service object has a notes field called annotations. Cloud providers read special notes there to unlock extra features that Kubernetes itself does not define, such as choosing a private load balancer, picking a certificate, or setting idle timeouts. This is powerful but has a cost: a Service with AWS-style notes will not automatically behave the same on Azure. Keep this in mind if you plan to run in more than one cloud.
Public versus internal
Not every LoadBalancer must face the internet. Teams often create internal load balancers that only answer inside their private cloud network. This is common for services shared between departments, or for apps that a company’s other systems call but customers never do. The Service is the same; only a cloud-specific note changes.
Each LoadBalancer Service usually creates its own cloud load balancer, and you are billed for each one by the hour plus the data it carries. Twenty small services with twenty load balancers can quietly become a large monthly bill. This is one of the main reasons teams put many apps behind a single Ingress or Gateway instead.
10LoadBalancer on Your Own Servers and Laptop
What if there is no big cloud company to build the front door for you? Then you need to bring your own doorman.
Remember that Kubernetes does not ship with a load balancer machine. It only knows how to ask for one. On a cloud, the cloud company answers. On your own servers in a data center, or on a laptop, nobody answers, and the Service waits forever with its address shown as “pending”. This surprises almost every beginner. The fix is to install a small add-on that plays the role of the cloud.
MetalLB
The best-known add-on for servers you own. You give it a pool of spare addresses. When a Service asks for a LoadBalancer, MetalLB hands out one address from the pool and announces it to your network so that traffic finds its way to the cluster.
kube-vip and Cilium
Other tools that can hand out and announce addresses. Cilium, a popular networking add-on, includes its own address-pool feature and can talk to your routers as well.
minikube and kind
Small learning clusters. minikube offers a tunnel feature that fakes a public address on your machine. kind is often paired with MetalLB so that LoadBalancer Services get a usable address.
Lightweight distributions
Small Kubernetes builds for edge computers, such as k3s, bring a simple built-in helper that makes LoadBalancer Services work on the machine’s own address.
Two ways MetalLB announces an address
In Layer 2 mode, one node in the cluster answers the network’s question “who owns this address?”. All traffic for that address goes to that single node first, and then Kubernetes spreads it onward. It is very simple and works on almost any network. If that node dies, another node takes over after a short pause. The catch is that one node handles all the incoming traffic for that address at any moment.
In BGP mode, the cluster talks to your network routers using the same language the internet itself uses to find routes. The routers learn that several nodes can reach the address, so they spread incoming traffic across them. It scales better, but you need routers that support it and someone who understands your network.
Layer 2 mode is like a single mail sorter at the front of a building who takes every parcel and walks it to the right room. If he goes home sick, another sorter steps in after a moment. BGP mode is like giving the postal service a list of several doors, so parcels are delivered straight to any of them. The second way is faster for big buildings, but it needs the post office to cooperate.
When learning on a laptop, do not panic if the external address says “pending”. It does not mean you broke something. It means nobody is providing load balancers yet. Add one of the helpers above and the address appears.
11LoadBalancer, Ingress and Gateway API Compared
Three tools, three different jobs. Choosing the right one saves money and headaches.
Ingress is a set of routing rules for web traffic. It can look at the website name and the page path, then send the visitor to the right Service. It is carried out by a program called an Ingress controller. Gateway API is the newer, more flexible family of objects designed to replace and extend Ingress, and it reached its stable 1.0 release in late 2023. Both work mostly at layer 7, which means they understand web requests, not only raw connections.
| Question | LoadBalancer Service | Ingress | Gateway API |
|---|---|---|---|
| What does it understand? | Connections (TCP, UDP) | Web requests (host and path) | Web requests, with growing support for other protocols |
| Routes by page name? | No | Yes | Yes, with richer rules |
| Cloud load balancers used | Usually one per Service | Often one shared by many apps | Often one shared by many apps |
| Handles security certificates | Only if the cloud offers it | Yes, through the controller | Yes, with clearer roles for teams |
| Best for | Simple front doors and non-web protocols | Many websites and APIs on one entrance | Larger platforms with several teams |
A LoadBalancer Service is a building’s street entrance with a doorman who only knows “send this person inside”. Ingress and Gateway are the directory board and receptionist just inside the lobby who read the visitor’s request and say “Accounting is on floor three, Shipping is on floor five”. Someone still needs to guard the street entrance, and that is the LoadBalancer.
The surprising link between them
Here is a fact that clears up a lot of confusion: the Ingress controller or Gateway itself is just a set of Pods, and those Pods need to be reached from outside too. In most clusters, they are exposed using a single LoadBalancer Service. So these tools are not rivals. A common design is one LoadBalancer Service in front of a shared Ingress or Gateway, which then routes to dozens of apps behind it.
Serving one or two apps, or something that is not a website (a game server, a message broker, a DNS server)? A direct LoadBalancer Service is perfect. Serving many websites and APIs? Put an Ingress or Gateway behind one LoadBalancer.
12Advantages, Disadvantages and Trade-offs
No tool is perfect. Knowing the honest strengths and weaknesses helps you pick well.
Advantages
- Very simple to ask for: one Service type gives you a public door.
- A stable address that survives Pod and node changes.
- Works with any TCP or UDP protocol, not just websites.
- The heavy work is done by a managed cloud service that scales and repairs itself.
- Cleaned up automatically when you delete the Service.
- Built-in health checking of targets.
Disadvantages
- Usually one cloud load balancer per Service, which adds up in cost.
- No understanding of web paths, hosts or headers.
- Behavior and features differ from cloud to cloud.
- Needs an add-on outside the cloud, such as MetalLB.
- Creation can take minutes, so scripts must wait patiently.
- Client address can be lost unless you choose settings carefully.
The trade-offs behind the choices
Simplicity versus cost. One LoadBalancer per app is the easiest to reason about because each app owns its door. The price is a growing pile of load balancers. Sharing one entrance through Ingress or Gateway is cheaper but adds a layer that someone must run and understand.
Even spread versus honest addresses. The Cluster traffic policy shares load more evenly but may hide the visitor’s address. The Local policy keeps the address but can create hot spots.
Portability versus power. Cloud-specific notes unlock great features but tie your setup to one provider. Teams that may move between clouds keep those notes in one clearly documented place.
Speed versus smartness. A layer 4 load balancer only moves connections, so it is fast and light. A layer 7 tool reads each request, so it can do smart routing, but it costs a bit more time and computing power per request.
13Security: Guarding the Front Door
A public door invites customers, but it also invites troublemakers. Good security is layered, like a castle with a moat, a wall and locked rooms.
Limit who can knock
A Service can carry a list of allowed visitor address ranges. Anyone outside the list is turned away at the door. This is ideal for admin tools that only your office should reach.
Choose private when you can
If only other systems inside your company need the service, use an internal load balancer. A door that does not face the internet cannot be attacked from the internet.
Encrypt the conversation
Traffic should travel in a locked envelope, called TLS. Some clouds can unlock and re-lock it at the load balancer. Otherwise the Pods handle it themselves, or an Ingress or Gateway in front does the job.
Add a shield for web attacks
A layer 4 load balancer cannot read web requests, so it cannot spot attacks such as harmful form input. For websites, add a web application firewall and cloud protection against traffic floods in front of, or beside, the door.
Lock the rooms inside
Network policies decide which Pods may talk to which. Even if a visitor gets through the door, they should not be able to wander into your database Pods.
Control who can build doors
Creating a LoadBalancer Service opens a public entrance. Use permissions and admission rules so only trusted people or pipelines can do it, and so that risky settings are rejected automatically.
Protecting the controller’s keys
The Cloud Controller Manager needs permission to create and edit load balancers in your cloud account. Give it only the permissions it needs and nothing more. Keep an eye on cloud audit logs to see who created which load balancer and when.
Exposing a database or an internal dashboard with a LoadBalancer Service and no allowed-range list is a classic way that private data ends up on the public internet. Always ask: “Does the whole world need to reach this?”
14Monitoring, Logging and Metrics
You cannot fix what you cannot see. A healthy front door needs a few dashboards and a few alarms.
Think of your front door like a shop entrance with a people counter, a camera and a fire alarm. You want to know how many people come in, whether the door is stuck, and whether anything is going wrong.
Three places to look
The cloud load balancer
Cloud companies publish numbers for each load balancer: how many connections are active, how many new ones arrive each second, how much data flows, how many targets are healthy, and how many connections fail. These show if the door itself is struggling.
Kubernetes itself
Watch Service events, the count of ready Pods behind each Service, node health, and kube-proxy statistics. A Service with zero ready Pods is an open door to an empty room.
Your application
Measure how long answers take and how often errors occur. The load balancer may look fine while the app behind it is slow, so both views are needed.
Logs that help
Many clouds can save access logs and network flow logs from the load balancer to storage, showing who connected and when. Keep them for security reviews and for solving strange incidents. Inside the cluster, gather Pod logs in one central place so you can follow one request from the door to the answer.
Alarms worth having
- Any Service whose external address stays “pending” for longer than a few minutes.
- The number of healthy targets falling below a safe minimum.
- Sudden spikes in failed connections or in total traffic.
- Latency rising above what your users tolerate.
- A load balancer that exists in the cloud but no longer belongs to any Service, since this means you are paying for nothing.
A popular way to collect cluster numbers is Prometheus with Grafana dashboards. Cloud numbers can be pulled into the same dashboards, so you get one screen showing the whole journey of a request.
15Design Patterns and Anti-patterns
A pattern is a solution that many teams found works well. An anti-pattern is a trap many teams fell into.
Patterns that work
Pattern: One door in front of a shared router
Expose a single Ingress controller or Gateway using one LoadBalancer Service. Dozens of apps share the entrance, certificates are managed in one place, and the cloud bill stays predictable.
Pattern: Internal doors for private services
Use internal load balancers for services that only other company systems call. This keeps them off the internet while still giving them a stable address.
Pattern: Direct door for non-web traffic
Game servers, message brokers, DNS servers and voice systems speak TCP or UDP rather than web requests. A direct LoadBalancer Service is the natural fit.
Pattern: Reserved address plus friendly name
Reserve a fixed public address from your cloud and attach it to the Service. Then point your DNS name at it. Partners who allow-list your address will not be surprised when you rebuild the cluster.
Pattern: Blue and green switch
Run an old and a new version side by side, each with its own label. Change the Service’s selector to flip all traffic from old to new in one step, and flip back instantly if trouble appears. Because the front door never changes, users notice nothing.
Pattern: Global DNS above regional doors
Run one cluster and one load balancer in each region, then let a global DNS or traffic service direct users to the closest healthy region. Each regional LoadBalancer is simple, and the global layer handles disasters.
Traps to avoid
What it looks like
Every small microservice gets its own public LoadBalancer Service, even ones that only other services use.
Why it hurts
Costs grow with every service, the attack surface widens, and nobody remembers which door leads where.
Better approach
Keep most services private with ClusterIP, and expose only the few that truly need the outside world, ideally through one shared entrance.
What it looks like
Typing the load balancer’s raw address into application settings, emails or partner contracts.
Why it hurts
On many clouds the address can change if the Service is deleted and recreated, and some clouds give you a DNS name rather than a fixed number. Anything that copied the old value breaks.
Better approach
Always use a DNS name you control, and reserve a fixed address if you truly need one.
What it looks like
Running a single Pod behind the load balancer and calling the system highly available.
Why it hurts
A fancy front door does not help if there is only one worker inside. When that Pod restarts, every visitor sees an error.
Better approach
Run several Pods, spread them across different nodes and different data center zones, and protect them from being all removed at once during maintenance.
16Best Practices and Common Mistakes
These habits separate a shaky setup from a calm, dependable one.
Habits that pay off
- Use readiness checks. A readiness check tells Kubernetes whether a Pod is truly prepared to serve. Pods that are not ready are removed from the Service’s list, so visitors never reach a Pod that is still starting up.
- Shut down gracefully. When a Pod is being removed, give it time to finish its current work and let the load balancer notice before it disappears. Without this, users see random errors during every update.
- Run enough Pods, in more than one zone. A zone is a separate building within a cloud region. Spreading Pods across zones lets you survive the loss of one.
- Protect against too many removals at once. A disruption budget tells Kubernetes the minimum number of Pods that must stay alive during maintenance.
- Pick the traffic policy on purpose. Decide whether you need the real visitor address or the smoothest spread, and test it.
- Restrict access by default. Start with a short allowed-range list and widen it only if needed.
- Label and track cost. Add notes so you can tell which team owns which load balancer, and review the list regularly.
- Delete what you no longer use. Unused Services keep their load balancers alive and their bills running.
- Test failure on purpose. Turn off a node in a test setting and watch what your users would see.
Mistakes beginners make
Selector does not match
A typo in the label rule means the Service finds zero Pods. The load balancer exists, but every check fails. Always confirm the Service has a list of live targets.
Wrong port numbers
The Service has a port it listens on and a port it forwards to inside the Pod. Mixing them up produces connection errors that look mysterious.
Blocked by firewalls
Cloud firewall rules or security groups can block the NodePort range or the health check traffic. The load balancer then believes every node is dead.
Expecting instant readiness
A new load balancer can take minutes before it accepts traffic, and DNS changes may take time to spread. Build waiting into your release steps.
Forgetting idle timeouts
Load balancers close connections that sit quiet too long. Long-lived connections, such as streaming or chat, need suitable timeout settings or keep-alive messages.
Assuming web smarts
Expecting a LoadBalancer Service to route by page path or to add security headers. It cannot. That needs Ingress, Gateway API or a layer 7 tool.
17Real-World and Industry Examples
Seeing how real companies and everyday setups use these ideas makes them stick.
A game that went viral: Pokémon GO
Niantic ran the backend of Pokémon GO on Google Kubernetes Engine. When the game launched, player numbers were many times higher than the company had planned for. A design where the front door and the workers behind it can grow and be replaced without changing the public address is exactly what such a launch needs. Game traffic is also a good example of why a layer 4 door matters, since real-time games often use raw connections rather than web pages.
Music streaming: Spotify
Spotify has publicly shared its move of many backend services onto Kubernetes. At that size, teams need standard, repeatable ways to give services stable addresses without hand-building network paths for each one. Services types like LoadBalancer, combined with shared routing layers, are the kind of building blocks that make this repeatable.
Travel and marketplaces: Airbnb
Airbnb has described running a large portion of its services and internal tools on Kubernetes. With many teams shipping changes daily, a stable front door means new versions can appear behind it while guests and hosts keep using the same address.
News and media: The New York Times
The Times has talked publicly about moving to Google Kubernetes Engine. Media sites face sudden traffic surges when big stories break. Load balancers that spread visitors across many healthy Pods, together with the ability to add more Pods quickly, help keep pages loading during those surges.
A typical online shop
Picture a store on a managed Kubernetes service. The website and the checkout API sit behind one Ingress controller, which is exposed using a single LoadBalancer Service with a reserved public address and a DNS name. A separate internal LoadBalancer lets the company’s warehouse system call the stock service privately. The database is never exposed at all. This mix of one public door, one private door and no door for the database is a very common and sensible layout.
Internet of Things fleet
Thousands of smart devices send small messages to a message broker using a lightweight protocol that is not ordinary web traffic. A direct LoadBalancer Service gives the broker a public address, spreads device connections across broker Pods, and skips the web-only routing layers that would get in the way.
18Frequently Asked Questions
Quick answers to the questions beginners ask most often.
19Summary and Key Takeaways
You started with a shop nobody could enter. Now you know how to build it a proper front door.
Key Takeaways
- The problem: Pods have private, short-lived addresses, so outside visitors cannot rely on them.
- The solution: A LoadBalancer Service asks the environment, usually a cloud, to build a public front door with a stable address and fair sharing of traffic.
- How it is built: It stacks on top of a ClusterIP and a NodePort, and the Cloud Controller Manager creates the external load balancer and writes its address back into the Service.
- How traffic flows: User, DNS, cloud load balancer, healthy node, kube-proxy rules, then a Pod, and the answer returns the same way.
- Key settings: The traffic policy decides between even spread and keeping the visitor’s address, and health checks keep broken targets out of rotation.
- Choose wisely: Use a direct LoadBalancer for simple or non-web services, and put many web apps behind one Ingress or Gateway to save cost.
- Run it safely: Restrict who can connect, prefer private doors when possible, run several Pods across zones, use readiness checks and graceful shutdown, and watch your dashboards and bills.