Cloud Architecture
The $50,000 NAT Gateway Bill
Every CFO loves Kubernetes until they see the bill. They understand "EC2 compute" (we pay for servers). They understand "S3 storage" (we pay for disk). But they scream when they see: "EC2-Other: Data Transfer - $50,000".
The $50,000 NAT Gateway Bill

Every CFO loves Kubernetes until they see the bill. They understand "EC2 compute" (we pay for servers). They understand "S3 storage" (we pay for disk). But they scream when they see: "EC2-Other: Data Transfer - $50,000".

For many SaaS companies, networking costs are arguably the most opaque and dangerous part of the cloud bill. And Kubernetes, by default, is designed to burn money on networking.

The "High Availability" Trap: Kubernetes schedulers love to spread pods across Availability Zones (AZs) for reliability.

  • Frontend Pod is in us-east-1a.

  • Backend Pod is in us-east-1b.

In AWS, traffic within an AZ is free. Traffic between AZs costs $0.02/GB. If your frontend talks to your backend 1,000 times a second, you are paying a "Cross-AZ Tax" on every single packet.

Part 1: The Core Culprit (Cross-AZ Traffic)

In a standard Deployment, you set replicas: 10. The scheduler acts randomly. It places 3 in Zone A, 4 in Zone B, 3 in Zone C.

When Service A calls Service B, the Kubernetes Service (ClusterIP) load balances via iptables or IPVS. It round-robins the request to any healthy pod. Statistically, 66% of your traffic will cross an AZ boundary. You are paying a tax on 66% of your internal traffic.

The Solution: Topology Aware Routing

Kubernetes v1.23 introduced Topology Aware Hints. It tells the Kube-Proxy: "If I am in Zone A, please try to send this request to a Pod in Zone A."

YAML

apiVersion: v1
kind: Service
metadata:
  name: my-service
  annotations:
    service.kubernetes.io/topology-mode: Auto

This simple annotation can cut your Data Transfer bill by 60% overnight.

Part 2: The NAT Gateway Tax

The NAT Gateway is the single most expensive managed service in AWS relative to what it does. It allows private subnets to talk to the internet. Price: $0.045/hour + $0.045/GB processed.

The Mistake: You put your S3 bucket in a private subnet. Your app downloads 10TB of images from S3. The traffic goes: App -> NAT Gateway -> Internet -> S3. You pay $450 in NAT fees.

The Solution: VPC Endpoints (Gateway Endpoints)

A Gateway Endpoint for S3 is free. It creates a route table entry that sends S3 traffic directly to S3, bypassing the NAT Gateway completely. Cost Savings: 100%.

Part 3: Service Mesh vs. No Service Mesh

Does Istio save money or cost money?

The Cost: Istio injects a sidecar proxy (Envoy) into every pod. That proxy consumes CPU and RAM. For a cluster with 5,000 pods, the "Istio Tax" on compute is massive.

The Savings: Istio has advanced "Locality Load Balancing" that is smarter than standard Kubernetes. It can strictly enforce Zone-Local routing. Verdict: For high-traffic clusters, the bandwidth savings outweigh the CPU cost. For low-traffic clusters, Istio is bloat.

Part 4: Monitoring with Kubecost

You cannot fix what you cannot measure. Kubecost is the industry standard. It breaks down the AWS bill by Namespace.

It can tell you: "Team A (Checkout Service) spent $400 on Cross-AZ traffic." "Team B (Search Service) spent $2,000 on NAT Gateway processing."

This enables Chargeback. When teams see the bill, they fix the code.

Part 5: CNI Deep Dive (Cilium vs. Calico)

Your networking costs and performance depend heavily on your CNI (Container Network Interface).

5-Minute Network Audit Checklist:

  • [ ] MTU Check: Are your nodes (1500) and Pods (1450) mismatched? (Common cause of packet drops).

  • [ ] DNS Latency: Is nslookup taking >5ms? (Check CoreDNS HPA).

  • [ ] Conntrack Table: Are you close to the Linux kernel limit? (Check dmesg for drops).

  • [ ] Cross-Zone Traffic: Are you paying for High Availability you don't need? (Use Topology Aware Routing).

Pro Tip: Always run tcpdump on both the source and destination pod simultaneously. If you see the packet leave but not arrive, your CNI provider (AWS VPC CNI / Cilium) is likely dropping it due to a security group or firewall rule.

1. AWS VPC CNI (The Default) Pros: Performance. Pods get real VPC IP addresses. No overlay overhead. Cons: IP exhaustion. Each Pod burns an IP from your subnet. If your subnet is /24 (254 IPs), you can only run ~250 pods.

2. Calico (The Standard) Pros: Network Policies. You can say "Frontend cannot talk to DB." Cons: Uses IPIP encapsulation (Tunneling). Adds CPU overhead and slight latency.

3. Cilium (The Future) Pros: eBPF. It bypasses iptables entirely. Extremely fast scaling. Incredible observability (Hubble UI). Cons: Complex to manage. Kernel dependency.

Part 6: Debugging Network Latency with eBPF

When a user says "The API is slow," how do you know if it's the code or the network?

Old Way: tcpdump. Painful. You have to SSH into the node. New Way: Cilium Hubble.

Bash

# View flow logs for a specific pod
hubble observe --pod my-pod --verdict DROPPED

# See DNS latency
hubble observe --pod my-pod --protocol dns

Hubble draws a "Service Map" automatically. It shows you: "Service A -> Service B (50ms latency, 1% packet loss)." It is like X-Ray vision for packets.

Appendix A: The Network Cost Glossary

  • AZ (Availability Zone): A physical data center within a region. (e.g., us-east-1a).

  • Cross-AZ Data Transfer: The fee AWS charges for moving data between AZs ($0.01 in + $0.01 out = $0.02). This typically accounts for 30-40% of a K8s bill.

  • Egress: Traffic leaving AWS to the internet. Expensive ($0.09/GB).

  • Ingress: Traffic entering AWS. Usually free.

  • NAT Gateway: A managed router allowing private instances to access the internet. Costs $0.045/hr + $0.045/GB. Avoid sending S3 traffic through this at all costs.

  • VPC Endpoint: A private connection to AWS services (S3, DynamoDB) keeping traffic internal. Saves 100% of NAT costs.

  • Topology Aware Hints: A K8s feature that tells the Kube-Proxy to prefer routing traffic to pods in the same zone as the caller.

Appendix B: Frequently Asked Questions

Q: Should I use a Service Mesh (Istio)? A: Only if you have >20 microservices. Below that, the complexity (YAML hell) outweighs the benefits. You can do basic mTLS and traffic splitting with simpler tools now (like Linkerd or Gateway API).

Q: How do I calculate my Cross-AZ cost? A: Use Kubecost or OpenCost. They will scrape the metric container_network_transmit_bytes_total and multiply it by the AWS list price.

Conclusion

Cloud costs are not just about "Shutting down unused servers." The real money is in the invisible pipes.

In 2025, the best Kubernetes Engineer is not the one who knows the most kubectl commands. It is the one who understands specific AWS pricing tables. If you can change 3 lines of YAML (Topology Hints) and save $50k/year, you are bulletproof.

Appendix C: Case Study (FinTech Migration)

The Context: A large payment processor moved from EC2 to EKS. Their bill exploded. The Investigation: They realized their Kafka cluster was in us-east-1a and their App cluster was in us-east-1b. Every single transaction was crossing a zone. The Fix: They implemented "Zone Affinity." They deployed a Kafka broker in every zone. They configured the Apps to consume only from the local broker. The Result: $20,000/month savings. Latency dropped by 1.5ms. Reliability increased.

Appendix D: Expert Interview (Network Engineer)

Q: Why is Kubernetes networking so hard? A: Because it tries to hide the network. It gives you a "Service IP" that doesn't exist. It uses iptables magic. Abstractions leak. When it breaks, you have to understand the magic.

Q: Is eBPF worth the hype? A: Yes. iptables was written in 1998. It was never designed for 5,000 containers appearing and disappearing every minute. eBPF is the only way to scale K8s networking without burning 30% of your CPU on packet routing.

Appendix E: The 5-Minute Network Audit Checklist

  • [ ] Topology Hints: Are service.kubernetes.io/topology-mode: Auto annotations present on all internal services?

  • [ ] NAT Gateway: Is S3 traffic bypassing the NAT via Gateway Endpoints? Check aws ec2 describe-vpc-endpoints.

  • [ ] Cross-AZ Traffic: Is my DaemonSet logging agent sending logs to a local Fluentd aggregator or a cross-zone one?

  • [ ] External Traffic: Am I using a Load Balancer for internal tools, or can I use kubectl port-forward and save $20/month?

  • [ ] DNS: Is ndots configuration optimized in resolv.conf to prevent excessive DNS lookups?

See, Understand, Optimize -
All in One Place

Atler Pilot decodes your cloud spend story by bringing monitoring, automation, and intelligent insights together for faster and better cloud operations.