Containers
Maximize Amazon EKS efficiency: How Auto Mode, Graviton, and Spot work together
Amazon Elastic Kubernetes Service (Amazon EKS) Auto Mode streamlines the operation of your Amazon EKS clusters by automating key infrastructure components. This automation streamlines various operational tasks, allowing for more efficient resource allocation and management. By reducing the manual effort required to maintain the infrastructure, Amazon EKS Auto Mode enables teams to focus on higher-level strategic initiatives and application development.
While our previous blog covered the core concepts of Amazon EKS Auto Mode, this blog post dives deeper into optimizing Amazon EKS Auto Mode clusters using AWS Graviton and Amazon EC2 Spot instances. AWS customers adopt AWS Graviton instances to achieve up to 40% higher price-performance ratio and up to 60% less energy to meet their sustainability goals. Additionally, AWS customers use Amazon EC2 Spot instances for eligible workloads to save up to 90% on Amazon Elastic Compute Cloud (Amazon EC2) On-Demand costs.
Solution overview
We will cover AWS Graviton and Amazon EC2 Spot implementations on Amazon EKS Auto Mode through the following two scenarios:
- Deploy the retail store application (referenced in the previous blog) using exclusively AWS Graviton (ARM64) instances.
- Deploy the retail store application using a mix of Spot and On-Demand Amazon EC2 instances with the following considerations:
- Self-managed MySQL, a stateful application using persistent volumes, must run on On-Demand instances as it’s not suitable for Spot instances. While running a Relational Database Management System (RDBMS) in Kubernetes is not recommended, we’re using it here solely to demonstrate a stateful workload example.
- All other applications in the retail store application are eligible to run on Amazon EC2 Spot instances.
- All the applications in the retail store application can run on AMD64, ARM64, or a mix of both architectures.
Getting started
Follow these steps sequentially from the previous blog:
- Complete prerequisites
- Create cluster
- Deploy Ingress Class by applying
ingress.yaml(ALB Ingress for the retail store app) - Deploy EBS Storage Class by applying
ebs-sc.yaml(Persistent Volume claim for the self-managed MySQL RDBMS)
Steps for scenario 1: Adopting AWS Graviton instances:
- Create custom NodePool: After completing the “Common Steps” section, create a custom NodePool named
graviton-ondemandin your Amazon EKS Auto Mode cluster. While the predefinedsystemNodePool supports ARM64 architecture and could theoretically be used (with tolerations to the taints) to deploy applications on AWS Graviton based Amazon EC2 instances, this approach is not recommended. Instead, follow these best practices:- Reserve the
systemNodePool exclusively for:- Critical cluster add-ons
- System-level components
- Core infrastructure services
- Create dedicated NodePools for:
- Specific architecture requirements (like AWS Graviton’s ARM64)
- Different performance or scaling needs
- Prioritize Savings Plans and/or Reserved Instances
- This separation helps maintain:
- Clear operational boundaries
- Better resource allocation
- Improved capacity availability
- Easier maintenance and troubleshooting
- Reserve the
The graviton-ondemand NodePool will provide a dedicated environment for your exclusive ARM64-based workloads.
Two important attributes of the above NodePool that differentiate it from the general-purpose NodePool created during cluster provisioning are:
- ARM64 is the only supported architecture in this NodePool:
- This NodePool has a weight of 10, whereas the
general-purposeandsystemNodePools provisioned during Amazon EKS Auto mode cluster creation had zero weight. This higher weight gives this NodePool priority over thegeneral-purposeandsystemNodePools.
- Deploy the retail store application using Helm. Create the
values.yamlfile to define the customization parameters for your Helm chart and execute the helm install command to deploy the application to your Amazon EKS cluster:
Create this values.yaml:
Execute Helm install command to deploy the application in Amazon EKS cluster:
Wait a few minutes until all pods reach Running status:
Get the LoadBalancer URL:
Access the application using the URL: http://[result-from-above-command]/
Verify that all worker nodes are AWS Graviton instances:
Reset Amazon EKS Auto Mode cluster before proceeding to scenario 2
Execute the below commands sequentially to delete the retail-store-app suite and remove the PVCs (Persistent Volume Claims) associated with the stateful sets, which will also delete the underlying Amazon Elastic Block Store (Amazon EBS) volumes. This returns the Amazon EKS Auto Mode cluster to its original state before proceeding to scenario 2.
Before proceeding to scenario 2, let’s recap what we accomplished in scenario 1.
We created a new node pool exclusively for AWS Graviton (ARM64) and assigned it a weight of 10. This will make sure that any eligible workloads deployed in this Amazon EKS cluster will prioritize AWS Graviton instances first for better price-performance. If a suitable AWS Graviton node cannot be found, the workload will fall back to the x86_64 options defined in the default “general-purpose” node pool.
Steps for scenario 2: Adopting spot instances and handling workload restrictions:
Create a custom node pool named spot in the Amazon EKS Auto Mode cluster.
Key features of this NodePool:
- Spot Pricing Options Support:
- Multi-Architecture Support:
- Priority Weighting: The NodePool has a weight of 20, giving it priority over the “general-purpose” (0 weight), “system”(0 weight), and “graviton-ondemand”(10 weight) NodePools .
- Deploy the retail store app using Helm. Create the
values.yamlfile to define the customization parameters for your Helm, and then execute the helm install command to deploy the application to your Amazon EKS cluster.
Create the values_spot.yaml creation with customization parameters.
Execute the Helm install command to deploy the application to Amazon EKS.
Key configuration aspects:
We will look into the key configuration aspects in the values_spot.yaml .
- MySQL Workload Restriction: Restricts stateful MySQL workloads to “on-demand” instances only:
Verification steps:
Confirm that everything is in Running state. This step takes a couple of minutes.
Get the LoadBalancer URL: kubectl get ingress retail-store-app-ui -o jsonpath="{.status.loadBalancer.ingress[*].hostname}"
Access the application using the URL: http://[result-from-above-command]/
Verify the node configuration.
Verifying workload placement
- MySQL stateful application verification: Verify that the MySQL stateful application is running on “on-demand” capacity type as specified in
values_spot.yaml:
- UI application distribution: You may notice that the UI application pods are distributed across mixed architectures (AMD64 andARM64) and capacity types (on-demand and spot). Unlike Amazon DynamoDB Local or MySQL, UI pods have no specific restrictions, demonstrating how Amazon EKS Auto Mode efficiently bin-packs pods across available nodes according to scheduling rules:
Note: If you don’t see UI pods having the OS architecture diversification, try to increase the number of pods with the below command:
kubectl scale deployments.apps retail-store-app-ui --replicas 70
This step still doesn’t guarantee that you will get a mixed architecture. Amazon EKS Auto Mode always provisions cost-efficient nodes based on your node pool configuration.
In scenario 2, we created a node pool exclusively for Amazon EC2 Spot instances that supports both AMD64 and ARM64 CPU architectures. We assigned it a weight of 20, to make sure that stateless workloads are first scheduled on worker nodes using Spot pricing. Only when Spot capacity is unavailable do workloads fall back to the ‘graviton-ondemand’ node pool, followed by the ‘general-purpose’ node pool.
Cleaning up
To avoid incurring future charges run the below steps sequentially to clean up the resources that were used for this blog post:
Conclusion
Although AWS Graviton Compute and Spot pricing options are not the default choices defined in the “general-purpose” NodePool, customers can seamlessly add their own Custom NodePool by using one of the strategies outlined in this blog. By incorporating AWS Graviton and Amazon EC2 Spot, customers can achieve improved compute efficiency and cost optimization. Additionally, Amazon EKS Auto Mode has a built-in Spot Interruption handler and node consolidation mechanism to further enhance these optimizations.
For more information on Amazon EKS Auto Mode capabilities, visit the Amazon EKS documentation.
About the authors
Muru Bhaskaran is a Senior Solutions Architect at AWS, specializing in Graviton adoption and migration strategies. He partners with customers to achieve maximum compute optimization, delivering enhanced performance and cost savings through ARM64-based EC2 instances. A dedicated expert in EC2, EC2 Spot Instances, Amazon EKS, EKS Auto Mode, and Karpenter, Muru guides customers in harnessing these powerful AWS technologies to run their containerized workloads with greater efficiency and scale.
Zakiya Randall is a Senior Technical Account Manager at AWS and she helps customers optimize their cloud infrastructure. She specializes in containers, observability, and modernization. Outside of work, she loves to play golf and visit museums.