diff --git a/designs/interruption-handling.md b/designs/interruption-handling.md index a4e9f6ba6b10..33be4c55b392 100644 --- a/designs/interruption-handling.md +++ b/designs/interruption-handling.md @@ -29,15 +29,17 @@ There are two ways in-which Spot interruption notifications and Rebalance Recomm EC2 IMDS is an HTTP API that can only be locally accessed from an EC2 instance. ``` -`curl 169.254.169.254/latest/meta-data/spot/instance-action +# Termination Check +curl 169.254.169.254/latest/meta-data/spot/instance-action { "action": "terminate", "time": "2022-07-11T17:11:44Z" } -curl 169.254.169.254``/``latest``/``meta``-``data``/``events``/``recommendations``/``rebalance` -`{` -` ``"noticeTime"``:`` ``"2022-07-16T19:18:24Z"` +# Rebalance Check +curl 169.254.169.254/latest/meta-data/events/recommendations/rebalance +{ + "noticeTime": "2022-07-16T19:18:24Z" } ``` @@ -47,19 +49,19 @@ curl 169.254.169.254``/``latest``/``meta``-``data``/``events``/``recommendations EventBridge is an Event Bus service within AWS that allows users to set rules on events to capture and then target destinations for those events. Relevant targets for Spot interruption notifications include SQS, Lambda, and EC2-Terminate-Instance. ``` -`# Example spot interruption notification EventBridge rule` -`$ aws events put``-``rule \` -` ``--``name ``MyK8sSpotTermRule`` \` -` ``--``event``-``pattern ``"{\"source\": [\"aws.ec2\"],\"detail-type\": [\"EC2 Spot Instance Interruption\"]}"` - -`# Example rebalance recommendation EventBridge rule`` -$ aws events put-rule \ - --name MyK8sRebalanceRule \ - --event-pattern "{\"source\": [\"aws.ec2\"],\"detail-type\": [\"EC2 Instance Rebalance Recommendation\"]}" -`` ` -`# Example targeting an SQS queue` -`$ aws events put``-``targets ``--``rule ``MyK8sSpotTermRule`` \` -` ``--``targets ``"Id"``=``"1"``,``"Arn"``=``"arn:aws:sqs:us-east-1:123456789012:MyK8sTermQueue"`` ` +# Example spot interruption notification EventBridge rule +aws events put-rule \ + --name MyK8sSpotTermRule \ + --event-pattern "{\"source\": [\"aws.ec2\"],\"detail-type\": [\"EC2 Spot Instance Interruption\"]}" + +# Example rebalance recommendation EventBridge rule +aws events put-rule \ + --name MyK8sRebalanceRule \ + --event-pattern "{\"source\": [\"aws.ec2\"],\"detail-type\": [\"EC2 Instance Rebalance Recommendation\"]}" + +# Example targeting an SQS queue +aws events put-targets --rule MyK8sSpotTermRule \ + --targets "Id=1,Arn=arn:aws:sqs:us-east-1:123456789012:MyK8sTermQueue" ``` @@ -113,17 +115,17 @@ SQS exposes a VPC Endpoint which will fulfill the isolated VPC use-case. Dynamically creating the SQS infrastructure and EventBridge rules means that Karpenter’s IAM role would need permissions to SQS and EventBridge: ``` -`"sqs:GetQueueUrl",` -`"sqs:ListQueues"``,` -`"sqs:ReceiveMessage"``,` -`"sqs:CreateQueue"``,` -`"sqs:DeleteMessage"``,` -`"events:ListRules",` -"`events:DescribeRule`", -"events:PutRule", +"sqs:GetQueueUrl", +"sqs:ListQueues", +"sqs:ReceiveMessage", +"sqs:CreateQueue", +"sqs:DeleteMessage", +"events:ListRules", +"events:DescribeRule", +"events:PutRule", "events:PutTargets", -"`events:DeleteRule`", -`"events:RemoveTargets"` +"events:DeleteRule", +"events:RemoveTargets" ``` The policy can be setup with a predefined name based on the cluster name. For example, `karpenter-events-${CLUSTER_NAME}` which would allow for a more constrained resource policy.