
Taming the Beast: How We Engineered a Bulletproof EKS Cluster with Zero Downtime and Max Cost Efficiency
Running Amazon Elastic Kubernetes Service (EKS) in production is a double-edged sword. On one hand, you get the resilience and elasticity of Kubernetes backed by AWS control plane reliability. On the other hand, Day-2 operations can quickly become a nightmare of creeping AWS bills, unexpected pod evictions during node rollouts, and subtle networking bottlenecks.
Running Amazon Elastic Kubernetes Service (EKS) in production is a double-edged sword. On one hand, you get the resilience and elasticity of Kubernetes backed by AWS control plane reliability. On the other hand, Day-2 operations can quickly become a nightmare of creeping AWS bills, unexpected pod evictions during node rollouts, and subtle networking bottlenecks.
Over the past few years of running mission-critical workloads on EKS, we transformed our infrastructure from a high-maintenance cash-sink into a self-healing, cost-optimized engine.
Here is the exact blueprint we used to achieve 99.99% availability, zero-downtime rolling upgrades, and a 45% reduction in compute costs.
Compute Optimization: Ditching Cluster Autoscaler for Karpenter
If you are still using the standard Kubernetes Cluster Autoscaler with AWS Auto Scaling Groups (ASGs), you are leaving money and speed on the table. ASGs are fundamentally unaware of complex Kubernetes scheduling constraints, leading to slow provisioning times (often 3–5 minutes) and bin-packing inefficiencies.
We migrated entirely to Karpenter, the open-source, high-performance node provisioner built for Kubernetes.
Why Karpenter Changed the Game
- No ASGs required: Karpenter talks directly to the EC2 API to launch right-sized capacity in seconds (~30–45s).
- Consolidation (Bin-Packing): Karpenter actively moves workloads off underutilized nodes and terminates empty or inefficient instances.
- Smart Spot/On-Demand Blending: Instead of static nodegroups, Karpenter evaluates multiple instance types on the fly.
Production NodePool Configuration
Here is an example of our production
NodePool manifest that dynamically balances reliability and Spot cost savings:apiVersion: karpenter.sh/v1kind: NodePoolmetadata: name: general-computespec: template: spec: requirements: - key: kubernetes.io/arch operator: In values: ["amd64", "arm64"] # Enables Graviton savings - key: karpenter.sh/capacity-type operator: In values: ["spot", "on-demand"] - key: karpenter.k8s.aws/instance-category operator: In values: ["c", "m", "r"] - key: karpenter.k8s.aws/instance-generation operator: In values: ["5", "6", "7"] nodeClassRef: group: karpenter.k8s.aws kind: EC2NodeClass name: default disruption: consolidationPolicy: WhenEmptyOrUnderutilized consolidateAfter: 1mZero-Downtime Deployments: Taming the Rollout
Achieving true zero downtime during deployments or node drains isn't just about setting replicas: 3. It requires tightly controlling the lifecycle of a pod from initialization to termination.
A. Perfecting Pod Disruption Budgets (PDBs)
Never run production deployments without a PDB. This guarantees that Karpenter or EKS node upgrades will never evict too many pods simultaneously.
apiVersion: policy/v1kind: PodDisruptionBudgetmetadata: name: core-service-pdbspec: minAvailable: 80% selector: matchLabels: app: core-serviceGraceful Shutdown & PreStop Hooks
When an EC2 node is reclaimed or drained, Kubernetes sends a SIGTERM signal to your container. However, if your application shuts down immediately, the AWS Load Balancer Controller might still route incoming traffic to that pod before the endpoint slice updates propagate.
To prevent dropped connections (502/504 errors), configure a preStop hook to delay container exit while the ingress updates:
spec: containers: - name: app image: my-app:v1.2.0 lifecycle: preStop: exec: command: ["/bin/sh", "-c", "sleep 15"] terminationGracePeriodSeconds: 45Ingress & Traffic Management: NGINX + AWS NLB
For traffic routing, we paired the AWS Load Balancer Controller (provisioning an AWS Network Load Balancer in IP mode) with an NGINX Ingress Controller inside the cluster.
Why IP Mode?
By setting the target type to
ip , the AWS NLB routes traffic directly to the pod IP instead of hitting an EC2 NodePort first. This eliminates an unnecessary extra hop inside the cluster network and improves latency distribution.apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: main-ingress annotations: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]'spec: ingressClassName: nginx # ... rules ...Key Takeaways Checklist
If you are auditing your production EKS cluster today, implement these 5 high-impact changes first:
- Adopt Karpenter and diversify your instance families to leverage Spot instances safely.
- Set Pod Anti-Affinity across Availability Zones so a single AZ outage doesn't take down your service.
- Configure Readiness/Liveness Probes properly—never point a liveness probe to a heavy database endpoint.
- Implement
preStophooks on web servers to absorb inflight requests during node drains.
- Right-size resource requests (
requestsvslimits) using tools like Goldilocks or KubeCost to prevent CPU throttling while eliminating node waste.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article