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

support metrics collection in scaling config for unmanaged node groups #2055

Merged
merged 1 commit into from
Apr 28, 2020
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
13 changes: 12 additions & 1 deletion examples/05-advanced-nodegroups.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# An advanced example of ClusterConfig object with customised nodegroups:
---
---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

Expand Down Expand Up @@ -42,6 +42,17 @@ nodeGroups:
nodegroup-type: very-special-science-workloads
classicLoadBalancerNames:
- ng3-classic-load-balancer
asgMetricsCollection:
saada marked this conversation as resolved.
Show resolved Hide resolved
- granularity: 1Minute
metrics:
- GroupMinSize
- GroupMaxSize
- GroupDesiredCapacity
- GroupInServiceInstances
- GroupPendingInstances
- GroupStandbyInstances
- GroupTerminatingInstances
- GroupTotalInstances
taints:
special: "true:NoSchedule"
privateNetworking: true
Expand Down
11 changes: 11 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,8 @@ type NodeGroup struct {
MinSize *int `json:"minSize,omitempty"`
// +optional
MaxSize *int `json:"maxSize,omitempty"`
// +optional
ASGMetricsCollection []MetricsCollection `json:"asgMetricsCollection,omitempty"`

// +optional
EBSOptimized *bool `json:"ebsOptimized,omitempty"`
Expand Down Expand Up @@ -787,6 +789,15 @@ type (
}
)

// MetricsCollection used by the scaling config
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-metricscollection.html
type MetricsCollection struct {
// +required
Granularity string `json:"granularity"`
// +optional
Metrics []string `json:"metrics,omitempty"`
}

// ScalingConfig defines the scaling config
type ScalingConfig struct {
// +optional
Expand Down
28 changes: 28 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.

26 changes: 25 additions & 1 deletion pkg/cfn/builder/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Properties struct {
VPCZoneIdentifier interface{}

LoadBalancerNames []string
MetricsCollection []map[string]interface{}
TargetGroupARNs []string
DesiredCapacity, MinSize, MaxSize string

Expand Down Expand Up @@ -811,7 +812,15 @@ var _ = Describe("CloudFormation template builder API", func() {

Context("NodeGroupAutoScaling", func() {
cfg, ng := newClusterConfigAndNodegroup(true)

ng.ASGMetricsCollection = []api.MetricsCollection{
{
Granularity: "1Minute",
Metrics: []string{
"GroupMinSize",
"GroupMaxSize",
},
},
}
ng.ClassicLoadBalancerNames = []string{"clb-1", "clb-2"}
ng.TargetGroupARNs = []string{"tg-arn-1", "tg-arn-2"}

Expand Down Expand Up @@ -916,6 +925,21 @@ var _ = Describe("CloudFormation template builder API", func() {
Expect(ng.Properties.LoadBalancerNames).To(Equal([]string{"clb-1", "clb-2"}))
})

It("should have metrics collections set", func() {
Expect(ngTemplate.Resources).To(HaveKey("NodeGroup"))
ng := ngTemplate.Resources["NodeGroup"]
Expect(ng).ToNot(BeNil())
Expect(ng.Properties).ToNot(BeNil())

Expect(ng.Properties.MetricsCollection).To(HaveLen(1))
var metricsCollection map[string]interface{} = ng.Properties.MetricsCollection[0]
Expect(metricsCollection).To(HaveKey("Granularity"))
Expect(metricsCollection).To(HaveKey("Metrics"))
Expect(metricsCollection["Granularity"]).To(Equal("1Minute"))
Expect(metricsCollection["Metrics"]).To(ContainElement("GroupMinSize"))
Expect(metricsCollection["Metrics"]).To(ContainElement("GroupMaxSize"))
})

It("should have target groups ARNs set", func() {
Expect(ngTemplate.Resources).To(HaveKey("NodeGroup"))
ng := ngTemplate.Resources["NodeGroup"]
Expand Down
18 changes: 18 additions & 0 deletions pkg/cfn/builder/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ func nodeGroupResource(launchTemplateName *gfn.Value, vpcZoneIdentifier interfac
if ng.MaxSize != nil {
ngProps["MaxSize"] = fmt.Sprintf("%d", *ng.MaxSize)
}
if len(ng.ASGMetricsCollection) > 0 {
ngProps["MetricsCollection"] = metricsCollectionResource(ng.ASGMetricsCollection)
}
if len(ng.ClassicLoadBalancerNames) > 0 {
ngProps["LoadBalancerNames"] = ng.ClassicLoadBalancerNames
}
Expand Down Expand Up @@ -345,3 +348,18 @@ func mixedInstancesPolicy(launchTemplateName *gfn.Value, ng *api.NodeGroup) *map

return &policy
}

func metricsCollectionResource(asgMetricsCollection []api.MetricsCollection) []map[string]interface{} {
var metricsCollections []map[string]interface{}
for _, m := range asgMetricsCollection {
newCollection := make(map[string]interface{})

var metrics []string
metrics = append(metrics, m.Metrics...)
newCollection["Metrics"] = metrics
newCollection["Granularity"] = m.Granularity

metricsCollections = append(metricsCollections, newCollection)
}
return metricsCollections
}
1 change: 1 addition & 0 deletions userdocs/src/usage/eks-managed-nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ the provisioned Autoscaling Group like in unmanaged nodegroups.
- Control over the node bootstrapping process and customization of the kubelet are not supported. This includes the
following fields: `classicLoadBalancerNames`, `maxPodsPerNode`, `taints`, `targetGroupARNs`, `preBootstrapCommands`, `overrideBootstrapCommand`,
`clusterDNS` and `kubeletExtraConfig`.
- No support for enabling metrics on AutoScalingGroups using `asgMetricsCollection`

## Note for eksctl versions below 0.12.0
- For clusters upgraded from EKS 1.13 to EKS 1.14, managed nodegroups will not be able to communicate with unmanaged
Expand Down
11 changes: 11 additions & 0 deletions userdocs/src/usage/managing-nodegroups.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ nodeGroups:
classicLoadBalancerNames:
- dev-clb-1
- dev-clb-2
asgMetricsCollection:
- granularity: 1Minute
metrics:
- GroupMinSize
saada marked this conversation as resolved.
Show resolved Hide resolved
- GroupMaxSize
- GroupDesiredCapacity
- GroupInServiceInstances
- GroupPendingInstances
- GroupStandbyInstances
- GroupTerminatingInstances
- GroupTotalInstances
- name: ng-2-api
labels: { role: api }
instanceType: m5.2xlarge
Expand Down
17 changes: 17 additions & 0 deletions userdocs/src/usage/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,18 @@ ManagedNodeGroup:
- ScalingConfig
- privateNetworking
type: object
MetricsCollection:
additionalProperties: false
properties:
granularity:
type: string
metrics:
items:
type: string
type: array
required:
- granularity
type: object
Network:
additionalProperties: false
properties:
Expand All @@ -369,6 +381,11 @@ NodeGroup:
type: string
amiFamily:
type: string
asgMetricsCollection:
items:
$ref: '#/definitions/MetricsCollection'
$schema: http://json-schema.org/draft-04/schema#
type: array
availabilityZones:
items:
type: string
Expand Down