|
| 1 | +// Module included in the following assembly |
| 2 | +// |
| 3 | +//post_installation_configuration/configuring-multi-arch-compute-machines/multi-architecture-compute-managing.adoc |
| 4 | + |
| 5 | +:_content-type: CONCEPT |
| 6 | +[id="multi-architecture-scheduling-examples_{context}"] |
| 7 | + |
| 8 | += Sample multi-architecture node workload deployments |
| 9 | + |
| 10 | +Before you schedule workloads on a cluster with compute nodes of different architectures, consider the following use cases: |
| 11 | + |
| 12 | +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. |
| 13 | ++ |
| 14 | +.Example deployment with the `nodeAffinity` set to certain architectures |
| 15 | +[source,yaml] |
| 16 | +---- |
| 17 | +apiVersion: apps/v1 |
| 18 | +kind: Deployment |
| 19 | +metadata: # ... |
| 20 | +spec: |
| 21 | + # ... |
| 22 | + template: |
| 23 | + # ... |
| 24 | + spec: |
| 25 | + affinity: |
| 26 | + nodeAffinity: |
| 27 | + requiredDuringSchedulingIgnoredDuringExecution: |
| 28 | + nodeSelectorTerms: |
| 29 | + - matchExpressions: |
| 30 | + - key: kubernetes.io/arch |
| 31 | + operator: In |
| 32 | + values: <1> |
| 33 | + - amd64 |
| 34 | + - arm64 |
| 35 | +---- |
| 36 | +<1> Specify the supported architectures. Valid values include `amd64`,`arm64`, or both values. |
| 37 | + |
| 38 | +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. |
| 39 | + |
| 40 | +* 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: |
| 41 | ++ |
| 42 | +[source,terminal] |
| 43 | +---- |
| 44 | +$ oc scale --replicas=0 machineset <machineset> -n openshift-machine-api |
| 45 | +---- |
| 46 | ++ |
| 47 | +Or: |
| 48 | ++ |
| 49 | +[source,terminal] |
| 50 | +---- |
| 51 | +$ oc edit machineset <machineset> -n openshift-machine-api |
| 52 | +---- |
| 53 | +For more information on scaling machine sets, see "Modifying a compute machine set". |
| 54 | + |
| 55 | ++ |
| 56 | +-- |
| 57 | +.Example `MachineSet` with a taint set |
| 58 | +[source,yaml] |
| 59 | +---- |
| 60 | +apiVersion: machine.openshift.io/v1beta1 |
| 61 | +kind: MachineSet |
| 62 | +metadata: # ... |
| 63 | +spec: |
| 64 | + # ... |
| 65 | + template: |
| 66 | + # ... |
| 67 | + spec: |
| 68 | + # ... |
| 69 | + taints: |
| 70 | + - effect: NoSchedule |
| 71 | + key: multi-arch.openshift.io/arch |
| 72 | + value: arm64 |
| 73 | +---- |
| 74 | +You can also set a taint on a specific node by running the following command: |
| 75 | +[source,terminal] |
| 76 | +---- |
| 77 | +$ oc adm taint nodes <node-name> multi-arch.openshift.io/arch=arm64:NoSchedule |
| 78 | +---- |
| 79 | +-- |
| 80 | + |
| 81 | +Creating a default toleration:: You can annotate a namespace so all of the workloads get the same default toleration by running the following command: |
| 82 | ++ |
| 83 | +[source,terminal] |
| 84 | +---- |
| 85 | +$ oc annotate namespace my-namespace \ |
| 86 | + 'scheduler.alpha.kubernetes.io/defaultTolerations'='[{"operator": "Exists", "effect": "NoSchedule", "key": "multi-arch.openshift.io/arch"}]' |
| 87 | +---- |
| 88 | + |
| 89 | +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. |
| 90 | ++ |
| 91 | +.Example deployment with a toleration |
| 92 | +[source,yaml] |
| 93 | +---- |
| 94 | +apiVersion: apps/v1 |
| 95 | +kind: Deployment |
| 96 | +metadata: # ... |
| 97 | +spec: |
| 98 | + # ... |
| 99 | + template: |
| 100 | + # ... |
| 101 | + spec: |
| 102 | + tolerations: |
| 103 | + - key: "multi-arch.openshift.io/arch" |
| 104 | + value: "arm64" |
| 105 | + operator: "Equal" |
| 106 | + effect: "NoSchedule" |
| 107 | +---- |
| 108 | ++ |
| 109 | +This example deployment can also be allowed on nodes with the `multi-arch.openshift.io/arch=arm64` taint specified. |
| 110 | + |
| 111 | +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. |
| 112 | ++ |
| 113 | +.Example deployment with a node affinity and toleration set. |
| 114 | +[source,yaml] |
| 115 | +---- |
| 116 | +apiVersion: apps/v1 |
| 117 | +kind: Deployment |
| 118 | +metadata: # ... |
| 119 | +spec: |
| 120 | + # ... |
| 121 | + template: |
| 122 | + # ... |
| 123 | + spec: |
| 124 | + affinity: |
| 125 | + nodeAffinity: |
| 126 | + requiredDuringSchedulingIgnoredDuringExecution: |
| 127 | + nodeSelectorTerms: |
| 128 | + - matchExpressions: |
| 129 | + - key: kubernetes.io/arch |
| 130 | + operator: In |
| 131 | + values: |
| 132 | + - amd64 |
| 133 | + - arm64 |
| 134 | + tolerations: |
| 135 | + - key: "multi-arch.openshift.io/arch" |
| 136 | + value: "arm64" |
| 137 | + operator: "Equal" |
| 138 | + effect: "NoSchedule" |
| 139 | +---- |
0 commit comments