Custom Label Selectors
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:
Add labels to Elastigroup based on imported ASG from an existing KOPS. Imported from an existing KOPS implementation:
- Identify the InstanceGroup name originally imported into Spotinst (“nodes” in the following example)
kops edit ig nodesand 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):
- Recognize the IG name you originally created (“nodes” in the following example)
kops edit ig nodesand add the relevant label
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 down. Elastigroup looks for other eligible 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:
kubernetes.io/hostname failure-domain.beta.kubernetes.io/zone failure-domain.beta.kubernetes.io/region beta.kubernetes.io/instance-type
You can also use Spotinst labels, please review here.