I have a EKS Cluster with a Node Group that is configured with launch template. All of the resources are created with Terraform.
launch_template.tf
;
resource "aws_launch_template" "launch-template" {
name = var.name
update_default_version = var.update_default_version
instance_type = var.instance_type
key_name = var.key_name
block_device_mappings {
device_name = var.block_device_name
ebs {
volume_size = var.volume_size
}
}
ebs_optimized = var.ebs_optimized
monitoring {
enabled = var.monitoring_enabled
}
dynamic "tag_specifications" {
for_each = toset(var.resources_to_tag)
content {
resource_type = tag_specifications.key
tags = var.tags
}
}
}
eks_nodegroup.tf
;
resource "aws_eks_node_group" "eks-nodegroup" {
cluster_name = var.cluster_name
node_group_name = var.node_group_name
node_role_arn = var.node_role_arn
subnet_ids = var.subnet_ids
labels = var.labels
tags = var.tags
scaling_config {
desired_size = var.desired_size
max_size = var.max_size
min_size = var.min_size
}
launch_template {
id = var.launch_template_id
version = var.launch_template_version
}
}
These resources are binding each other. But at the end of the day,
this setup is creating
- 2 launch templates,
- 1 autoscaling group
- 2 volumes for each instance in autoscaling group.
I understood from this question that, because I’m using aws_launch_template
resource with aws_eks_node_group
; second launch template is being created. But I didn’t understand where the second volume is coming from for each instance. One of the volumes fits my configuration which has 40 GB
capacity, path is /dev/sda1
and IOPS
is 120. But the second one has 20 GB
capacity, path is /dev/xvda
and IOPS
is 100. I don’t have any configuration like this in my Terraform structure.
I didn’t find where is the source of the second volume. Any guidance will be highly appreciated, Thank you very much.
2
Answers
Your second volume is being created based on the default volume for the
aws_eks_node_group
. Thedisk_size
parameter is set by default to 20 GB.The
disk_size
parameter is not configurable when using a launch template. It will cause an error if configured.I suspect you may be using a Bottlerocket AMI which comes with two volumes. One is the OS volume and the second is the data volume. You likely want to configure the data volume size which is exposed at
/dev/xvdb
by default.See https://github.com/bottlerocket-os/bottlerocket#default-volumes