Code samples and manifests for the AWS Prescriptive Guidance guide on Amazon EKS cost optimization.
This repository contains Kubernetes YAML manifests, shell scripts, and configuration samples referenced in the APG guide. Each folder corresponds to a section of the guide:
| Folder | Section | Contents |
|---|---|---|
01-idle-cluster-cleanup/ |
Idle Cluster Decommissioning | Scripts to detect idle clusters via kubectl and CloudWatch |
02-application-cleanup/ |
Application Cleanup | Scripts to find stale namespaces and remove redundant workloads |
03-eks-control-plane-upgrade/ |
EKS Control Plane Upgrade | Version audit, cost estimation, pre-upgrade health checks |
04-karpenter-cost-optimization/ |
Karpenter Cost Optimization | (see 07 and 09 for Karpenter NodePool manifests) |
05-cluster-autoscaler-optimization/ |
Cluster Autoscaler Tuning | Scripts to verify and monitor autoscaler behavior |
06-cpu-memory-right-sizing/ |
CPU and Memory Right-Sizing | VPA and HPA manifests for recommendation and scaling |
07-graviton-instance-migration/ |
Graviton Instance Migration | Karpenter NodePool for ARM64, readiness detection |
08-vendor-custom-metrics-reduction/ |
Metrics Cost Reduction | ServiceMonitor with relabeling, Container Insights audit |
09-spark-jobs-optimization/ |
Spark Jobs Optimization | Spark NodePool, cost-optimized Spark config |
10-additional-strategies/ |
Additional Cost Savings | gp3 StorageClass, namespace quotas, off-hours scaling, topology routing |
- Amazon EKS clusters running Kubernetes 1.23+
- kubectl configured for your EKS cluster
- AWS CLI v2.x configured with appropriate permissions
- Karpenter v0.33+ (for NodePool manifests)
- Helm 3.x (for VPA and monitoring stack installation)
All .sh scripts accept cluster name as the first argument:
# Detect idle clusters
./01-idle-cluster-cleanup/detect-idle-clusters.sh
# CloudWatch-based detection
./01-idle-cluster-cleanup/detect-idle-clusters-cloudwatch.sh my-cluster 7
# Audit cluster versions
./03-eks-control-plane-upgrade/audit-cluster-versions.sh "us-east-1 us-west-2"Apply manifests with kubectl:
# Deploy VPA in recommendation mode
kubectl apply -f 06-cpu-memory-right-sizing/vpa-recommendation-mode.yaml
# Deploy cost-efficient HPA
kubectl apply -f 06-cpu-memory-right-sizing/hpa-efficient-scaling.yaml
# Create Graviton-preferred NodePool
kubectl apply -f 07-graviton-instance-migration/graviton-nodepool.yaml
# Create dedicated Spark NodePool
kubectl apply -f 09-spark-jobs-optimization/spark-nodepool.yamlSee CONTRIBUTING for reporting security issues.
This library is licensed under the MIT-0 License. See the LICENSE file.