diff --git a/pkg/model/bootstrapscript.go b/pkg/model/bootstrapscript.go index 769f6055d2..bd524b2d84 100644 --- a/pkg/model/bootstrapscript.go +++ b/pkg/model/bootstrapscript.go @@ -35,12 +35,13 @@ import ( "k8s.io/kops/pkg/model/resources" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/awsup" + "k8s.io/kops/util/pkg/architectures" ) // BootstrapScript creates the bootstrap script type BootstrapScript struct { - NodeUpSource string - NodeUpSourceHash string + NodeUpSource map[architectures.Architecture]string + NodeUpSourceHash map[architectures.Architecture]string NodeUpConfigBuilder func(ig *kops.InstanceGroup) (*nodeup.Config, error) } @@ -140,11 +141,17 @@ func (b *BootstrapScript) ResourceNodeUp(ig *kops.InstanceGroup, cluster *kops.C } functions := template.FuncMap{ - "NodeUpSource": func() string { - return b.NodeUpSource + "NodeUpSourceAmd64": func() string { + return b.NodeUpSource[architectures.ArchitectureAmd64] }, - "NodeUpSourceHash": func() string { - return b.NodeUpSourceHash + "NodeUpSourceHashAmd64": func() string { + return b.NodeUpSourceHash[architectures.ArchitectureAmd64] + }, + "NodeUpSourceArm64": func() string { + return b.NodeUpSource[architectures.ArchitectureArm64] + }, + "NodeUpSourceHashArm64": func() string { + return b.NodeUpSourceHash[architectures.ArchitectureArm64] }, "KubeEnv": func() (string, error) { return b.KubeEnv(ig) diff --git a/pkg/model/bootstrapscript_test.go b/pkg/model/bootstrapscript_test.go index bb1f84139f..b1967bf493 100644 --- a/pkg/model/bootstrapscript_test.go +++ b/pkg/model/bootstrapscript_test.go @@ -23,6 +23,7 @@ import ( "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/apis/nodeup" "k8s.io/kops/pkg/testutils/golden" + "k8s.io/kops/util/pkg/architectures" ) func Test_ProxyFunc(t *testing.T) { @@ -118,9 +119,15 @@ func TestBootstrapUserData(t *testing.T) { } bs := &BootstrapScript{ - NodeUpSource: "NUSource", - NodeUpSourceHash: "NUSHash", NodeUpConfigBuilder: renderNodeUpConfig, + NodeUpSource: map[architectures.Architecture]string{ + architectures.ArchitectureAmd64: "NUSourceAmd64", + architectures.ArchitectureArm64: "NUSourceArm64", + }, + NodeUpSourceHash: map[architectures.Architecture]string{ + architectures.ArchitectureAmd64: "NUSHashAmd64", + architectures.ArchitectureArm64: "NUSHashArm64", + }, } // Purposely running this twice to cover issue #3516 diff --git a/pkg/model/openstackmodel/servergroup_test.go b/pkg/model/openstackmodel/servergroup_test.go index 78721e96b9..c264909d0c 100644 --- a/pkg/model/openstackmodel/servergroup_test.go +++ b/pkg/model/openstackmodel/servergroup_test.go @@ -29,6 +29,7 @@ import ( "k8s.io/kops/pkg/model" "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstacktasks" + "k8s.io/kops/util/pkg/architectures" ) func Test_ServerGroupModelBuilder(t *testing.T) { @@ -2715,8 +2716,14 @@ func Test_ServerGroupModelBuilder(t *testing.T) { NodeUpConfigBuilder: func(ig *kops.InstanceGroup) (*nodeup.Config, error) { return &nodeup.Config{}, nil }, - NodeUpSource: "source", - NodeUpSourceHash: "source-hash", + NodeUpSource: map[architectures.Architecture]string{ + architectures.ArchitectureAmd64: "source-amd64", + architectures.ArchitectureArm64: "source-arm64", + }, + NodeUpSourceHash: map[architectures.Architecture]string{ + architectures.ArchitectureAmd64: "source-hash-amd64", + architectures.ArchitectureArm64: "source-hash-arm64", + }, } builder := createBuilderForCluster(testCase.cluster, testCase.instanceGroups, clusterLifecycle, bootstrapScriptBuilder) @@ -3179,8 +3186,14 @@ func mustUserdataForClusterInstance(cluster *kops.Cluster, ig *kops.InstanceGrou NodeUpConfigBuilder: func(ig *kops.InstanceGroup) (*nodeup.Config, error) { return &nodeup.Config{}, nil }, - NodeUpSource: "source", - NodeUpSourceHash: "source-hash", + NodeUpSource: map[architectures.Architecture]string{ + architectures.ArchitectureAmd64: "source-amd64", + architectures.ArchitectureArm64: "source-arm64", + }, + NodeUpSourceHash: map[architectures.Architecture]string{ + architectures.ArchitectureAmd64: "source-hash-amd64", + architectures.ArchitectureArm64: "source-hash-arm64", + }, } startupResources, err := bootstrapScriptBuilder.ResourceNodeUp(ig, cluster) if err != nil { diff --git a/pkg/model/resources/nodeup.go b/pkg/model/resources/nodeup.go index ee3bbdcb26..d2433945cc 100644 --- a/pkg/model/resources/nodeup.go +++ b/pkg/model/resources/nodeup.go @@ -45,8 +45,10 @@ set -o errexit set -o nounset set -o pipefail -NODEUP_URL={{ NodeUpSource }} -NODEUP_HASH={{ NodeUpSourceHash }} +NODEUP_URL_AMD64={{ NodeUpSourceAmd64 }} +NODEUP_HASH_AMD64={{ NodeUpSourceHashAmd64 }} +NODEUP_URL_ARM64={{ NodeUpSourceArm64 }} +NODEUP_HASH_ARM64={{ NodeUpSourceHashArm64 }} {{ EnvironmentVariables }} @@ -139,8 +141,12 @@ function try-download-release() { function download-release() { case "$(uname -m)" in x86_64*|i?86_64*|amd64*) - NODEUP_URL="${NODEUP_URL}" - NODEUP_HASH="${NODEUP_HASH}" + NODEUP_URL="${NODEUP_URL_AMD64}" + NODEUP_HASH="${NODEUP_HASH_AMD64}" + ;; + aarch64*|arm64*) + NODEUP_URL="${NODEUP_URL_ARM64}" + NODEUP_HASH="${NODEUP_HASH_ARM64}" ;; *) echo "Unsupported host arch: $(uname -m)" >&2