Skip to main content

Hidden Kubernetes Costs: NAT Gateways, Cross-AZ Traffic, and Load Balancers

· 12 min read

You optimized your pod requests, eliminated idle workloads, and right-sized your nodes. Your compute costs dropped 30%. Then you looked at your cloud bill and realized compute is only 60% of your Kubernetes spend. The rest? Networking charges that nobody on the team fully understands.

The Iceberg Problem​

When teams think "Kubernetes costs," they think CPU and memory. That's the visible tip. Below the waterline sits a collection of networking and infrastructure charges that are difficult to monitor, poorly understood, and surprisingly expensive:

         ┌──────────────┐
│ Compute │ ← What you optimize
│ (CPU + RAM) │
─────────┴──────────────┴─────────── waterline
┌──────────────────────────┐
│ NAT Gateway data fees │
│ Cross-AZ transfer │
│ Load balancer hours │ ← What actually kills your budget
│ DNS query charges │
│ Elastic IP idle fees │
│ Log/metric ingestion │
└──────────────────────────┘

In a typical AWS EKS cluster, these hidden costs add 20-40% on top of compute. On GKE and AKS it's lower (10-25%) but still significant. Let's break each one down.

1. NAT Gateway: The $0.045/GB Tax​

If your pods need to reach the internet — pulling container images, calling external APIs, sending webhooks — and your nodes are in private subnets (which they should be), all outbound traffic routes through a NAT Gateway.

AWS NAT Gateway pricing:

ComponentCost
Hourly charge$0.045/hr ($32.85/month) per gateway
Data processing$0.045/GB

The hourly charge is a rounding error. The data processing charge is the killer. Every byte that transits the NAT Gateway — outbound and inbound responses — costs $0.045/GB.

How it adds up:

Traffic sourceMonthly volumeNAT cost
Container image pulls50 GB$2.25
External API calls200 GB$9.00
Log shipping to SaaS500 GB$22.50
Metrics export100 GB$4.50
Package/dependency downloads30 GB$1.35
Total880 GB$39.60 + $32.85 hourly = $72.45

That's a single NAT Gateway in a single AZ. Most production setups run one per AZ for redundancy — multiply by 3.

Monthly NAT cost for a typical 3-AZ cluster: $217

And that's a modest traffic volume. Organizations shipping logs to Datadog or Splunk routinely see 2-5 TB/month through NAT Gateways — $90-225/month per gateway just in data processing fees.

How to Reduce NAT Gateway Costs​

1. Use VPC endpoints for AWS services

If your pods pull images from ECR, write logs to CloudWatch, or push metrics to S3, that traffic doesn't need to traverse the NAT Gateway. VPC Gateway Endpoints (S3, DynamoDB) are free. VPC Interface Endpoints (ECR, CloudWatch, STS, etc.) cost $0.01/hr + $0.01/GB — still much cheaper than NAT at $0.045/GB.

# Check how much NAT traffic goes to AWS services (CloudWatch → NAT Gateway metrics)
# If > 50%, VPC endpoints will pay for themselves immediately

# Key endpoints to create:
# - com.amazonaws.{region}.s3 (Gateway, free)
# - com.amazonaws.{region}.ecr.api (Interface, $7.30/mo)
# - com.amazonaws.{region}.ecr.dkr (Interface, $7.30/mo)
# - com.amazonaws.{region}.logs (Interface, $7.30/mo)
# - com.amazonaws.{region}.monitoring (Interface, $7.30/mo)
# - com.amazonaws.{region}.sts (Interface, $7.30/mo)

A set of 5 Interface Endpoints costs $36.50/month — and typically eliminates 60-80% of NAT Gateway data fees.

2. Cache container images locally

Every node pull of a 500MB image goes through the NAT Gateway. If you have 20 nodes and they all pull the same image, that's 10 GB through NAT for a single deployment. Use a pull-through cache or in-cluster registry mirror:

# Example: Zot registry as an ECR pull-through cache (DaemonSet)
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: registry-mirror
namespace: kube-system
spec:
selector:
matchLabels:
app: registry-mirror
template:
metadata:
labels:
app: registry-mirror
spec:
containers:
- name: zot
image: ghcr.io/project-zot/zot-linux-amd64:latest
ports:
- containerPort: 5000
hostPort: 5000
volumeMounts:
- name: registry-data
mountPath: /var/lib/registry
volumes:
- name: registry-data
hostPath:
path: /var/lib/registry

3. Ship logs internally, not through NAT

If you're sending logs to an external SaaS, consider aggregating them inside the VPC first. A Fluent Bit → in-VPC Elasticsearch/Loki pipeline eliminates NAT charges for log traffic entirely.

GCP equivalent: Cloud NAT charges $0.045/GB processed. Same mitigation: use Private Google Access for GCP APIs, Private Service Connect for everything else.

Azure equivalent: Azure NAT Gateway charges $0.045/GB. Use Service Endpoints (free) and Private Endpoints ($0.01/hr) to keep Azure-service traffic off the NAT path.

2. Cross-AZ Data Transfer: The Silent Multiplier​

Every time a pod in us-east-1a talks to a pod in us-east-1b, both sides pay:

ProviderCross-AZ cost
AWS$0.01/GB each direction ($0.02/GB round trip)
GCP$0.01/GB each direction
AzureFree within the same region (one of Azure's few pricing wins)

$0.02/GB doesn't sound like much until you calculate the volume. In a microservices architecture, a single user request can fan out to 5-10 internal service calls. If those services are distributed across AZs:

Example: E-commerce checkout flow

User → API Gateway (AZ-a)
→ Auth Service (AZ-b) 1 MB round trip
→ Cart Service (AZ-c) 2 MB round trip
→ Inventory Service (AZ-a) 0.5 MB (same AZ, free)
→ Payment Service (AZ-b) 1 MB round trip
→ Notification Service (AZ-c) 0.5 MB round trip
─────────────
Cross-AZ: 5 MB per checkout

At 100,000 checkouts/day: 500 GB/day cross-AZ = ~$300/month just for one flow.

Now multiply by every microservice interaction in your cluster — health checks, metrics scraping, service mesh sidecars (Istio injects ~1KB per request in headers), log forwarding. Cross-AZ traffic in a busy cluster easily hits 5-20 TB/month.

How to Reduce Cross-AZ Transfer Costs​

1. Topology-aware routing

Kubernetes 1.27+ supports topology-aware routing natively. When enabled, kube-proxy prefers endpoints in the same AZ:

apiVersion: v1
kind: Service
metadata:
name: cart-service
annotations:
service.kubernetes.io/topology-mode: Auto
spec:
selector:
app: cart
ports:
- port: 8080

With topology-mode: Auto, traffic from a pod in us-east-1a preferentially routes to cart-service pods also in us-east-1a. Cross-AZ traffic only occurs when the local AZ has insufficient capacity.

Caveat: This can create load imbalance if pod distribution across AZs is uneven. Monitor per-AZ pod counts and latency after enabling.

2. Co-locate chatty services

If Service A and Service B exchange 10 GB/day, schedule them in the same AZ using pod affinity:

# Schedule payment-processor near cart-service
apiVersion: apps/v1
kind: Deployment
metadata:
name: payment-processor
spec:
template:
spec:
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: cart-service
topologyKey: topology.kubernetes.io/zone

Use preferredDuringScheduling (soft), not requiredDuringScheduling (hard). Hard affinity breaks HA — if the target AZ goes down, your pods can't reschedule.

3. Compress inter-service payloads

If you can't co-locate services, compress the data they exchange. gRPC with gzip compression typically reduces payload size by 70-80%:

# Enable gRPC compression in your service
env:
- name: GRPC_DEFAULT_COMPRESSION
value: "gzip"

For REST APIs, enable response compression at the application level. A 70% reduction in payload size means a 70% reduction in cross-AZ fees.

4. Measure before optimizing

You can't fix what you can't see. Use VPC Flow Logs (AWS), VPC Flow Logs (GCP), or NSG Flow Logs (Azure) to quantify cross-AZ traffic:

# AWS: Enable VPC Flow Logs and query with Athena
# This query shows top cross-AZ traffic pairs
SELECT
srcaddr, dstaddr, az_id,
SUM(bytes) / 1073741824 as gb_transferred
FROM vpc_flow_logs
WHERE az_id != dst_az_id
AND action = 'ACCEPT'
GROUP BY srcaddr, dstaddr, az_id
ORDER BY gb_transferred DESC
LIMIT 20;

3. Load Balancers: Pay-Per-Hour Whether You Use Them or Not​

Every Kubernetes Service of type LoadBalancer provisions a cloud load balancer. Each one costs money — even if it handles zero traffic.

Hourly costs (idle):

TypeAWSGCPAzure
Network LB (L4)$0.0225/hr ($16.43/mo)$0.025/hr ($18.25/mo)$0.005/hr ($3.65/mo)
Application LB (L7)$0.0225/hr + LCU$0.025/hr + backend$0.005/hr + rules

Data processing costs (per GB):

ProviderCost
AWS ALB$0.008/LCU-hour (complex formula)
AWS NLB$0.006/NLCU-hour
GCP$0.008-0.012/GB
AzureIncluded in base (Standard SKU)

The problem isn't one load balancer — it's the pattern of creating many. In a typical microservices cluster:

# How many LoadBalancer services do you have?
kubectl get svc -A --field-selector spec.type=LoadBalancer --no-headers | wc -l

It's common to find 8-15 LoadBalancer services in a production cluster. At $16/month each (AWS), that's $128-240/month in idle LB charges alone — before any traffic flows.

How to Reduce Load Balancer Costs​

1. Use an Ingress Controller instead of per-service LBs

Replace multiple LoadBalancer services with a single Ingress Controller (nginx, Traefik, HAProxy) backed by one load balancer:

# Before: 5 services, 5 load balancers ($82/month idle)
apiVersion: v1
kind: Service
metadata:
name: api-service
spec:
type: LoadBalancer # Creates its own LB
---
apiVersion: v1
kind: Service
metadata:
name: web-service
spec:
type: LoadBalancer # Creates its own LB
# ... repeat for each service

# After: 5 services behind 1 Ingress, 1 load balancer ($16/month idle)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: main-ingress
spec:
ingressClassName: nginx
rules:
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-service
port:
number: 8080
- host: web.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 3000

Savings: 4 fewer LBs = $66/month in this small example. At scale (15 services → 1 Ingress), savings reach $200+/month.

2. Use Gateway API with shared listeners

Kubernetes Gateway API (GA in 1.29) takes this further with explicit infrastructure sharing:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: shared-gateway
spec:
gatewayClassName: aws-alb
listeners:
- name: https
port: 443
protocol: HTTPS
tls:
certificateRefs:
- name: wildcard-cert
allowedRoutes:
namespaces:
from: All

Multiple teams can attach HTTPRoute resources to a single Gateway — one load balancer, many routing rules.

3. Clean up orphaned load balancers

When you delete a LoadBalancer Service, Kubernetes should delete the cloud LB. But it doesn't always work — especially after forced deletions, finalizer issues, or controller crashes. Check for orphans:

# AWS: List all ELBs/ALBs/NLBs and check for ones not managed by K8s
aws elbv2 describe-load-balancers --query 'LoadBalancers[*].[LoadBalancerName,State.Code,CreatedTime]' --output table

# Cross-reference with K8s services
kubectl get svc -A -o jsonpath='{range .items[?(@.spec.type=="LoadBalancer")]}{.metadata.namespace}/{.metadata.name}: {.status.loadBalancer.ingress[0].hostname}{"\n"}{end}'

Any cloud LB not referenced by a Kubernetes service is an orphan you're paying for.

4. Other Hidden Costs Worth Checking​

DNS Query Charges​

Route 53 charges $0.40 per million queries. CoreDNS inside the cluster generates a surprising volume — every service discovery lookup, every external DNS resolution. Clusters with aggressive DNS TTLs or chatty services can hit 100M+ queries/month ($40/month). Not huge, but not zero.

Fix: Enable NodeLocal DNSCache. It runs a DNS cache on every node, reducing Route 53 queries by 80-90%:

# Check if NodeLocal DNSCache is already running
kubectl get ds -n kube-system | grep node-local-dns

Elastic IP Charges​

Since February 2024, AWS charges $0.005/hr ($3.65/month) for every public IPv4 address — even ones attached to running instances. Each LoadBalancer service allocates 1 public IP per AZ. A single NLB across 3 AZs = 3 public IPs = $10.95/month.

# Count your public IPs (AWS)
aws ec2 describe-addresses --query 'Addresses[*].[PublicIp,AssociationId]' --output table

Log and Metric Ingestion​

CloudWatch Logs ingestion: $0.50/GB. Datadog custom metrics: $0.05/metric/month. A Prometheus stack scraping 500 pods at 15-second intervals generates 2-5 GB/day of metric data. If that flows to a SaaS observability platform, ingestion costs can exceed your compute costs.

Fix: Filter before shipping. Drop debug-level logs, reduce metric cardinality, increase scrape intervals for non-critical targets.

Putting It All Together​

Here's a real-world cost breakdown from a mid-size EKS cluster (50 nodes, 3 AZs, ~400 pods):

CategoryMonthly Cost% of Total
EC2 instances (compute)$7,20056%
NAT Gateway (3x)$8907%
Cross-AZ data transfer$6405%
Load balancers (8x)$3853%
EBS volumes (PVCs)$1,2009%
Elastic IPs$881%
CloudWatch Logs$4203%
Route 53 DNS$45<1%
ECR storage$30<1%
EKS control plane$731%
Other (S3, Secrets Manager, etc.)$1,92915%
Total$12,900

Compute is 56% of the bill. The remaining 44% — $5,700/month — is infrastructure that most Kubernetes cost tools ignore entirely because it doesn't show up in kubectl top.

Tools like K8Cost factor in these non-compute costs when calculating total cluster spend, so your chargeback reports reflect what you're actually paying — not just the CPU and memory slice.

Action Checklist​

  1. Audit NAT Gateway traffic. Check VPC Flow Logs or CloudWatch NAT metrics. If AWS-service traffic (ECR, S3, CloudWatch) exceeds 30%, deploy VPC Endpoints immediately.
  2. Count your load balancers. kubectl get svc -A --field-selector spec.type=LoadBalancer. If you have more than 3, consolidate behind an Ingress Controller.
  3. Measure cross-AZ transfer. Enable topology-aware routing on your highest-traffic services. Monitor for load imbalance.
  4. Check for orphaned resources. Cloud LBs, EIPs, and EBS volumes that aren't attached to anything running.
  5. Review observability costs. Are you shipping debug logs to a $0.50/GB platform? Filter first.
  6. Add non-compute costs to your FinOps reporting. If your cost dashboard only shows CPU and memory, it's showing you 60% of the picture.

Hidden costs aren't hidden because they're small. They're hidden because they live in a different part of the cloud bill than the Kubernetes console shows. Once you know where to look, the savings are straightforward.