1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 00:48:01 +01:00
Files
openshift-docs/modules/multi-architecture-scheduling-examples.adoc
2023-10-30 10:13:25 -04:00

139 lines
4.4 KiB
Plaintext

// Module included in the following assembly
//
//post_installation_configuration/configuring-multi-arch-compute-machines/multi-architecture-compute-managing.adoc
:_mod-docs-content-type: CONCEPT
[id="multi-architecture-scheduling-examples_{context}"]
= 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
[source,yaml]
----
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.
* Before you can taint a node, you must scale down the `MachineSet` object or remove available machines. You can scale down the machine set by using one of following commands:
+
[source,terminal]
----
$ oc scale --replicas=0 machineset <machineset> -n openshift-machine-api
----
+
Or:
+
[source,terminal]
----
$ oc edit machineset <machineset> -n openshift-machine-api
----
For more information on scaling machine sets, see "Modifying a compute machine set".
+
--
.Example `MachineSet` with a taint set
[source,yaml]
----
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:
[source,terminal]
----
$ 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:
+
[source,terminal]
----
$ 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
[source,yaml]
----
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.
[source,yaml]
----
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"
----