mirror of https://github.com/kubernetes/kops.git
ARM64 support - Update bootstrap script for multi-arch
This commit is contained in:
parent
755b122f7e
commit
602cb825e7
|
|
@ -35,12 +35,13 @@ import (
|
||||||
"k8s.io/kops/pkg/model/resources"
|
"k8s.io/kops/pkg/model/resources"
|
||||||
"k8s.io/kops/upup/pkg/fi"
|
"k8s.io/kops/upup/pkg/fi"
|
||||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||||
|
"k8s.io/kops/util/pkg/architectures"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BootstrapScript creates the bootstrap script
|
// BootstrapScript creates the bootstrap script
|
||||||
type BootstrapScript struct {
|
type BootstrapScript struct {
|
||||||
NodeUpSource string
|
NodeUpSource map[architectures.Architecture]string
|
||||||
NodeUpSourceHash string
|
NodeUpSourceHash map[architectures.Architecture]string
|
||||||
NodeUpConfigBuilder func(ig *kops.InstanceGroup) (*nodeup.Config, error)
|
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{
|
functions := template.FuncMap{
|
||||||
"NodeUpSource": func() string {
|
"NodeUpSourceAmd64": func() string {
|
||||||
return b.NodeUpSource
|
return b.NodeUpSource[architectures.ArchitectureAmd64]
|
||||||
},
|
},
|
||||||
"NodeUpSourceHash": func() string {
|
"NodeUpSourceHashAmd64": func() string {
|
||||||
return b.NodeUpSourceHash
|
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) {
|
"KubeEnv": func() (string, error) {
|
||||||
return b.KubeEnv(ig)
|
return b.KubeEnv(ig)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"k8s.io/kops/pkg/apis/kops"
|
"k8s.io/kops/pkg/apis/kops"
|
||||||
"k8s.io/kops/pkg/apis/nodeup"
|
"k8s.io/kops/pkg/apis/nodeup"
|
||||||
"k8s.io/kops/pkg/testutils/golden"
|
"k8s.io/kops/pkg/testutils/golden"
|
||||||
|
"k8s.io/kops/util/pkg/architectures"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ProxyFunc(t *testing.T) {
|
func Test_ProxyFunc(t *testing.T) {
|
||||||
|
|
@ -118,9 +119,15 @@ func TestBootstrapUserData(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bs := &BootstrapScript{
|
bs := &BootstrapScript{
|
||||||
NodeUpSource: "NUSource",
|
|
||||||
NodeUpSourceHash: "NUSHash",
|
|
||||||
NodeUpConfigBuilder: renderNodeUpConfig,
|
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
|
// Purposely running this twice to cover issue #3516
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import (
|
||||||
"k8s.io/kops/pkg/model"
|
"k8s.io/kops/pkg/model"
|
||||||
"k8s.io/kops/upup/pkg/fi"
|
"k8s.io/kops/upup/pkg/fi"
|
||||||
"k8s.io/kops/upup/pkg/fi/cloudup/openstacktasks"
|
"k8s.io/kops/upup/pkg/fi/cloudup/openstacktasks"
|
||||||
|
"k8s.io/kops/util/pkg/architectures"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ServerGroupModelBuilder(t *testing.T) {
|
func Test_ServerGroupModelBuilder(t *testing.T) {
|
||||||
|
|
@ -2715,8 +2716,14 @@ func Test_ServerGroupModelBuilder(t *testing.T) {
|
||||||
NodeUpConfigBuilder: func(ig *kops.InstanceGroup) (*nodeup.Config, error) {
|
NodeUpConfigBuilder: func(ig *kops.InstanceGroup) (*nodeup.Config, error) {
|
||||||
return &nodeup.Config{}, nil
|
return &nodeup.Config{}, nil
|
||||||
},
|
},
|
||||||
NodeUpSource: "source",
|
NodeUpSource: map[architectures.Architecture]string{
|
||||||
NodeUpSourceHash: "source-hash",
|
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)
|
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) {
|
NodeUpConfigBuilder: func(ig *kops.InstanceGroup) (*nodeup.Config, error) {
|
||||||
return &nodeup.Config{}, nil
|
return &nodeup.Config{}, nil
|
||||||
},
|
},
|
||||||
NodeUpSource: "source",
|
NodeUpSource: map[architectures.Architecture]string{
|
||||||
NodeUpSourceHash: "source-hash",
|
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)
|
startupResources, err := bootstrapScriptBuilder.ResourceNodeUp(ig, cluster)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,10 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
NODEUP_URL={{ NodeUpSource }}
|
NODEUP_URL_AMD64={{ NodeUpSourceAmd64 }}
|
||||||
NODEUP_HASH={{ NodeUpSourceHash }}
|
NODEUP_HASH_AMD64={{ NodeUpSourceHashAmd64 }}
|
||||||
|
NODEUP_URL_ARM64={{ NodeUpSourceArm64 }}
|
||||||
|
NODEUP_HASH_ARM64={{ NodeUpSourceHashArm64 }}
|
||||||
|
|
||||||
{{ EnvironmentVariables }}
|
{{ EnvironmentVariables }}
|
||||||
|
|
||||||
|
|
@ -139,8 +141,12 @@ function try-download-release() {
|
||||||
function download-release() {
|
function download-release() {
|
||||||
case "$(uname -m)" in
|
case "$(uname -m)" in
|
||||||
x86_64*|i?86_64*|amd64*)
|
x86_64*|i?86_64*|amd64*)
|
||||||
NODEUP_URL="${NODEUP_URL}"
|
NODEUP_URL="${NODEUP_URL_AMD64}"
|
||||||
NODEUP_HASH="${NODEUP_HASH}"
|
NODEUP_HASH="${NODEUP_HASH_AMD64}"
|
||||||
|
;;
|
||||||
|
aarch64*|arm64*)
|
||||||
|
NODEUP_URL="${NODEUP_URL_ARM64}"
|
||||||
|
NODEUP_HASH="${NODEUP_HASH_ARM64}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported host arch: $(uname -m)" >&2
|
echo "Unsupported host arch: $(uname -m)" >&2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue