-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Enable autoscaling and install required ancillary tooling to s…
…upport it (#257) * feat!: add autoscaling to terraform modules and change variable lookup order for instance sizing * feat!: add cluster autoscaler to cluster BREAKING CHANGE: A number of variable defaults are removed and variables renamed for node counts.
- Loading branch information
1 parent
47b06e1
commit 8d48434
Showing
12 changed files
with
274 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"autoscaling:DescribeAutoScalingGroups", | ||
"autoscaling:DescribeAutoScalingInstances", | ||
"autoscaling:DescribeLaunchConfigurations", | ||
"autoscaling:DescribeScalingActivities", | ||
"ec2:DescribeImages", | ||
"ec2:DescribeInstanceTypes", | ||
"ec2:DescribeLaunchTemplateVersions", | ||
"ec2:GetInstanceTypesFromInstanceRequirements", | ||
"eks:DescribeNodegroup" | ||
], | ||
"Resource": ["*"] | ||
}, | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"autoscaling:SetDesiredCapacity", | ||
"autoscaling:TerminateInstanceInAutoScalingGroup" | ||
], | ||
"Resource": ["*"], | ||
"Condition": { | ||
"StringEquals": { | ||
"aws:ResourceTag/k8s.io/cluster-autoscaler/enabled": "true", | ||
"aws:ResourceTag/k8s.io/cluster-autoscaler/${namespace}": "owned" | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
data "aws_region" "current" {} | ||
|
||
resource "helm_release" "cluster-autoscaler" { | ||
chart = "cluster-autoscaler" | ||
name = "cluster-autoscaler" | ||
repository = "https://kubernetes.github.io/autoscaler" | ||
namespace = "cluster-autoscaler" | ||
create_namespace = true | ||
|
||
set { | ||
name = "fullnameOverride" | ||
value = "cluster-autoscaler" | ||
} | ||
|
||
set { | ||
name = "autoDiscovery.clusterName" | ||
value = var.namespace | ||
} | ||
|
||
set { | ||
name = "awsRegion" | ||
value = data.aws_region.current.name | ||
} | ||
|
||
set { | ||
name = "rbac.serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn" | ||
value = aws_iam_role.default.arn | ||
} | ||
|
||
set { | ||
name = "extraArgs.balance-similar-node-groups" | ||
value = "true" | ||
} | ||
|
||
set { | ||
name = "extraArgs.balancing-ignore-label" | ||
value = "eks.amazonaws.com/nodegroup" | ||
} | ||
|
||
set { | ||
name = "extraArgs.balancing-ignore-label" | ||
value = "eks.amazonaws.com/sourceLaunchTemplateId" | ||
} | ||
|
||
set { | ||
name = "extraArgs.balancing-ignore-label" | ||
value = "topology.ebs.csi.aws.com/zone" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
data "aws_iam_policy_document" "default" { | ||
statement { | ||
actions = ["sts:AssumeRoleWithWebIdentity"] | ||
effect = "Allow" | ||
|
||
condition { | ||
test = "StringLike" | ||
variable = "${replace(var.oidc_provider.url, "https://", "")}:sub" | ||
values = ["system:serviceaccount:cluster-autoscaler:*"] | ||
} | ||
|
||
principals { | ||
identifiers = [var.oidc_provider.arn] | ||
type = "Federated" | ||
} | ||
} | ||
} | ||
|
||
resource "aws_iam_role" "default" { | ||
assume_role_policy = data.aws_iam_policy_document.default.json | ||
name = "${var.namespace}-cluster-autoscaler" | ||
} | ||
|
||
resource "aws_iam_policy" "default" { | ||
policy = templatefile("${path.module}/ClusterAutoscaler.json", { namespace = var.namespace }) | ||
name = "${var.namespace}-cluster-autoscaler" | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "default" { | ||
role = aws_iam_role.default.name | ||
policy_arn = aws_iam_policy.default.arn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
variable "namespace" { | ||
type = string | ||
} | ||
|
||
variable "oidc_provider" { | ||
type = object({ | ||
arn = string | ||
url = string | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.