Containers
Amazon EKS now supports Amazon Application Recovery Controller
Introduction
Amazon Elastic Kubernetes Service (Amazon EKS) now supports Amazon Application Recovery Controller (ARC). ARC is an AWS service that allows you to prepare for and recover from AWS Region or Availability Zone (AZ) impairments.
ARC provides two sets of capabilities: Multi-AZ recovery, which includes zonal shift and zonal autoshift, and multi-Region recovery, which includes routing control and readiness check. With this launch, we’ve extended the support for zonal shift and zonal autoshift capabilities to Amazon EKS, which were previously available only for AWS Application Load Balancers (ALBs) and Network Load Balancers (NLBs).
The ARC zonal shift and zonal autoshift capabilities achieve multi-AZ recovery for a supported AWS resource by shifting the ingress traffic away from an impaired AZ to other healthy AZs. When the shift ends, ARC adds back the previously impacted AZ so that it can again receive ingress traffic.
You can enable zonal shift for your EKS clusters using the Amazon EKS console, AWS Command Line Interface (AWS CLI), AWS CloudFormation, or eksctl. When enabled, you can use the ARC console, AWS CLI, or the Zonal Shift and Zonal Autoshift APIs to start a zonal shift or enable zonal autoshift for your EKS cluster.
To trigger a zonal shift on an EKS cluster, you must first select an AZ, then select the EKS cluster (version 1.28 or above) and specify an expiration time for the zonal shift to be in effect. Then, ARC initiates a zonal shift, which shifts the traffic away from the selected AZ. ARC ends the zonal shift when it expires or if you cancel it. When the zonal shift ends, traffic returns to all the healthy AZs attached to the EKS cluster.
When you enable zonal autoshift for an EKS cluster, you allow AWS to shift the traffic away on your behalf whenever ARC detects that an AZ is unhealthy. ARC uses internal telemetry to monitor critical health metrics from various sources, such as the AWS network, Amazon Elastic Compute Cloud (Amazon EC2), and Elastic Load Balancing (ELB) services. ARC ends the zonal autoshift when the telemetry indicates that the impacted AZ is healthy again. This returns traffic to all the healthy AZs attached to the EKS cluster.
Why should you use ARC zonal shift and zonal autoshift?
The AWS Global Cloud Infrastructure provides fault tolerance and resilience, with each AWS Region made up of multiple, fully isolated AZs. Leveraging this multi-AZ architecture is essential for implementing highly-available applications in a Region. Amazon EKS allows you to quickly develop highly-available applications by deploying them across multiple AZs, but addressing AZ impairments in a scalable, performant, and reliable manner requires implementing custom solutions that would take much effort to build and maintain.
Another challenge is testing for AZ impairment scenarios, which are often difficult to simulate. Insufficient testing can lead to unpredictable workload behavior when an AZ in your environment is unhealthy.
Using ARC zonal shift or zonal autoshift, you can temporarily isolate your cluster worker nodes and pods that are running in an impaired AZ and automatically shift in-cluster network traffic away from them to improve your workload’s fault tolerance and availability.
Furthermore, by using zonal shift and zonal autoshift capabilities, you can reduce your team’s operational overhead involved in planning and responding to AZ impairments.
How it works
When you’ve registered your EKS cluster as an ARC resource, you can use ARC to trigger a zonal shift for the cluster or alternatively enable zonal autoshift for the cluster. When ARC performs a zonal shift, the cluster undergoes the following changes:
- The nodes in the impacted AZ are cordoned to prevent the Kubernetes Scheduler from scheduling new pods onto the nodes in the unhealthy AZ. If you’re using managed node groups (MNG), AZ rebalancing is suspended, and your Auto Scaling Group (ASG) is updated to make sure that new Amazon EKS data plane nodes are only launched in the healthy AZs. Karpenter and Kubernetes Cluster Autoscaler don’t natively support ARC zonal shift and zonal autoshift. You must reconfigure your auto scaling tool to only provision new nodes in the healthy AZs. Refer to the Amazon EKS Best Practices Guide on how to configure Karpenter and Cluster Autoscaler to only use certain AZs for launching new nodes.
- Nodes in the unhealthy AZ aren’t terminated. Therefore, pods aren’t evicted in the impacted AZ. This is done to make sure of the safe return of your traffic to the AZ with full capacity when a zonal shift expires or is cancelled.
- The EndpointSlice controller finds the pod endpoints in the impaired AZ and removes them from the relevant EndpointSlice resources. This guarantees that network traffic only targets pod endpoints in healthy AZs. The endpoint slice controller updates the endpoint slice to include the endpoints in the restored AZ when a zonal shift cancels or expires.
The following diagram depicts an Amazon EKS environment with east-to-west traffic flow when an AZ is unhealthy. In such a scenario, there may be network packet drops or network latency.
The following diagram depicts an Amazon EKS environment when you shift traffic away from the impaired AZ.
Preparing your EKS cluster and workloads for zonal shift and zonal autoshift
To make sure that zonal shift and autoshift work successfully in Amazon EKS, you must prepare your cluster environment to be resilient to AZ impairment beforehand. The following is a list of important steps you have to implement for your EKS cluster. These steps are further detailed in the Amazon EKS documentation.
- Distribute the worker nodes in your cluster across multiple AZs.
- Provision sufficient compute capacity to withstand the removal of a single AZ. Refer to the AWS documentation on static stability for more information on how to build applications that can withstand AZ impairments.
- In every AZ, pre-scale your pods. These pods include your application pods and controller pods such as CoreDNS, Cluster Autoscaler, and AWS Load Balancer Controller. Refer to the Amazon EKS documentationfor more information on how this could be achieved.
- Spread pod replicas across the AZs to make sure that shifting away from a single AZ leaves you with sufficient capacity. Topology spread constraints can help you achieve this.
- If a leader election is necessary to support high availability (HA) for the controllers or any other application running in your clusters, then make sure that the criteria, such as having an odd number of pods or at least two pods, are consistently met during and after the AZ impairment event.
- When using load balancers to route external traffic to your Kubernetes services, we recommend using only ALB and NLB. We also recommend using AWS Load Balancer controller to manage the load balancers. AWS Load Balancer controller supports Instance and IP traffic modes, of which IP mode is recommended. Refer to the AWS Load Balancer controller documentation for more information on instances and IP modes.
The preceding steps are essential for your applications and cluster environment to recover successfully with a zonal shift in Amazon EKS. In addition, we recommend the following best practices to effectively manage AZ impairments.
- Limit pod-to-pod communications to be within the same AZ by using Kubernetes features such as Topology Aware Routing or integrating with a service mesh.
- In the same AZ, co-locate interdependent applications and services. You can achieve this with pod affinity rules.
- Implement Multi-AZ observability.
- For your applications, make sure that you properly configure timeout values for external dependencies such as databases, services, and implement retries. To gracefully handle failures, implement a circuit breaker with an exponential back off pattern.
Refer to the Amazon EKS documentation for more information on how to prepare your cluster and workloads to support zonal shift and zonal autoshift, and other best practices for zonal shift and zonal autoshift.
Furthermore, we strongly recommend regularly testing and validating that your workloads can handle AZ impairments. You can test for AZ impairment by manually triggering a zonal shift or by enabling zonal autoshift and verifying that your workloads are functioning as expected with one less AZ in your cluster environment.
Getting started
We have built an example application, which we are using to walk through the ARC Zonal shift capabilities. You can either use an existing EKS cluster or create a new cluster for this walkthrough. The cluster and node groups configured in the cluster should span across three AZs and have minimum of one node in each AZ.
1.Deploy the example application
a. Start by deploying the example application on the EKS cluster. Make sure that you provide a valid username and password when creating the Kubernetes secret. This secret is used by both the MySQL database and the application to connect to it.
b. Applying the Kubernetes manifest file to the cluster creates two applications named “catalog” and “catalog-mysql,” respectively, with “catalog-mysql” being a MySQL database. Verify that the pods are in a running state before proceeding to the next step (this may take few minutes).
2. Enable zonal shift for your cluster
a. Open the Amazon EKS console, select the cluster and go to the Zonal shift section under Overview, as shown in the following figure.
b. Choose ‘Manage’, then choose ‘Enabled’ and save changes.
3. Validate the application
a)List the available services in the default namespace.
b)Run kubectl port-forward to the catalog service in background mode. Note the process ID of the process.
c)Using curl, invoke the catalog service, and you should observe the service return a few item IDs as shown in the following.
4. Understand the cluster topology
As you have validated that the application is working fine, thus you are ready to perform a zonal shift. However, before you trigger a zonal shift, you must understand the cluster’s topology, which involves identifying the AZs where the pods are running.
a. List the Region’s AZ IDs. In this case, the Region is us-west-2, thus you could observe the AZ IDs for us-west-2.
b. You must identify each node in the cluster and the AZ in which it is operating, using the following commands. Entering the following commands should produce an output listing the node names and the AZs where the nodes are running. In this case, you have three nodes distributed across three AZs: us-west-2b, us-west-2b, and us-west-2c.
c. You must use the following commands to identify the nodes and AZs where each pod is currently running. Entering the commands should produce an output listing the pod name, the AZ, and the node where the pods are running. In this case, you have the catalog application pods, which are distributed across three nodes across three AZs.
5. Trigger a zonal shift
You should now have a good understanding of cluster topology. Next, you can trigger a zonal shift to move traffic away from an to test the Zonal shift capability.
a. Open ARC console and choose Zonal shift, as shown in the following figure.
- b. Initiate a zonal shift by selecting the AZ (us-west-2b) to shift traffic away from, the EKS cluster to perform the zonal shift for, an expiry time period (10 minutes), and then choose Start, as shown in the following figures.
Zonal shift takes a few minutes to complete after you trigger it. Therefore, it is advisable to wait a few minutes before testing.
c. Validate the application by generating traffic to the application endpoint and verifying no calls are made to the pods running in the AZ from which the traffic was shifted away. You can accomplish this by first running a Kubernetes job to generate traffic to the application and then identify from the logs the pods responsible for handling the traffic and the AZs to which they belong. Entering the following commands, you observe that the traffic to the catalog service is distributed across two pods.
d. If you check the locations of the pods, then you can observe that none of them are operating in AZ us-west-2b, the AZ from which the zonal shift diverted traffic.
e. Before proceeding, delete the Kubernetes job that you created for generating traffic.
6. Cancel a zonal shift
a. Test canceling the zonal shift by choosing a zonal shift that you previously created and choosing Cancel zonal shift, as shown in the following figures.
Cancelling a zonal shift takes a few minutes to complete after you trigger it. Therefore, it is advisable to wait a few minutes before testing.
b. You can generate traffic to the application and confirm that the pods operating in the AZs receive the traffic.
7. Configure zonal autoshift for the cluster.
a. Before you can configure zonal autoshift, you need to set up an Amazon CloudWatch alarm that ARC uses to verify if the practice runs have completed successfully. For more information on ARC zonal autoshift practice runs, refer to this documentation.
b. Open the ARC console and choose Configure zonal autoshift, as shown in the following figure.
c. Choose the EKS cluster as the resource to configure zonal autoshift, choose Enable for zonal autoshift status, provide a CloudWatch alarm ARN, and choose Create. Leave the optional sections in the console as is, as shown in the following figures.
d. ARC regularly performs a zonal autoshift one time per week as part of practice runs. You can integrate with Amazon EventBridge to receive notifications for zonal autoshift and practice runs. During the practice run, you can apply the same validation steps you used to validate the zonal shift for the zonal autoshift.
Zonal shift and autoshift enables you to quickly recover from AZ impairment and increase the reliability of your Amazon EKS workloads. To be truly resilient against AZ impairment, your workloads must not only use the zonal shift and autoshift capabilities but also recover from AZ impairment by adhering to the practices outlined in the Cluster and Workload Requirements section.
Cleaning Up
To avoid future costs, delete all resources, such as the EKS cluster, which were created for this exercise. The following command deletes the application that you installed earlier to test Zonal shift.
Pricing and availability
Amazon EKS support for ARC Zonal shift and autoshift capabilities is available in all AWS Regions, excluding China and GovCloud regions. Enabling zonal shift in your EKS clusters and triggering zonal shifts doesn’t incur any more costs. However, you may incur more costs to make sure that your workloads can handle AZ failures, such as pre-scaling your pods and cluster nodes.
Conclusion
In this post, we demonstrated how you can use the ARC zonal shift and zonal autoshift capabilities to recover from a single AZ impairment. With careful planning and implementation, you can harness the full potential of zonal shift and zonal autoshift to protect your applications and data sources running in Amazon EKS clusters with an impacted AZ.
Visit the Amazon EKS documentation to learn more about zonal shift and zonal autoshift in Amazon EKS.
By leaving a comment or opening an issue on the GitHub-hosted AWS Containers Roadmap, you can provide feedback on the ARC zonal shift capability for EKS clusters. Stay tuned as we continue to evolve our features and explore more methods to help our users improve their cluster resilience and availability.