diff --git a/cluster-autoscaler/main.go b/cluster-autoscaler/main.go index 52bf6171d43..1bc403d9cf3 100644 --- a/cluster-autoscaler/main.go +++ b/cluster-autoscaler/main.go @@ -295,6 +295,9 @@ func buildAutoscaler() (core.Autoscaler, error) { if autoscalingOptions.CloudProviderName == cloudprovider.AzureProviderName { processors.NodeGroupSetProcessor = &nodegroupset.BalancingNodeGroupSetProcessor{ Comparator: nodegroupset.IsAzureNodeInfoSimilar} + } else if autoscalingOptions.CloudProviderName == cloudprovider.AwsProviderName { + processors.NodeGroupSetProcessor = &nodegroupset.BalancingNodeGroupSetProcessor{ + Comparator: nodegroupset.IsAwsNodeInfoSimilar} } opts := core.AutoscalerOptions{ diff --git a/cluster-autoscaler/processors/nodegroupset/aws_nodegroups.go b/cluster-autoscaler/processors/nodegroupset/aws_nodegroups.go new file mode 100644 index 00000000000..0899bbcabe2 --- /dev/null +++ b/cluster-autoscaler/processors/nodegroupset/aws_nodegroups.go @@ -0,0 +1,36 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package nodegroupset + +import ( + schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" +) + +// IsAwsNodeInfoSimilar adds AWS specific node labels to the list of ignored labels. +func IsAwsNodeInfoSimilar(n1, n2 *schedulernodeinfo.NodeInfo) bool { + awsIgnoredLabels := map[string]bool{ + "alpha.eksctl.io/instance-id": true, // this is a label used by eksctl to identify instances. + "alpha.eksctl.io/nodegroup-name": true, // this is a label used by eksctl to identify "node group" names. + "k8s.amazonaws.com/eniConfig": true, // this is a label used by the AWS CNI for custom networking. + "lifecycle": true, // this is a label used by the AWS for spot. + } + + for k, v := range BasicIgnoredLabels { + awsIgnoredLabels[k] = v + } + return IsCloudProviderNodeInfoSimilar(n1, n2, awsIgnoredLabels) +} diff --git a/cluster-autoscaler/processors/nodegroupset/compare_nodegroups.go b/cluster-autoscaler/processors/nodegroupset/compare_nodegroups.go index 2c9ad5c2702..07e3c3372d7 100644 --- a/cluster-autoscaler/processors/nodegroupset/compare_nodegroups.go +++ b/cluster-autoscaler/processors/nodegroupset/compare_nodegroups.go @@ -33,7 +33,7 @@ const ( MaxFreeDifferenceRatio = 0.05 // MaxMemoryDifferenceInKiloBytes describes how much memory // capacity can differ but still be considered equal. - MaxMemoryDifferenceInKiloBytes = 128000 + MaxMemoryDifferenceInKiloBytes = 256000 ) // BasicIgnoredLabels define a set of basic labels that should be ignored when comparing the similarity @@ -45,7 +45,6 @@ var BasicIgnoredLabels = map[string]bool{ apiv1.LabelZoneRegion: true, "beta.kubernetes.io/fluentd-ds-ready": true, // this is internal label used for determining if fluentd should be installed as deamon set. Used for migration 1.8 to 1.9. "kops.k8s.io/instancegroup": true, // this is a label used by kops to identify "instance group" names. it's value is variable, defeating check of similar node groups - "alpha.eksctl.io/nodegroup-name": true, // this is a label used by eksctl to identify "node group" names, similar in spirit to the kops label above } // NodeInfoComparator is a function that tells if two nodes are from NodeGroups