/aws-node-termination-handler

A Kubernetes DaemonSet to gracefully handle EC2 Spot Instance interruptions.

Primary LanguageShellApache License 2.0Apache-2.0

GitHub go.mod Go version License Go Report Card Build Status Docker Pulls

AWS Node Termination Handler

The AWS Node Termination Handler is an operational DaemonSet built to run on any Kubernetes cluster using AWS EC2 Spot Instances. When a user starts the termination handler, the handler watches the AWS instance metadata service for spot instance interruptions within a customer's account. If a termination notice is received for an instance that’s running on the cluster, the termination handler begins a multi-step cordon and drain process for the node.

You can run the termination handler on any Kubernetes cluster running on AWS, including clusters created with Amazon Elastic Kubernetes Service.

Getting Started

The termination handler consists of a ServiceAccount, ClusterRole, ClusterRoleBinding, and a DaemonSet. All four of these Kubernetes constructs are required for the termination handler to run properly.

You can create and run all of these at once on your own Kubernetes cluster by running the following command:

kubectl apply -k https://github.com/aws/aws-node-termination-handler/config/base?ref=master

By default, the aws-node-termination-handler will run on all of your nodes (on-demand and spot). If your spot instances are labeled, you can configure aws-node-termination-handler to only run on your labeled spot nodes. If you're using the tag lifecycle=Ec2Spot, you can run the following to apply our spot-node-selector overlay:

kubectl apply -k https://github.com/aws/aws-node-termination-handler/config/overlays/spot-node-selector?ref=master

If you're using a different key/value tag to label your spot nodes, you can write your own overlay to set a spot-node-selector while still receiving updates of the base kubernetes resource files. See our spot-node-selector overlay for an example.

For build instructions please consult BUILD.md.

Communication

  • Found a bug? Please open an issue.
  • Have a feature request? Please open an issue.
  • Want to contribute? Please submit a pull request.

Contributing

Contributions are welcome! Please read our guidelines and our Code of Conduct

License

This project is licensed under the Apache-2.0 License.