ARM64 support - Update bootstrap script for multi-arch

This commit is contained in:
Ciprian Hacman 2020-06-16 06:12:21 +03:00
parent 755b122f7e
commit 602cb825e7
4 changed files with 49 additions and 16 deletions

View File

@ -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)

View File

@ -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

View File

@ -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 {

View File

@ -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