Deploying a workload on a cluster with compute nodes of different architectures requires attention and monitoring of your cluster. There might be further actions you need to take in order to successfully place pods in the nodes of your cluster.
For more information on node affinity, scheduling, taints and tolerations, see the following documentation:
Sample multi-architecture node workload deployments
Before you schedule workloads on a cluster with compute nodes of different architectures, consider the following use cases:
- Using node affinity to schedule workloads on a node
-
You can allow a workload to be scheduled on only a set of nodes with architectures supported by its images, you can set the spec.affinity.nodeAffinity
field in your pod’s template specification.
Example deployment with the nodeAffinity
set to certain architectures
apiVersion: apps/v1
kind: Deployment
metadata: # ...
spec:
# ...
template:
# ...
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values: (1)
- amd64
- arm64
1 |
Specify the supported architectures. Valid values include amd64 ,arm64 , or both values. |
- Tainting every node for a specific architecture
-
You can taint a node to avoid workloads that are not compatible with its architecture to be scheduled on that node. In the case where your cluster is using a MachineSet
object, you can add parameters to the .spec.template.spec.taints
field to avoid workloads being scheduled on nodes with non-supported architectures.
Example MachineSet
with a taint set
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
metadata: # ...
spec:
# ...
template:
# ...
spec:
# ...
taints:
- effect: NoSchedule
key: multi-arch.openshift.io/arch
value: arm64
You can also set a taint on a specific node by running the following command:
$ oc adm taint nodes <node-name> multi-arch.openshift.io/arch=arm64:NoSchedule
- Creating a default toleration
-
You can annotate a namespace so all of the workloads get the same default toleration by running the following command:
$ oc annotate namespace my-namespace \
'scheduler.alpha.kubernetes.io/defaultTolerations'='[{"operator": "Exists", "effect": "NoSchedule", "key": "multi-arch.openshift.io/arch"}]'
- Tolerating architecture taints in workloads
-
On a node with a defined taint, workloads will not be scheduled on that node. However, you can allow them to be scheduled by setting a toleration in the pod’s specification.
Example deployment with a toleration
apiVersion: apps/v1
kind: Deployment
metadata: # ...
spec:
# ...
template:
# ...
spec:
tolerations:
- key: "multi-arch.openshift.io/arch"
value: "arm64"
operator: "Equal"
effect: "NoSchedule"
This example deployment can also be allowed on nodes with the multi-arch.openshift.io/arch=arm64
taint specified.
- Using node affinity with taints and tolerations
-
When a scheduler computes the set of nodes to schedule a pod, tolerations can broaden the set while node affinity restricts the set. If you set a taint to the nodes of a specific architecture, the following example toleration is required for scheduling pods.
Example deployment with a node affinity and toleration set.
apiVersion: apps/v1
kind: Deployment
metadata: # ...
spec:
# ...
template:
# ...
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- amd64
- arm64
tolerations:
- key: "multi-arch.openshift.io/arch"
value: "arm64"
operator: "Equal"
effect: "NoSchedule"