Schedule workloads to ARM nodes

Updated at:

By default, Container Service for Kubernetes (ACK) schedules all workloads to x86 worker nodes. If your cluster has both ARM and non-ARM nodes, such as x86 nodes, use native Kubernetes scheduling configurations. These configurations run ARM-only workloads on ARM nodes and preferentially schedule multi-architecture images to ARM nodes.

Prerequisites

  • An ACK cluster that runs Kubernetes 1.20 or later is created, and the operating system of the cluster is Alibaba Cloud Linux 3. For more information, see Create a cluster and Upgrade clusters.

    Note
    • On the Add-ons page of the ACK console, only add-ons in the Core Components, Logs and Monitoring, Volumes, and Network categories are supported in ARM node pools.

    • Add-ons in the App Marketplace are not supported in ARM node pools.

  • The kube-scheduler add-on is installed. For more information, see Components.

Usage notes

If both ARM-based nodes and x86-based nodes exist in your cluster, we recommend that you add the kubernetes.io/arch=arm64:NoSchedule taint to ARM-based nodes. This avoids accidentally scheduling applications or components that do not support the ARM architecture to ARM-based nodes. When you configure nodeSelector or nodeAffinity to schedule applications to ARM-based nodes in an ACK cluster that runs a Kubernetes version earlier than 1.24, you need to add a toleration to tolerate the kubernetes.io/arch=arm64:NoSchedule taint. However, if the cluster runs Kubernetes 1.24 or later, the scheduler automatically tolerates the kubernetes.io/arch=arm64:NoSchedule taint. In this case, you do not need to add a toleration to tolerate the taint.

Billing

For more information about ARM-based ECS instance types and pricing, see:

Create an ARM cluster or node pool

Add ARM nodes when creating an ACK cluster to create a cluster that contains only ARM nodes, or create an ARM node pool in an existing cluster.

Add during cluster creation

During node pool configuration when you create a cluster, in the Instance Type section, set Architecture to Arm. Select the required instance type, configure other parameters as needed, and create the cluster. For more information about cluster creation settings, see Create an ACK managed cluster.

Note

Create a node pool

During node pool creation, in the Instance Type section, set Architecture to Arm. Select the required instance type, configure other parameters as needed, and create the node pool. For more information about node pool creation settings, see Create and manage node pools.

Note

Schedule ARM-only workloads to ARM nodes

If your cluster has both ARM and non-ARM nodes and your application supports only the ARM architecture, run the application on ARM nodes. Otherwise, its pods might be scheduled to non-ARM nodes and fail to start. All ARM nodes have the kubernetes.io/arch=arm64 label by default. Use either nodeSelector or nodeAffinity to deploy applications to ARM nodes.

nodeSelector

Add the following constraint to a pod and use nodeSelector to schedule the pod to ARM nodes. nodeSelector restricts this workload to nodes with the arm64 label. All ARM nodes in ACK clusters have this label.

nodeSelector:
  kubernetes.io/arch: arm64 # Specify an ARM node.

The following sample code deploys a stateless application to an ARM node.

View the YAML file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: only-arm
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      nodeSelector:
        kubernetes.io/arch: arm64 # Specify an ARM node.
      containers:
      - name: nginx
        image: nginx

nodeAffinity

Add the following constraint to a pod and use node affinity to deploy the application to ARM nodes. This constraint specifies that the pod can be scheduled only to nodes with the kubernetes.io/arch=arm64 label.

When a pod spec contains this constraint, the scheduler automatically tolerates the node taint kubernetes.io/arch=arm64:NoSchedule.

affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/arch
          operator: In
          values:
          - arm64

The following sample code deploys a stateless application to an ARM node.

View the YAML file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: only-arm
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/arch
                operator: In
                values:
                - arm64
      containers:
      - name: nginx
        image: nginx

Schedule multi-architecture images to ARM nodes

By default, an ACK cluster schedules all workloads to x86 nodes and keeps waiting for x86 node resources when those resources are insufficient. If your application image is a multi-architecture image that supports both x86 and ARM, configure node scheduling across x86 and ARM architectures.

For example, configure node affinity to preferentially schedule workloads to ARM or x86 nodes. If resources of the preferred node type are insufficient, the scheduler attempts to schedule the workloads to nodes of the other architecture.

      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: kubernetes.io/arch
                operator: In
                values:
                - arm64

Prefer ARM architecture

View the YAML file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: arm-prefer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
# Preferentially schedule the pod to ARM nodes.
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: kubernetes.io/arch
                operator: In
                values:
                - arm64
      containers:
      - name: my-container
        image: nginx

Prefer x86 architecture

View the YAML file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: amd-prefer
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      tolerations:
# Preferentially schedule the pod to x86 nodes.
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: kubernetes.io/arch
                operator: In
                values:
                - amd64
      containers:
      - name: my-container
        image: nginx

FAQ

Can I use ARM-based spot instances?

ARM-based spot instances are available. For instructions, see Use preemptible instances.

What are the limitations of using ARM nodes in ACK clusters?

For the ARM architecture, the Add-ons page of the ACK console supports only the following add-ons:

  • Core Components

  • Logs and Monitoring

  • Storage

  • Networking

Add-ons in the App Marketplace do not support ARM.

References