Merge pull request #14347 from olemarkus/fix-arm64-image

Add node/master size from create cluster into IG spec
This commit is contained in:
Kubernetes Prow Robot 2022-09-28 04:03:37 -07:00 committed by GitHub
commit befd283381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 119 additions and 17 deletions

View File

@ -63,8 +63,6 @@ type CreateClusterOptions struct {
cloudup.NewClusterOptions cloudup.NewClusterOptions
Yes bool Yes bool
Target string Target string
NodeSize string
MasterSize string
MasterVolumeSize int32 MasterVolumeSize int32
NodeVolumeSize int32 NodeVolumeSize int32
ContainerRuntime string ContainerRuntime string
@ -544,12 +542,6 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr
cluster.Spec.CloudLabels = cloudLabels cluster.Spec.CloudLabels = cloudLabels
} }
if c.NodeSize != "" {
for _, group := range nodes {
group.Spec.MachineType = c.NodeSize
}
}
if c.AssociatePublicIP != nil { if c.AssociatePublicIP != nil {
for _, group := range instanceGroups { for _, group := range instanceGroups {
group.Spec.AssociatePublicIP = c.AssociatePublicIP group.Spec.AssociatePublicIP = c.AssociatePublicIP
@ -580,12 +572,6 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr
} }
} }
if c.MasterSize != "" {
for _, group := range masters {
group.Spec.MachineType = c.MasterSize
}
}
if c.MasterVolumeSize != 0 { if c.MasterVolumeSize != 0 {
for _, group := range masters { for _, group := range masters {
group.Spec.RootVolumeSize = fi.Int32(c.MasterVolumeSize) group.Spec.RootVolumeSize = fi.Int32(c.MasterVolumeSize)

View File

@ -53,6 +53,7 @@ func TestCreateClusterMinimal(t *testing.T) {
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.24", "v1alpha2") runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.24", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.25", "v1alpha2") runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.25", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.26", "v1alpha2") runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.26", "v1alpha2")
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/minimal-1.26-arm64", "v1alpha2")
} }
// TestCreateClusterHetzner runs kops create cluster minimal.k8s.local --zones fsn1 // TestCreateClusterHetzner runs kops create cluster minimal.k8s.local --zones fsn1

View File

@ -0,0 +1,97 @@
apiVersion: kops.k8s.io/v1alpha2
kind: Cluster
metadata:
creationTimestamp: "2017-01-01T00:00:00Z"
name: minimal.example.com
spec:
api:
dns: {}
authorization:
rbac: {}
channel: stable
cloudProvider: aws
configBase: memfs://tests/minimal.example.com
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
iam:
allowContainerRegistry: true
legacy: false
kubelet:
anonymousAuth: false
kubernetesApiAccess:
- 0.0.0.0/0
- ::/0
kubernetesVersion: v1.26.0
masterPublicName: api.minimal.example.com
networkCIDR: 172.20.0.0/16
networking:
cni: {}
nonMasqueradeCIDR: 100.64.0.0/10
sshAccess:
- 0.0.0.0/0
- ::/0
subnets:
- cidr: 172.20.32.0/19
name: us-test-1a
type: Public
zone: us-test-1a
topology:
dns:
type: Public
masters: public
nodes: public
---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
creationTimestamp: "2017-01-01T00:00:00Z"
labels:
kops.k8s.io/cluster: minimal.example.com
name: master-us-test-1a
spec:
image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-arm64-server-20220924
instanceMetadata:
httpPutResponseHopLimit: 3
httpTokens: required
machineType: m6g.xlarge
maxSize: 1
minSize: 1
role: Master
subnets:
- us-test-1a
---
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
creationTimestamp: "2017-01-01T00:00:00Z"
labels:
kops.k8s.io/cluster: minimal.example.com
name: nodes-us-test-1a
spec:
image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-arm64-server-20220924
instanceMetadata:
httpPutResponseHopLimit: 1
httpTokens: required
machineType: m6g.xlarge
maxSize: 1
minSize: 1
role: Node
subnets:
- us-test-1a

View File

@ -0,0 +1,8 @@
ClusterName: minimal.example.com
Zones:
- us-test-1a
CloudProvider: aws
Networking: cni
KubernetesVersion: v1.26.0
NodeSize: m6g.xlarge
MasterSize: m6g.xlarge

View File

@ -95,7 +95,7 @@ spec:
- sg-exampleid3 - sg-exampleid3
- sg-exampleid4 - sg-exampleid4
image: ubuntu-os-cloud/ubuntu-2004-focal-v20220927 image: ubuntu-os-cloud/ubuntu-2004-focal-v20220927
machineType: e2-medium machineType: e2-standard-2
maxSize: 1 maxSize: 1
minSize: 1 minSize: 1
role: Master role: Master

View File

@ -15,3 +15,4 @@ KubernetesVersion: v1.21.0
cloudLabels: "Owner=John Doe,dn=\"cn=John Doe: dc=example dc=com\", foo/bar=fib+baz" cloudLabels: "Owner=John Doe,dn=\"cn=John Doe: dc=example dc=com\", foo/bar=fib+baz"
Project: testproject Project: testproject
GCEServiceAccount: test-account@testproject.iam.gserviceaccount.com GCEServiceAccount: test-account@testproject.iam.gserviceaccount.com
MasterSize: e2-standard-2

View File

@ -358,7 +358,7 @@ func (c *MockAWSCloud) DescribeInstanceType(instanceType string) (*ec2.InstanceT
aws.String(ec2.ArchitectureTypeX8664), aws.String(ec2.ArchitectureTypeX8664),
}, },
} }
case "a1.large": case "a1.large", "m6g.xlarge":
info.ProcessorInfo = &ec2.ProcessorInfo{ info.ProcessorInfo = &ec2.ProcessorInfo{
SupportedArchitectures: []*string{ SupportedArchitectures: []*string{
aws.String(ec2.ArchitectureTypeArm64), aws.String(ec2.ArchitectureTypeArm64),

View File

@ -157,6 +157,8 @@ type NewClusterOptions struct {
Image string Image string
NodeImage string NodeImage string
MasterImage string MasterImage string
MasterSize string
NodeSize string
} }
func (o *NewClusterOptions) InitDefaults() { func (o *NewClusterOptions) InitDefaults() {
@ -856,6 +858,7 @@ func setupMasters(opt *NewClusterOptions, cluster *api.Cluster, zoneToSubnetMap
} }
} }
g.Spec.MachineType = opt.MasterSize
g.Spec.Image = opt.MasterImage g.Spec.Image = opt.MasterImage
masters = append(masters, g) masters = append(masters, g)
@ -983,6 +986,7 @@ func setupNodes(opt *NewClusterOptions, cluster *api.Cluster, zoneToSubnetMap ma
} }
} }
g.Spec.MachineType = opt.NodeSize
g.Spec.Image = opt.NodeImage g.Spec.Image = opt.NodeImage
nodes = append(nodes, g) nodes = append(nodes, g)
@ -1461,11 +1465,16 @@ func MachineArchitecture(cloud fi.Cloud, machineType string) (architectures.Arch
return architectures.ArchitectureAmd64, nil return architectures.ArchitectureAmd64, nil
} }
// Some calls only have AWS initialised at this point and in other cases pass in nil as cloud.
if cloud == nil {
return architectures.ArchitectureAmd64, nil
}
switch cloud.ProviderID() { switch cloud.ProviderID() {
case kopsapi.CloudProviderAWS: case kopsapi.CloudProviderAWS:
info, err := cloud.(awsup.AWSCloud).DescribeInstanceType(machineType) info, err := cloud.(awsup.AWSCloud).DescribeInstanceType(machineType)
if err != nil { if err != nil {
return "", fmt.Errorf("error finding instance info for instance type %q: %v", machineType, err) return "", fmt.Errorf("error finding instance info for instance type %q: %w", machineType, err)
} }
if info.ProcessorInfo == nil || len(info.ProcessorInfo.SupportedArchitectures) == 0 { if info.ProcessorInfo == nil || len(info.ProcessorInfo.SupportedArchitectures) == 0 {
return "", fmt.Errorf("error finding architecture info for instance type %q", machineType) return "", fmt.Errorf("error finding architecture info for instance type %q", machineType)