fix(templates): runtime Kubernetes arch detection for arm64#663
Conversation
Pull Request Test Coverage Report for Build 21984708330Details
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This PR updates the Kubernetes provisioner templates to avoid hardcoding amd64 as the default architecture, instead emitting runtime architecture detection logic when spec.kubernetes.arch is not provided—improving support for arm64 environments.
Changes:
- Switched kubeadm (release/git/latest) templates from
ARCH="{{.Arch}}"to anif .Archbranch that otherwise detects arch at runtime viadpkg --print-architecturewith auname -mfallback mapping. - Updated
NewKubernetesdefaults/tests soArchis empty by default (meaning “detect at runtime”). - Added unit tests asserting the rendered templates include runtime detection when
Archis empty, and hardcode whenArchis explicitly set.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/provisioner/templates/kubernetes.go | Emits runtime arch detection in kubeadm template variants and stops defaulting Arch to amd64 in NewKubernetes. |
| pkg/provisioner/templates/kubernetes_test.go | Updates expectations for default Arch and adds coverage for the new template rendering behavior. |
| if env.Spec.Kubernetes.Arch != "" { | ||
| kubernetes.Arch = env.Spec.Kubernetes.Arch | ||
| } else { | ||
| kubernetes.Arch = "amd64" | ||
| } | ||
| // When Arch is empty, the template uses runtime detection |
There was a problem hiding this comment.
NewKubernetes now leaves kubernetes.Arch empty when the user doesn’t specify spec.kubernetes.arch. That works for the kubernetes.go kubeadm templates because they added runtime detection, but it breaks other kubeadm scripts that still render ARCH="{{.Arch}}" (e.g. KubeadmInitTemplate / KubeadmPrereqTemplate), producing ARCH="" and invalid download URLs like .../bin/linux//kubectl.
Suggested fix: apply the same runtime-detection logic in those other templates (preferred), or keep a non-empty default in NewKubernetes and only use runtime detection in templates that explicitly opt into it.
…ng to amd64 When the user doesn't explicitly set Kubernetes.Arch, use runtime detection (dpkg --print-architecture) instead of hardcoding "amd64". This ensures arm64 nodes download the correct architecture binaries for kubeadm, kubelet, kubectl, CNI plugins, and crictl. The user can still explicitly set Arch to override runtime detection. Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
d601033 to
e38ecca
Compare
Summary
amd64default for Kubernetes arch with runtime detectiondpkg --print-architecture(falls back touname -mmapping)Archstill takes precedenceTest plan
go test ./pkg/provisioner/templates/...passesgolangci-lint run ./...passes (0 issues)