In this tutorial you will learn how to use custom Labels with Ocean Launch Specifications.


This tutorial is relevant for Kubernetes users.

Label Definition

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.

Ocean supports custom label selectors, as well as built-in node labels and affinity/anti-affinity for pods & nodes.

Once configured, Ocean 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 Ocean

In your Ocean cluster go to Actions > Launch Specifications > Add Launch Specification.

This will add a new Launch Specification to your Ocean Cluster:

Here you can add key / value of custom label and click on “Add”.

Step 3: Add labels to the nodes

Add Labels to EKS:

Add labels to the nodes by using the user data:

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


set -o xtrace
/etc/eks/ Ocean_Cluster --kubelet-extra-args --node-labels=mykey=myvalue,mykey2=myvalue2

For all of the above, new nodes will be launched with new labels.

Add labels to Spotinst-KOPS (Cluster 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

Built-in Node Label Support

Spot auto scaler also supports Built-in Node Labels, there is no need to explicitly add any launch specifications for built-in labels.  In Scale-Up, Ocean will launch eligible instances into the cluster to satisfy the built-in labels of the pods that are pending. Respectively, during the scale-down Ocean will look for under-utilized instances in the cluster to accommodate the pods that run on the host that is scheduled for scale down.

The following built-in labels are supported:

Note: Avoid adding Built-In labels under the Launch specification Node labels section, these labels need to be added just in your pod configuration.

You can also use Spot labels. Please review here.