Setup e2e_node to support testing on ARM64

* Enable dockerized build with --use-dockerized-build=true
* Build and create test artifacts for ARM64 with --target-build-arch=arm64
* Prepull multi-arch ready container image
* Download ARM64 binaries/packages if running on ARM64 machine
This commit is contained in:
Ike Ma
2023-03-30 17:01:38 +00:00
parent 6d09ab86c2
commit e21cf9a54e
7 changed files with 57 additions and 9 deletions

View File

@@ -29,6 +29,8 @@ import (
)
var k8sBinDir = flag.String("k8s-bin-dir", "", "Directory containing k8s kubelet binaries.")
var useDockerizedBuild = flag.Bool("use-dockerized-build", false, "Use dockerized build for test artifacts")
var targetBuildArch = flag.String("target-build-arch", "linux/amd64", "Target architecture for the test artifacts for dockerized build")
var buildTargets = []string{
"cmd/kubelet",
@@ -47,6 +49,11 @@ func BuildGo() error {
}
targets := strings.Join(buildTargets, " ")
cmd := exec.Command("make", "-C", k8sRoot, fmt.Sprintf("WHAT=%s", targets))
if IsDockerizedBuild() {
klog.Infof("Building dockerized k8s binaries targets %s for architecture %s", targets, GetTargetBuildArch())
// Multi-architecture build is only supported in dockerized build
cmd = exec.Command(filepath.Join(k8sRoot, "build/run.sh"), "make", fmt.Sprintf("WHAT=%s", targets), fmt.Sprintf("KUBE_BUILD_PLATFORMS=%s", GetTargetBuildArch()))
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
@@ -56,6 +63,21 @@ func BuildGo() error {
return nil
}
// IsDockerizedBuild returns if test needs to use dockerized build
func IsDockerizedBuild() bool {
return *useDockerizedBuild
}
// GetTargetBuildArch returns the target build architecture for dockerized build
func GetTargetBuildArch() string {
return *targetBuildArch
}
// IsTargetArchArm64 returns if the target is for linux/arm64 platform
func IsTargetArchArm64() bool {
return GetTargetBuildArch() == "linux/arm64"
}
func getK8sBin(bin string) (string, error) {
// Use commandline specified path
if *k8sBinDir != "" {
@@ -77,7 +99,7 @@ func getK8sBin(bin string) (string, error) {
return filepath.Join(path, bin), nil
}
buildOutputDir, err := utils.GetK8sBuildOutputDir()
buildOutputDir, err := utils.GetK8sBuildOutputDir(IsDockerizedBuild(), GetTargetBuildArch())
if err != nil {
return "", err
}