k8s-spot-termination-handler

by joaquinito2051

Helm chartv1.2.1App 1.13.0-1

The K8s Spot Termination handler handles draining AWS Spot Instances in response to termination requests.

About this chart

Kubernetes AWS EC2 Spot Termination Notice Handler

This chart installs the k8s-spot-termination-handler as a daemonset across the cluster nodes.

Purpose

Spot instances on EC2 come with significant cost savings, but with the burden of instance being terminated if the market price goes higher than the maximum price you have configured.

The termination handler watches the AWS Metadata API for termination requests and starts draining the node so that it can be terminated safely. Optionally it can also send a message to a Slack channel informing that a termination notice has been received.

Installation

You should install into the kube-system namespace, but this is not a requirement. The following example assumes this has been chosen.

helm install <helm-repo>/k8s-spot-termination-handler --namespace kube-system

helm install stable/k8s-spot-termination-handler --namespace kube-system

Configuration

The following table lists the configurable parameters of the k8s-spot-termination-handler chart and their default values.

ParameterDescriptionDefault
image.repositorycontainer image repositorykubeaws/kube-spot-termination-notice-handler
image.tagcontainer image tag1.13.0-1
image.pullPolicycontainer image pull policyIfNotPresent
pollIntervalthe interval in seconds between attempts to poll EC2 metadata API for termination events"5"
slackUrlSlack webhook URL to send messages when a termination notice is receivednot defined
clusterNameif slackUrl is set - use this cluster name in Slack messagesnot defined
enableLogspoutif true, enable the Logspout log capturing. Logspout should be deployed separatelyfalse
rbac.createif true, create & use RBAC resourcestrue
serviceAccount.createif true, create a service accounttrue
serviceAccount.namethe name of the service account to use. If not set and create is true, a name is generated using the fullname template.``
detachAsgif true, the spot termination handler will detect (standard) AutoScaling Group, and initiate detach when termination notice is detected.false
gracePeriodGrace period for node draining120
resourcespod resource requests & limits{}
nodeSelectornode labels for pod assignment{}
tolerationsnode taints to tolerate (requires Kubernetes >=1.6)[]
affinitynode/pod affinities (requires Kubernetes >=1.6){}
priorityClassNamepod priorityClassName for pod.``

Deploy k8s-spot-termination-handler with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has k8s-spot-termination-handler on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartk8s-spot-termination-handler is pinned at v1.2.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply