Commit Graph

44 Commits

Author SHA1 Message Date
Julien Balestra 716836acde cluster-autoscaler/aws: batch launch config query and ttl cache
Signed-off-by: Julien Balestra <julien.balestra@datadoghq.com>
2020-02-19 16:36:42 +01:00
Ace Eldeib d63067e70b refactor: move aws discovery config 2019-10-17 05:19:11 -07:00
Jiaxin Shan 7eb864502c Load AWS EC2 Instance Types dynamically 2019-10-14 17:19:42 -07:00
Alfred Krohmer f7695c52ea AWS – use `session.NewSession` instead of `session.New` to
`session.New` is deprecated and requires the `AWS_SDK_LOAD_CONFIG`
environment variable to be set in order to automatically call
`AssumeRoleWithWebIdentity` when `AWS_WEB_IDENTITY_TOKEN_FILE` is set
(which is not documented and most likely unintended).
2019-10-07 15:09:51 +02:00
Kubernetes Prow Robot 8d9010e11e
Merge pull request #2248 from Jeffwan/mixed_instance_policy
Add MixedInstancesPolicy struct to better handle instance type
2019-08-26 02:40:20 -07:00
Łukasz Piątkowski 8d9b81caaa correctly handle lack of capacity of AWS spot ASGs 2019-08-19 12:43:53 +02:00
Jiaxin Shan 8d567eb102 Add MixedInstancesPolicy struct to better handle instance type
Ensures that when MixedInstancePolicy is used in an AWS AutoScalingGroup, that
the buildInstanceType() AWS manager method returns an instance type after looking
at the MixedInstancePolicy.LaunchTemplateSpecification. The buildInstanceType()
method is called in numerous places including on cluster scale up actions.

Also adds documentation highlighting the minimum version of cluster autoscaler
supporting MixedInstancePolicy is 1.14
2019-08-15 14:40:11 -07:00
Łukasz Osipiuk 738ce84c2e Update gofmt 2019-06-06 20:35:16 +02:00
Łukasz Osipiuk cba6582fe1 Use k8s.io/legacy-cloud-providers 2019-06-06 20:27:27 +02:00
Yago Nobre d35f797c4a
Add cache to getInstanceTypeByLCName for avoid aws rate limit 2019-04-20 00:33:03 -03:00
Jiaxin Shan 0d84968d56 Update aws RefreshInterval to 1 minute 2019-03-29 00:21:14 -07:00
ampsingram c9832b83f5 Allow custom AWS region overrides #1707
Replicated changes from kubernetes "Add AWS Custom Endpoint capability #70588" into cluster-autoscaler:

- Modified aws_manager snd aws_manager_test similar to kubernetes aws and aws_test.
2019-03-07 11:32:26 -05:00
Pengfei Ni 2546d0d97c Move leaderelection options to new packages 2019-02-21 13:45:46 +08:00
Niels-Ole Kühl f79a432693 Adding ability to override allocatable resources via ASG tags. Fixes #1650 2019-02-11 09:06:58 +01:00
Marcin Wielgus 99f1dcf9d2
Merge branch 'master' into crc-fix-error-format 2019-02-01 17:22:57 +01:00
CodeLingo Bot c0603afdeb Fix error format strings according to best practices from CodeReviewComments
Fix error format strings according to best practices from CodeReviewComments

Fix error format strings according to best practices from CodeReviewComments

Reverted incorrect change to with error format string

Signed-off-by: CodeLingo Bot <hello@codelingo.io>
Signed-off-by: CodeLingoBot <hello@codelingo.io>
Signed-off-by: CodeLingo Bot <hello@codelingo.io>
Signed-off-by: CodeLingo Bot <bot@codelingo.io>

Resolve conflict

Signed-off-by: CodeLingo Bot <hello@codelingo.io>
Signed-off-by: CodeLingoBot <hello@codelingo.io>
Signed-off-by: CodeLingo Bot <hello@codelingo.io>
Signed-off-by: CodeLingo Bot <bot@codelingo.io>

Fix error strings in testscases to remedy failing tests

Signed-off-by: CodeLingo Bot <bot@codelingo.io>

Fix more error strings to remedy failing tests

Signed-off-by: CodeLingo Bot <bot@codelingo.io>
2019-01-11 09:10:31 +13:00
Shatil Rafiullah 05e61ad4fc Set AWS_REGION so tests don't wait for SDK timeout #1449
This patch sets and then resets the `AWS_REGION` environment variable in
tests that call `createAWSManagerInternal`, which calls `getRegion`.

`getRegion` introduced `AWS_REGION` lookup at runtime, but tests that
don't (a) run inside AWS or (b) set `AWS_REGION` environment variable
encountered AWS SDK's EC2 Metadata lookup timeout. Tests that indirectly
invoked `getRegion`, e.g., via `createAWSManagerInternal`, saw at least
a 5-second timeout per invocation, ballooning test times.
2018-12-07 09:09:37 -08:00
Łukasz Osipiuk 016bf7fc2c Use k8s.io/klog instead github.com/golang/glog 2018-11-26 17:30:31 +01:00
Steve Harris c41951108c Report ASGs using unknown AWS EC2 instance types 2018-11-20 13:28:33 -05:00
Johannes Würbach 14120a43ff
AWS: Improved balancing 2018-11-06 22:38:47 +01:00
Shatil Rafiullah a36f8007af Read AWS Region from EC2 Metadata
Tackles kubernetes/autoscaler#1208. EC2 Metadata helpfully supplies AWS
Region info, so rather than _requiring_ an environment variable, this
patch enables `aws_manager.go` to retrieve that information from EC2
itself.

Example YAMLs no longer reference the vestigial `AWS_REGION` environment
variable, but supplying it to `cluster-autoscaler` still relays it to
the AWS SDK like before.
2018-09-28 22:45:34 -07:00
Johannes Würbach e29bddc483
Fetch ASG names in chunks of 50 2018-09-20 12:18:41 +02:00
Sheldon Kwok b942eec809 Add test for building aws asg instance type with launch templates 2018-07-17 02:54:35 -07:00
Sheldon Kwok 4bd79c8353 Add EC2 Launch Template handler for ASG instanceType fetching 2018-07-17 02:54:35 -07:00
Lee Briggs 5b023650b9 Validate taint key with regex (#1005)
* Validate taint key with regex

Before attempting to perform a split on the tag value, validate it
matches the format <tag>:NoSchedule

This should prevent invalid tag keys from causing the autoscaler to
panic and crash

* Further taint validation

Also add test cases for valid taint methods
2018-06-28 11:46:20 +02:00
Johannes Würbach 0598749d76
AWS: Reduce amount of API calls
Instead of doing auto-discovery, nodes per ASG and target size per ASG separately, fetch all
of those ASG details in a single request on each Refresh() with maximum 10 seconds granularity.
2018-05-21 10:31:03 +02:00
Johannes 'fish' Ziemke f1b71ddc07 AWS: Support selecting ASG by values 2018-04-10 16:11:46 +02:00
Johannes 'fish' Ziemke 4eb83911df Fix nvidia gpu resource name on AWS 2018-02-13 16:00:17 +01:00
Nic Cope e96ff07896 Replace the Polling Autoscaler
Node group discovery is now handled by cloudprovider.Refresh() in all cases.
Additionally, explicit node groups can now be used alongside autodiscovery.
2017-12-11 13:09:56 -08:00
mmerrill3 77aa30a5c1 Fixing for issue 252 by implementing a channel to stop the go routine 2017-11-01 11:00:00 -04:00
Seth Pollack d87a3e8615 add gpu to node template 2017-09-10 12:25:51 -04:00
Seth Pollack c3b86378a2
add taints to AWS node template 2017-07-20 22:07:20 -04:00
Seth Pollack 314ed88b14
Enable min size 0 in aws 2017-07-10 09:04:18 -04:00
Yusuke Kuoka dfb481b19f cluster-autoscaler: Fix excessive calls to DescribeAutoScalingGroup
By caching AWS refs for nodes/EC2 instances already known to be not in any of ASGs managed by cluster-autoscaler(CA).

Please beware of the edge case - this method is safe as long as users don't attach nodes by calling AttachInstances API after CA cached them. I believe, even if it was necessary, a warning in the documentation about the edge case is enough for now. If we really need to support the case, I will submit an another PR to invalidate the cache periodically so that CA can detect the formerly cached nodes are attached to ASG(s).

Also refactor AwsManager for less complexity by extracting types, accordingly to the discussion made [here](https://github.com/kubernetes/autoscaler/pull/46#discussion_r117912687)
2017-06-22 16:55:15 +09:00
Yusuke Kuoka 3e8cc02243 cluster-autoscaler: Fix node group auto discovery for AWS not to mix up ASGs from different k8s clusters 2017-06-22 15:59:53 +09:00
Yusuke Kuoka e9c7cd0733 cluster-autoscaler: Re: AWS Autoscaler autodiscover ASG names and sizes
This is an alternative implementation of https://github.com/kubernetes/contrib/pull/1982

Notable differences from the original PR are:

* A new flag named `--node-group-auto-discovery` is introduced for opting in to enable the auto-discovery feature.
  * For example, specifying `--cloud-provider aws --node-group-auto-discovery asg:tag=k8s.io/cluster-autoscaler/enabled` instructs CA to auto-discover ASGs tagged with `k8s.io/cluster-autoscaler/enabled` to be used as target node groups
* The new code path introduced by this PR is executed only when `node-group-auto-discovery` is specified. There is relatively less chance to break existing features by introducing this change

Resolves https://github.com/kubernetes/contrib/issues/1956

---

Other notes:

* We rely mainly on the `DescribeTags` API rather than `DescribeAutoScalingGroups` so that AWS can filter out unnecessary ASGs which doesn't belong to the k8s cluster, for us.
  * If we relied on `DescribeAutoScalingGroups` here, as it doesn't support `Filter`ing, we'd need to iterate over ALL the ASGs available in an AWS account, which isn't desirable due to unnecessary excessive API calls and network usages

* Update cloudprovider/aws/README for the new configuration

* Warn abount invalid combination of flags
according to the review comment https://github.com/kubernetes/autoscaler/pull/11#discussion_r113713138

* Emit a validation error when both --nodes and --node-group-auto-discovery are specified
according to the review comment https://github.com/kubernetes/autoscaler/pull/11#discussion_r113958080

TODO/Possible future improvements before recommending this to everyone:

* Cache the result of an auto-discovery for a configurable period, so that we won't invoke DescribeTags and DescribeAutoScalingGroup APIs too many times
2017-05-10 08:36:02 +09:00
Phil Kates c2cb357e7d Return correct ProviderID format from GetAsgNodes
This matches the way that the [gce does it][1] and fixes issues with the
[cluster state][2].

1: https://github.com/kubernetes/contrib/blob/master/cluster-autoscaler/cloudprovider/gce/gce_manager.go#L247
2: https://github.com/kubernetes/contrib/issues/2228#issuecomment-274896211
2017-02-21 12:06:12 -08:00
Marcin Wielgus ce45c33d29 Cluster-autoscaler: update CA code for godep refresh 2017-01-20 14:46:34 +01:00
Marcin Wielgus cfc1117a17 Cluster-autoscaler: decrease target size function in cloud provider interface 2017-01-16 15:20:45 +01:00
Marcin Wielgus be796d8218 Cluster-autoscaler: add get nodes function to cloud provider interface 2017-01-04 13:23:57 +01:00
Marcin Wielgus 7b63b6c1f1 Cluster-autoscaler: update code to compile with K8S 1.5 2016-12-13 17:22:57 +01:00
andrewsykim bc6cac07c0 return nil if node is not in an ASG managed by CA 2016-09-12 13:44:29 -04:00
Jan Chaloupka e028312170 Remove "All rights reserved" from all the headers 2016-09-08 13:02:39 +02:00
osxi ebfc2b989f Cluster-autoscaler: cloud provider interface implementation for AWS 2016-08-16 16:37:53 -05:00