Custom Label Selectors

Labels are key/value pairs that are attached to objects, such as pods. Labels allow constraining a pod to only be able to run on particular nodes or have a preference for a particular node. See the Kubernetes documentation here for more.

Spotinst supports custom label selectors, as well as built-in node labels and affinity/anti-affinity for pods & nodes. Once configured, Elastigroup considers the constraints and launches capacity only when Pods that have the predefined labels are waiting to be scheduled.


Configuring Custom Label Selectors

Step 1:  Label the Pods

Make sure that your Pods are labeled properly. See the Kubernetes documentation.

Step 2: Define the Custom Labels in Elastigroup

In the Spotinst Console add the relevant labels with key/value in Compute tab -> Integrations -> Labels:

Step 3: Add Labels to the Nodes

Add Labels to EKS:

Add to user data:

--kubelet-extra-args --node-labels=mykey=myvalue,mykey2=myvalue2

Add labels to Elastigroup based on imported ASG from an existing KOPS. Imported from an existing KOPS implementation:

  1. Identify the InstanceGroup name originally imported into Spotinst (“nodes” in the following example)
  2. Run kops edit ig nodes and add the relevant label:

3. Add the label to Elastigroup user data:

Add the following attribute to your ig_spec.yaml in your user-data start-up script

Add labels to Spotinst-KOPS (Elastigroup that were created by KOPS natively):

  1. Recognize the IG name you originally created (“nodes” in the following example)
  2. Run kops edit ig nodes and add the relevant label

       3. Perform kops update cluster

For all of the above, new nodes will be launched with new labels. If the new label required to be applied to all the nodes in the group immediately, a roll of the Elastigroup is required.

Built-in Node Labels Support

Spotinst also supports Built-in Node Labels. In Scale-Up, Elastigroup will launch eligible instances into the cluster to satisfy the built-in labels of the containers that are pending. Respectively, during scale-down Elastigroup will look for under-utilized instances in the cluster to accommodate the containers that run on the host that is scheduled for scale down.

The following built-in labels are supported:

You can also use Spotinst labels, please review here.