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
EKS | AKS | GKE | KOPS |
---|---|---|---|
+ | + | + | - |
Main attributes
Attribute | Description |
---|---|
Template name | Used 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 link | By 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 |
Lifecycle | Used 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 Optimization | Pre-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 throughput & IOPS (local flash storage) |
Apply Instance constraints | Apply other additional constraints on instances to be selected, such as: - Instance Family - Min/Max CPU - Min/Max Memory |
Processor architecture | Use nodes with x86_64 or ARM processors, or both. ARM nodes supported only on EKS clusters |
Create a Node Template
-
You have the following options to create node templates:
- Create Node Template through the API
- Create Node Template through the UI ( Cluster --> Autoscaler --> Node Templates )
- Terraform
-
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
shouldTaint
flagWhile 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
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
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
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
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 multiple custom labels in nodeSelector
nodeSelector
In case you have a node template with multiple custom labels custom-label-key-1=custom-label-value-1
and custom-label-key-2=custom-label-value-2
. You can schedule your pods on a node created using that node template by providing nodeSelector
with all the custom labels as described below:
apiVersion: v1
kind: Pod
metadata:
name: busybox-sleep
spec:
nodeSelector:
custom-label-key-1: custom-label-value-1
custom-label-key-2: custom-label-value-2
containers:
- name: busybox
image: busybox:1.28
args:
- sleep
- "1200"
Using nodeAffinity
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
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 labels in nodeAffinity
nodeAffinity
In case you have a node template with multiple custom labels custom-label-key-1=custom-label-value-1
and custom-label-key-2=custom-label-value-2
. You can schedule your pods on a node created using that node template by providing nodeAffinity
with all the custom labels as described below:
apiVersion: v1
kind: Pod
metadata:
name: busybox-sleep
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: custom-label-key-1
operator: In
values:
- "custom-label-value-1"
- key: custom-label-key-2
operator: In
values:
- "custom-label-value-2"
containers:
- name: busybox
image: busybox:1.28
args:
- sleep
- "1200"
Updated 2 months ago