Node Templates

What is it?

Node Templates are part of the Autoscaler component. They allow you to define virtual buckets of constraints such as:

  • instance types to be used;
  • lifecycle of the nodes to add;
  • node provisioning configurations;
  • and other various properties.

CAST AI will respect all the above settings when creating nodes for your workloads to run on.

UI is available at CAST AI console and you can find it in: Cluster --> Autoscaler --> Node Templates

Feature availability

EKSAKSGKEKOPS
+++-

Main attributes

AttributeDescription
Template nameUsed for guiding pods to nodes. To schedule pods on the nodes created using the template, you will need to apply the nodeSelector or nodeAffinity (and toleration, if you selected the option to taint nodes).

By default, nodeSelector and nodeAffinity are constructed using the template name. However, you may choose to use a custom label to fit your use case better.
Node configuration linkBy default, node templates mostly focus on the type of resources that need to be scheduled. To learn how to configure the scheduling of your resources and how to use other kinds of attributes on provisioned nodes, see Node configuration
LifecycleUsed to indicate whether node templates will provision only spot or only on-demand nodes.

In the case of spot, on-demand fallback nodes will be created if there is not enough spot capacity available in the cloud.
Instance OptimizationPre-filter indicating the type of instances to use from the inventory:

- Compute Optimized - Instances designed to run applications that benefit from high-performance CPUs

- Storage Optimized - Instances designed to run applications that benefit from high IOPS.
Apply Instance constraintsApply other additional constraints on instances to be selected, such as:
- Instance Family
- Min/Max CPU
- Min/Max Memory

Create a Node Template

  • You have the following options to create node templates:

  • Sometimes, when you create a Node Template, you may want to associate it with custom node configurations to be used when provisioning nodes. You can achieve this by linking the template with Node configuration

Using the shouldTaint flag

While creating a Node Template, you can choose if the nodes created by the CAST AI Autoscaler should be tainted or not. This is controlled through shouldTaint property in the API payload.

🚧

When shouldTaint is set to false

Since no taints will be applied on the nodes created by CAST AI, any pods being deployed to the cluster, even the ones without nodeSelector, might get scheduled on these nodes. This effect might not always be desirable.

When shouldTaint is set to true

apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  nodeSelector:
    scheduling.cast.ai/node-template: memory-optimized
  tolerations:
    - key: scheduling.cast.ai/node-template
      value: memory-optimized
      operator: Equal
      effect: NoSchedule
  containers:
    - name: busybox
      image: busybox:1.28
      args:
        - sleep
        - "1200"

When shouldTaint is set to false

apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  nodeSelector:
    scheduling.cast.ai/node-template: memory-optimized
  containers:
    - name: busybox
      image: busybox:1.28
      args:
        - sleep
        - "1200"

Using nodeSelector

You can use nodeSelector to schedule pods on the nodes created using the template. By default, you construct nodeSelector using the template name. However, you may choose to use a custom label to fit your use case better.

Using a node template name in nodeSelector

apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  nodeSelector:
    scheduling.cast.ai/node-template: memory-optimized
  containers:
    - name: busybox
      image: busybox:1.28
      args:
        - sleep
        - "1200"

Using a node template's custom label in nodeSelector

Consider that you have a node template with a custom label custom-label-key=custom-label-value. You can schedule your pods on a node created using that node template by providing nodeSelector with a custom label as described below:

apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  nodeSelector:
    custom-label-key: custom-label-value
  containers:
    - name: busybox
      image: busybox:1.28
      args:
        - sleep
        - "1200"

Using nodeAffinity

You can use nodeAffinity to schedule pods on the nodes created using the template. By default, you construct nodeAffinity using the template name. However, you may choose to use a custom label to fit your use case better. The only supported nodeAffinity operator is In.

Using the node template name in nodeAffinity

apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
            - key: scheduling.cast.ai/node-template
              operator: In
              values:
                - "memory-optimized"
  containers:
    - name: busybox
      image: busybox:1.28
      args:
        - sleep
        - "1200"

Using a node template's custom label in nodeAffinity

Consider that you have a node template with a custom label custom-label-key=custom-label-value. You can schedule your pods on a node created using that node template by providing nodeAffinity with a custom label as described below:

apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
            - key: custom-label-key
              operator: In
              values:
                - "custom-label-value"
  containers:
    - name: busybox
      image: busybox:1.28
      args:
        - sleep
        - "1200"

What’s Next