Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added T3 Unlimited support #2391

Merged
merged 30 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
224eec9
Added T3 Unlimited
efim-a-efim Jul 1, 2020
da9c576
Refined logic to strictly follow CloudFormation
efim-a-efim Jul 1, 2020
4dd1451
Added tests
efim-a-efim Jul 1, 2020
5cfa0f1
Syntax fix
efim-a-efim Jul 1, 2020
d9320ab
Dereference pointer
efim-a-efim Jul 1, 2020
d5364dc
Fixing variable type
efim-a-efim Jul 1, 2020
37df944
Removed unused var
efim-a-efim Jul 1, 2020
8545f1e
Fixing tests
efim-a-efim Jul 1, 2020
d3b5ca2
Fixing tests
efim-a-efim Jul 1, 2020
95f9e51
Types fix in tests
efim-a-efim Jul 2, 2020
4d31a48
Gofmt-ed changed files
efim-a-efim Jul 2, 2020
99a386a
Added T3Unlimited validation
efim-a-efim Jul 2, 2020
2e99f13
Merge branch 'master' into t3-unlimited
efim-a-efim Jul 2, 2020
8eed025
Merge branch 'master' into t3-unlimited
efim-a-efim Jul 2, 2020
486908e
Merge branch 't3-unlimited' of github.com:efim-a-efim/eksctl into t3-…
efim-a-efim Jul 2, 2020
ebb7bba
Fixed template field naming
efim-a-efim Jul 2, 2020
2e0f954
Fixing naming in tests
efim-a-efim Jul 2, 2020
ffb1435
Fixed logical error in test
efim-a-efim Jul 4, 2020
8e2ce2f
Renamed t3Unlimited to cpuCredits
efim-a-efim Jul 6, 2020
63b0895
Merge branch 'master' into t3-unlimited
efim-a-efim Jul 6, 2020
1338a07
Fixing CPUCredits type
efim-a-efim Jul 6, 2020
437b857
Merge branch 't3-unlimited' of github.com:efim-a-efim/eksctl into t3-…
efim-a-efim Jul 6, 2020
e47a1f3
Fixing types
efim-a-efim Jul 7, 2020
b6e30c6
Fixing types and tests
efim-a-efim Jul 7, 2020
e4d9f54
CPUCredits validation in 1 function
efim-a-efim Jul 7, 2020
ac624dc
Fixing types and optional parameters
efim-a-efim Jul 7, 2020
944b654
Fixing type in tests
efim-a-efim Jul 7, 2020
607b064
Merge remote-tracking branch 'wv/master' into t3-unlimited
efim-a-efim Jul 7, 2020
eae5005
Removed unneeded validation
efim-a-efim Jul 8, 2020
43e55f3
Removed unused var
efim-a-efim Jul 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/assets/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,11 @@
"description": "enables [EBS optimization](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-optimized.html)",
"x-intellij-html-description": "enables <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-optimized.html\">EBS optimization</a>"
},
"t3Unlimited": {
"type": "boolean",
"description": "enables [T3 Unlimited](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances-unlimited-mode.html), valid only for T-type instances",
"x-intellij-html-description": "enables <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances-unlimited-mode.html\">T3 Unlimited</a>, valid only for T-type instances"
},
"iam": {
"$ref": "#/definitions/NodeGroupIAM"
},
Expand Down Expand Up @@ -869,6 +874,7 @@
"maxSize",
"asgMetricsCollection",
"ebsOptimized",
"t3Unlimited",
"volumeSize",
"volumeType",
"volumeName",
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,9 @@ type NodeGroup struct {
// +optional
EBSOptimized *bool `json:"ebsOptimized,omitempty"`

// T3Unlimited enables [T3 Unlimited](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances-unlimited-mode.html), valid only for T-type instances
T3Unlimited *bool `json:"t3Unlimited,omitempty"`
efim-a-efim marked this conversation as resolved.
Show resolved Hide resolved

// VolumeSize gigabytes
// Defaults to `80`
// +optional
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 99 additions & 5 deletions pkg/cfn/builder/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type Properties struct {
SpotAllocationStrategy string
}
}

}

type LaunchTemplateData struct {
Expand All @@ -132,6 +133,9 @@ type LaunchTemplateData struct {
MaxPrice string
}
}
CreditSpecification *struct {
CpuCredits string
}
}

type Template struct {
Expand Down Expand Up @@ -1916,6 +1920,7 @@ var _ = Describe("CloudFormation template builder API", func() {
})
})


checkAsset := func(name, expectedContent string) {
assetContent, err := nodebootstrap.Asset(name)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -2881,14 +2886,15 @@ var _ = Describe("CloudFormation template builder API", func() {

})

maxSpotPrice := 0.045
baseCap := 40
percentageOnDemand := 20
pools := 3
spotAllocationStrategy := "lowest-price"

Context("Nodegroup with Mixed instances", func() {
cfg, ng := newClusterConfigAndNodegroup(true)

maxSpotPrice := 0.045
baseCap := 40
percentageOnDemand := 20
pools := 3
spotAllocationStrategy := "lowest-price"
ng.InstanceType = "mixed"
ng.InstancesDistribution = &api.NodeGroupInstancesDistribution{
MaxPrice: &maxSpotPrice,
Expand Down Expand Up @@ -2933,6 +2939,94 @@ var _ = Describe("CloudFormation template builder API", func() {

})
})

Context("NodeGroup{T3Unlimited=nil}", func() {
cfg, ng := newClusterConfigAndNodegroup(true)

build(cfg, "eksctl-test-t3-unlimited", ng)

roundtrip()

It("should have correct resources and attributes", func() {
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification).To(BeNil())
})
})

Context("NodeGroup{T3Unlimited=false InstancesDistribution.InstanceTypes=t3.medium,t3a.medium}", func() {
cfg, ng := newClusterConfigAndNodegroup(true)

ng.InstanceType = "mixed"
ng.T3Unlimited = false
ng.InstancesDistribution = &api.NodeGroupInstancesDistribution{
MaxPrice: &maxSpotPrice,
InstanceTypes: []string{"t3.medium", "t3a.medium"},
OnDemandBaseCapacity: &baseCap,
OnDemandPercentageAboveBaseCapacity: &percentageOnDemand,
SpotInstancePools: &pools,
SpotAllocationStrategy: &spotAllocationStrategy,
}

build(cfg, "eksctl-test-t3-unlimited", ng)

roundtrip()

It("should have correct resources and attributes", func() {
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification).To(BeNil())
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification.CpuCredits).ToNot(BeNil())
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification.CpuCredits).To(Equal("standard"))
})
})

Context("NodeGroup{T3Unlimited=true InstancesDistribution.InstanceTypes=t3.medium,t3a.medium}", func() {
cfg, ng := newClusterConfigAndNodegroup(true)

ng.InstanceType = "mixed"
ng.T3Unlimited = true
ng.InstancesDistribution = &api.NodeGroupInstancesDistribution{
MaxPrice: &maxSpotPrice,
InstanceTypes: []string{"t3.medium", "t3a.medium"},
OnDemandBaseCapacity: &baseCap,
OnDemandPercentageAboveBaseCapacity: &percentageOnDemand,
SpotInstancePools: &pools,
SpotAllocationStrategy: &spotAllocationStrategy,
}

build(cfg, "eksctl-test-t3-unlimited", ng)

roundtrip()

It("should have correct resources and attributes", func() {
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification).ToNot(BeNil())
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification.CpuCredits).ToNot(BeNil())
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification.CpuCredits).To(Equal("unlimited"))
})
})

Context("NodeGroup{T3Unlimited=true InstancesDistribution.InstanceTypes=m5.large}", func() {
efim-a-efim marked this conversation as resolved.
Show resolved Hide resolved
cfg, ng := newClusterConfigAndNodegroup(true)

ng.InstanceType = "mixed"
ng.T3Unlimited = true
ng.InstancesDistribution = &api.NodeGroupInstancesDistribution{
MaxPrice: &maxSpotPrice,
InstanceTypes: []string{"m5.large", "m5.2xlarge"},
OnDemandBaseCapacity: &baseCap,
OnDemandPercentageAboveBaseCapacity: &percentageOnDemand,
SpotInstancePools: &pools,
SpotAllocationStrategy: &spotAllocationStrategy,
}

build(cfg, "eksctl-test-t3-unlimited", ng)

roundtrip()

It("should have correct resources and attributes", func() {
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification).ToNot(BeNil())
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification.CpuCredits).ToNot(BeNil())
Expect(getLaunchTemplateData(ngTemplate).CreditSpecification.CpuCredits).To(Equal("standard"))
})
})

})

func setSubnets(cfg *api.ClusterConfig) {
Expand Down
30 changes: 30 additions & 0 deletions pkg/cfn/builder/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ func (n *NodeGroupResourceSet) GetAllOutputs(stack cfn.Stack) error {
}

func newLaunchTemplateData(n *NodeGroupResourceSet) *gfn.AWSEC2LaunchTemplate_LaunchTemplateData {
isTInstance := false
efim-a-efim marked this conversation as resolved.
Show resolved Hide resolved

launchTemplateData := &gfn.AWSEC2LaunchTemplate_LaunchTemplateData{
IamInstanceProfile: &gfn.AWSEC2LaunchTemplate_IamInstanceProfile{
Arn: n.instanceProfileARN,
Expand All @@ -267,15 +269,43 @@ func newLaunchTemplateData(n *NodeGroupResourceSet) *gfn.AWSEC2LaunchTemplate_La
HttpPutResponseHopLimit: gfn.NewInteger(2),
},
}

if !api.HasMixedInstances(n.spec) {
launchTemplateData.InstanceType = gfn.NewString(n.spec.InstanceType)

if strings.HasPrefix(n.spec.InstanceType, "t") {
isTInstance = true
}
} else {
launchTemplateData.InstanceType = gfn.NewString(n.spec.InstancesDistribution.InstanceTypes[0])

for _, instanceType := range n.spec.InstancesDistribution.InstanceTypes {
if strings.HasPrefix(instanceType, "t") {
isTInstance = true
}
}
}
if n.spec.EBSOptimized != nil {
launchTemplateData.EbsOptimized = gfn.NewBoolean(*n.spec.EBSOptimized)
}

// Add T3 Unlimited setting only if nodegroup has T-type instances
if n.spec.T3Unlimited != nil {
if isTInstance {
if *n.spec.T3Unlimited {
launchTemplateData.CreditSpecification = &gfn.AWSEC2LaunchTemplate_CreditSpecification{
CpuCredits: gfn.NewString("unlimited"),
}
} else {
launchTemplateData.CreditSpecification = &gfn.AWSEC2LaunchTemplate_CreditSpecification{
CpuCredits: gfn.NewString("standard"),
}
}
} else {
logger.Warning("T3unlimited option ignored, nodegroup %s has no T3 instance types", n.nodeGroupName)
}
}

return launchTemplateData
}

Expand Down