fbpx

In this tutorial we will see how to use custom Labels with Ocean Launch Specifications.

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

e.g.:

#!/bin/bash
set -o xtrace
/etc/eks/bootstrap.sh 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