Introducing MCS’s Support For 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, the MCS Autoscaler considers the constraints and only launches capacity into Elastigroup when Pods that are waiting to be scheduled have the labels that match the labels defined on Elastigroup.
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 the following attribute to the
ig_spec.yaml in your user-data start-up script.
Add following attribute to your ig_spec.yaml in your user-data start-up script. nodeLabels: group: microservices kops.k8s.io/instancegroup: microservices
Built-in Node Labels Support
Spotinst also supports Built-in Node Labels in scale down. The controller 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
That’s it! The MCS autoscaler can now detect custom label constraints and scale based on the constraint requirements of the Pods waiting to be scheduled.