Commit 61582a85 authored by Chris Merrett's avatar Chris Merrett

Added support for cluster-autoscaler

parent 398489fd
Pipeline #5377 passed with stage
in 16 seconds
......@@ -68,6 +68,24 @@ data "aws_iam_policy_document" "admin_assumerole" {
}
}
data "aws_iam_policy_document" "workers_autoscaling" {
statement {
effect = "Allow"
actions = [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeTags",
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:DescribeLaunchConfigurations",
"ec2:DescribeLaunchTemplateVersions",
]
resources = ["*"]
}
}
data "template_file" "kubeconfig" {
template = "${file("${path.module}/templates/kubeconfig.tpl")}"
......
......@@ -28,6 +28,18 @@ resource "aws_autoscaling_group" "workers" {
value = "owned"
propagate_at_launch = true
}
tag {
key = "k8s.io/cluster-autoscaler/enabled"
value = "true"
propagate_at_launch = true
}
tag {
key = "k8s.io/cluster-autoscaler/${var.cluster_name}"
value = ""
propagate_at_launch = true
}
}
resource "aws_security_group" "workers" {
......@@ -95,3 +107,13 @@ resource "aws_iam_instance_profile" "workers" {
name = "${var.cluster_name}-eks-workers-instance-profile"
role = "${aws_iam_role.workers.name}"
}
resource "aws_iam_policy" "workers_autoscaling" {
name = "${var.cluster_name}-eks-kubernetes-workers-autoscaling"
policy = "${data.aws_iam_policy_document.workers_autoscaling.json}"
}
resource "aws_iam_role_policy_attachment" "workers_autoscaling" {
role = "${aws_iam_role.workers.name}"
policy_arn = "${aws_iam_policy.workers_autoscaling.arn}"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment