Skip to content

Commit

Permalink
Adds node region and zone topology labels to autoscaler template (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
errm authored Sep 18, 2020
1 parent 17adf6c commit 749963d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions modules/asg_node_group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ data "aws_ami" "image" {
}
}

data "aws_region" "current" {}

data "template_file" "cloud_config" {
template = file("${path.module}/cloud_config.tpl")
vars = {
Expand Down Expand Up @@ -141,6 +143,39 @@ resource "aws_autoscaling_group" "nodes" {
propagate_at_launch = true
}

dynamic "tag" {
for_each = var.cluster_config.aws_ebs_csi_driver ? { "k8s.io/cluster-autoscaler/node-template/label/topology.ebs.csi.aws.com/zone" = each.key } : {}
content {
key = tag.key
value = tag.value
propagate_at_launch = false
}
}

tag {
key = "k8s.io/cluster-autoscaler/node-template/label/topology.kubernetes.io/zone"
value = each.key
propagate_at_launch = false
}

tag {
key = "k8s.io/cluster-autoscaler/node-template/label/failure-domain.beta.kubernetes.io/zone"
value = each.key
propagate_at_launch = false
}

tag {
key = "k8s.io/cluster-autoscaler/node-template/label/topology.kubernetes.io/region"
value = data.aws_region.current.name
propagate_at_launch = false
}

tag {
key = "k8s.io/cluster-autoscaler/node-template/label/topology.kubernetes.io/region"
value = data.aws_region.current.name
propagate_at_launch = false
}

dynamic "tag" {
for_each = local.labels
content {
Expand Down
1 change: 1 addition & 0 deletions modules/asg_node_group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ variable "cluster_config" {
node_instance_profile = string
tags = map(string)
dns_cluster_ip = string
aws_ebs_csi_driver = bool
})
}

Expand Down
1 change: 1 addition & 0 deletions modules/cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ locals {
node_instance_profile = var.iam_config.node_role
tags = var.tags
dns_cluster_ip = local.dns_cluster_ip
aws_ebs_csi_driver = var.aws_ebs_csi_driver
}
}

Expand Down

0 comments on commit 749963d

Please sign in to comment.