build: add architecture detection to CNI makefile target (#26877)

The 'cni' make target was hardcoded to download amd64 CNI plugins,
which prevented users on arm64/aarch64 systems from using this target.

This change adds automatic architecture detection that maps the
system architecture (from uname -m) to the appropriate CNI plugin
architecture:
- x86_64 -> amd64 (existing behavior)
- aarch64 -> arm64 (new support)

The implementation uses the existing THIS_ARCH variable already
defined in the Makefile, ensuring consistency with other build
targets.

Fixes #26864
This commit is contained in:
Chase Naples
2025-10-03 04:47:49 -04:00
committed by GitHub
parent c7233854b9
commit 2d6629b9dc

View File

@@ -477,6 +477,8 @@ copywriteheaders:
.PHONY: cni
cni: ## Install CNI plugins. Run this as root.
@# Detect architecture: x86_64 -> amd64, aarch64 -> arm64
$(eval CNI_ARCH := $(shell if [ "$(THIS_ARCH)" = "aarch64" ]; then echo "arm64"; else echo "amd64"; fi))
mkdir -p /opt/cni/bin
curl --fail -LsO "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz"
tar -C /opt/cni/bin -xf cni-plugins-linux-amd64-v1.3.0.tgz
curl --fail -LsO "https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-$(CNI_ARCH)-v1.3.0.tgz"
tar -C /opt/cni/bin -xf cni-plugins-linux-$(CNI_ARCH)-v1.3.0.tgz