How to deploy both x86 and ARM images in Kubernetes
In a multi-architecture computing environment, where both x86 and ARM architectures are used, deploying applications in a Kubernetes cluster can present challenges. However, Kubernetes provides several mechanisms to manage architectural diversity effectively. Two of the most common approaches are using multi-arch images and architecture-specific deployments.
What is ARM architecture, and why is it different from x86?
- ARM architecture is commonly used in devices like Raspberry Pi, IoT devices, and recent Cost-Optimized Instances based on ARM.
- Kubernetes clusters may consist of nodes with different architectures, including x86 and ARM.
- Deploying applications across these diverse architectures requires special consideration.
For a detailed comparison between ARM and x86 architectures, refer to our dedicated documentation Understanding the differences between ARM and x86 Instances.
Using multi-arch images
The most common approach to using ARM and x86 architecture Instances in a Kubernetes cluster is multi-arch images. These images contain binaries for multiple architectures, allowing Kubernetes to pull the appropriate binaries for each node.
How to deploy multi-arch images
- Build multi-arch images. Docker supports multi-arch builds using
buildx
. - Push the built images to a container registry accessible by your Kubernetes cluster. For example, you can use the Scaleway Container Registry.
- Specify node selectors and affinity. Use either node selectors and affinity rules to ensure pods are scheduled on nodes with compatible architectures.
Example
Below, you can find an example of a pod configuration with affinity set to target the kubernetes.io/arch=arm64
label, which is present by default on Scaleway ARM nodes:
apiVersion: v1
kind: Pod
metadata:
name: example-pod-with-affinity
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- arm64
containers:
- name: my-container
image: my-image:latest
# Add more container configurations as needed
In this example, the pod's affinity is configured to be scheduled on nodes that have the label kubernetes.io/arch
with the value arm64
.
This ensures that the pod will only be scheduled on nodes with this architecture.
Using architecture-specific deployments
You can also use architecture-specific deployments as an alternative, if multi-arch images are not available.
How to deploy architecture-specific images
- Start by determining the architecture of each node in the Kubernetes cluster.
- Build architecture-specific images by creating separate images for each architecture (x86 and ARM).
- Assign labels to images with the corresponding architecture name.
- Deploy with architecture-specific manifests for each architecture.