Sitelet https://github.com/kubernetes/kops/pull/18113/files
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions docs/instance_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,24 @@ spec:

Note that burstable instances are always included in the set of eligible instances.

You can exclude instance types from the set of eligible instances using `excludedInstanceTypes`.
You can use strings with one or more wild cards, represented by an asterisk (*), to exclude an instance type, size, or generation.
For example, `m7i.8xlarge`, `c7*.*`, `m7a.*`, `r*`, `*3*`.

```
spec:
mixedInstancesPolicy:
instanceRequirements:
cpu:
min: "2"
max: "16"
memory:
min: "2G"
excludedInstanceTypes:
- t2.*
- t3.*
```

## warmPool (AWS Only)

{{ kops_feature_table(kops_added_default='1.21') }}
Expand Down
8 changes: 8 additions & 0 deletions k8s/crds/kops.k8s.io_instancegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,14 @@ spec:
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
excludedInstanceTypes:
description: |-
ExcludedInstanceTypes is a list of instance types which will not be used by the instance group.
You can use strings with one or more wild cards, represented by an asterisk (*), to exclude an
instance type, size, or generation.
items:
type: string
type: array
memory:
properties:
max:
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/kops/instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ type MixedInstancesPolicySpec struct {
type InstanceRequirementsSpec struct {
CPU *MinMaxSpec `json:"cpu,omitempty"`
Memory *MinMaxSpec `json:"memory,omitempty"`
// ExcludedInstanceTypes is a list of instance types which will not be used by the instance group.
// You can use strings with one or more wild cards, represented by an asterisk (*), to exclude an
// instance type, size, or generation.
ExcludedInstanceTypes []string `json:"excludedInstanceTypes,omitempty"`
}

type MinMaxSpec struct {
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/kops/v1alpha2/instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ type MixedInstancesPolicySpec struct {
type InstanceRequirementsSpec struct {
CPU *MinMaxSpec `json:"cpu,omitempty"`
Memory *MinMaxSpec `json:"memory,omitempty"`
// ExcludedInstanceTypes is a list of instance types which will not be used by the instance group.
// You can use strings with one or more wild cards, represented by an asterisk (*), to exclude an
// instance type, size, or generation.
ExcludedInstanceTypes []string `json:"excludedInstanceTypes,omitempty"`
}

type MinMaxSpec struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions pkg/apis/kops/v1alpha3/instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ type MixedInstancesPolicySpec struct {
type InstanceRequirementsSpec struct {
CPU *MinMaxSpec `json:"cpu,omitempty"`
Memory *MinMaxSpec `json:"memory,omitempty"`
// ExcludedInstanceTypes is a list of instance types which will not be used by the instance group.
// You can use strings with one or more wild cards, represented by an asterisk (*), to exclude an
// instance type, size, or generation.
ExcludedInstanceTypes []string `json:"excludedInstanceTypes,omitempty"`
}

type MinMaxSpec struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha3/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha3/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions pkg/model/awsmodel/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo
} else {
ir.MemoryMin = fi.PtrTo(int32(0))
}
if len(spec.InstanceRequirements.ExcludedInstanceTypes) > 0 {
ir.ExcludedInstanceTypes = spec.InstanceRequirements.ExcludedInstanceTypes
}
t.InstanceRequirements = ir
}

Expand Down
40 changes: 24 additions & 16 deletions upup/pkg/fi/cloudup/awstasks/instancerequirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
)

type InstanceRequirements struct {
Architecture *string
CPUMin *int32
CPUMax *int32
MemoryMin *int32
MemoryMax *int32
Architecture *string
CPUMin *int32
CPUMax *int32
MemoryMin *int32
MemoryMax *int32
ExcludedInstanceTypes []string
}

var _ fi.CloudupHasDependencies = (*InstanceRequirements)(nil)
Expand All @@ -49,6 +50,9 @@ func findInstanceRequirements(asg *autoscalingtypes.AutoScalingGroup) (*Instance
actual.MemoryMax = override.InstanceRequirements.MemoryMiB.Max
actual.MemoryMax = override.InstanceRequirements.MemoryMiB.Min

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated bug, but good occasion to fix.

Suggested change
actual.MemoryMax = override.InstanceRequirements.MemoryMiB.Min
actual.MemoryMin = override.InstanceRequirements.MemoryMiB.Min

}
if len(override.InstanceRequirements.ExcludedInstanceTypes) > 0 {
actual.ExcludedInstanceTypes = override.InstanceRequirements.ExcludedInstanceTypes
}
return actual, nil
}
}
Expand All @@ -57,17 +61,21 @@ func findInstanceRequirements(asg *autoscalingtypes.AutoScalingGroup) (*Instance
}

func overridesFromInstanceRequirements(ir *InstanceRequirements) autoscalingtypes.LaunchTemplateOverrides {
return autoscalingtypes.LaunchTemplateOverrides{
InstanceRequirements: &autoscalingtypes.InstanceRequirements{
VCpuCount: &autoscalingtypes.VCpuCountRequest{
Max: ir.CPUMax,
Min: ir.CPUMin,
},
MemoryMiB: &autoscalingtypes.MemoryMiBRequest{
Max: ir.MemoryMax,
Min: ir.MemoryMin,
},
BurstablePerformance: autoscalingtypes.BurstablePerformanceIncluded,
req := &autoscalingtypes.InstanceRequirements{
VCpuCount: &autoscalingtypes.VCpuCountRequest{
Max: ir.CPUMax,
Min: ir.CPUMin,
},
MemoryMiB: &autoscalingtypes.MemoryMiBRequest{
Max: ir.MemoryMax,
Min: ir.MemoryMin,
},
BurstablePerformance: autoscalingtypes.BurstablePerformanceIncluded,
}
if len(ir.ExcludedInstanceTypes) > 0 {
req.ExcludedInstanceTypes = ir.ExcludedInstanceTypes
}
return autoscalingtypes.LaunchTemplateOverrides{
InstanceRequirements: req,
}
}
Loading