These instructions were originally for my testing of aws/aws-node-termination-handler#669, but I'm putting them here for general reference in the future.
- Create an EKS cluster with a managed node group using
eksctl
eksctl create cluster --name nthCluster --region us-east-2
- Create an SQS queue and EventBridge rules using the CloudFormation template in this repo
- Modify the nodegroup IAM role (name similar to
eksctl-*-nodegroup-ng-1-NodeInstanceRole-*
) to add the following inline policy (or use theAmazonSQSFullAccess
managed policy):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "*"
}
]
}
- Install NTH v1.17.0 into the cluster in Queue Processor mode
curl -L https://github.com/aws/aws-node-termination-handler/releases/download/v1.17.0/all-resources-queue-processor.yaml -o nth.yaml
# Open the YAML file and update QUEUE_URL value
kubectl apply -f ./nth.yaml
- (optional) Install Metrics Server into the cluster
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
kubectl top pod <pod_name>
- Launch an EC2 instance:
simple-ec2 launch --capacity-type spot --tags aws-node-termination-handler/managed=
- Send that instance a Spot ITN:
ec2-spot-interrupter --interactive
- Verify that NTH receives the message from the queue
- Build NTH locally with these changes
make build-docker-images
- Push that container to an ECR repo you own
docker tag amazon/aws-node-termination-handler:<TAG_OF_LATEST_BUILD> <ECR_REPO_URL>:<TAG_OF_LATEST_BUILD>
docker push <ECR_REPO_URL>:<TAG_OF_LATEST_BUILD>
- Install that version of NTH into the EKS cluster
cp nth.yaml nth-my-build.yaml
# Edit nth-my-build.yaml to point to the ECR image we just pushed
kubectl apply -f ./nth-my-build.yaml