diff --git a/README.md b/README.md index f3701b1..19cd65e 100644 --- a/README.md +++ b/README.md @@ -152,12 +152,14 @@ Optional policies have the option of being created by default, but are specified | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | ami | Server pool ami | `string` | n/a | yes | -| block\_device\_mappings | Server pool block device mapping configuration | `map(string)` |
{
"encrypted": false,
"size": 30
}
| no || cluster\_name | Name of the rkegov cluster to create | `string` | n/a | yes | +| block\_device\_mappings | Server pool block device mapping configuration | `map(string)` |
{
"encrypted": false,
"size": 30
}
| no | +| cluster\_name | Name of the rkegov cluster to create | `string` | n/a | yes | | controlplane\_allowed\_cidrs | Server pool security group allowed cidr ranges | `list(string)` |
[
"0.0.0.0/0"
]
| no | | controlplane\_enable\_cross\_zone\_load\_balancing | Toggle between controlplane cross zone load balancing | `bool` | `true` | no | | controlplane\_internal | Toggle between public or private control plane load balancer | `bool` | `true` | no | | download | Toggle best effort download of rke2 dependencies (rke2 and aws cli), if disabled, dependencies are assumed to exist in $PATH | `bool` | `true` | no | | enable\_ccm | Toggle enabling the cluster as aws aware, this will ensure the appropriate IAM policies are present | `bool` | `false` | no | +| extra\_block\_device\_mappings | Additional server pool block device mappings configuration | `list(map(string))` | `[]` | no | | iam\_instance\_profile | Server pool IAM Instance Profile, created if left blank (default behavior) | `string` | `""` | no | | iam\_permissions\_boundary | If provided, the IAM role created for the servers will be created with this permissions boundary attached. | `string` | `null` | no | | extra\_security\_group\_ids | List of additional security group IDs | `list(string)` | `[]` | no | diff --git a/main.tf b/main.tf index 31765b0..c4720f7 100644 --- a/main.tf +++ b/main.tf @@ -178,14 +178,15 @@ module "servers" { source = "./modules/nodepool" name = "${local.uname}-server" - vpc_id = var.vpc_id - subnets = var.subnets - ami = var.ami - instance_type = var.instance_type - block_device_mappings = var.block_device_mappings - vpc_security_group_ids = concat([aws_security_group.server.id, aws_security_group.cluster.id], var.extra_security_group_ids) - spot = var.spot - load_balancers = [module.cp_lb.name] + vpc_id = var.vpc_id + subnets = var.subnets + ami = var.ami + instance_type = var.instance_type + block_device_mappings = var.block_device_mappings + extra_block_device_mappings = var.extra_block_device_mappings + vpc_security_group_ids = concat([aws_security_group.server.id, aws_security_group.cluster.id], var.extra_security_group_ids) + spot = var.spot + load_balancers = [module.cp_lb.name] # Overrideable variables userdata = data.template_cloudinit_config.this.rendered diff --git a/modules/agent-nodepool/README.md b/modules/agent-nodepool/README.md index 08c9a6b..27b3231 100644 --- a/modules/agent-nodepool/README.md +++ b/modules/agent-nodepool/README.md @@ -14,6 +14,7 @@ | cluster\_data | Required data relevant to joining an existing rke2 cluster, sourced from main rke2 module, do NOT modify |
object({
name = string
server_url = string
cluster_sg = string
token = object({
bucket = string
bucket_arn = string
object = string
policy_document = string
})
})
| n/a | yes | | enable\_autoscaler | Toggle configure the nodepool for cluster autoscaler, this will ensure the appropriate IAM policies are present, you are still responsible for ensuring cluster autoscaler is installed | `bool` | `false` | no | | enable\_ccm | Toggle enabling the cluster as aws aware, this will ensure the appropriate IAM policies are present | `bool` | `false` | no | +| extra\_block\_device\_mappings | Additional node pool block device mappings configuration | `list(map(string))` | `[]` | no | | extra\_security\_group\_ids | List of additional security group IDs | `list(string)` | `[]` | no | | iam\_instance\_profile | Node pool IAM Instance Profile, created if node specified | `string` | `""` | no | | instance\_type | Node pool instance type | `string` | `"t3.medium"` | no | diff --git a/modules/agent-nodepool/main.tf b/modules/agent-nodepool/main.tf index 69e115d..10dd62e 100644 --- a/modules/agent-nodepool/main.tf +++ b/modules/agent-nodepool/main.tf @@ -109,16 +109,17 @@ module "nodepool" { source = "../nodepool" name = "${local.name}-agent" - vpc_id = var.vpc_id - subnets = var.subnets - ami = var.ami - instance_type = var.instance_type - block_device_mappings = var.block_device_mappings - vpc_security_group_ids = concat([var.cluster_data.cluster_sg], var.extra_security_group_ids) - userdata = data.template_cloudinit_config.init.rendered - iam_instance_profile = var.iam_instance_profile == "" ? module.iam[0].iam_instance_profile : var.iam_instance_profile - asg = var.asg - spot = var.spot + vpc_id = var.vpc_id + subnets = var.subnets + ami = var.ami + instance_type = var.instance_type + block_device_mappings = var.block_device_mappings + extra_block_device_mappings = var.extra_block_device_mappings + vpc_security_group_ids = concat([var.cluster_data.cluster_sg], var.extra_security_group_ids) + userdata = data.template_cloudinit_config.init.rendered + iam_instance_profile = var.iam_instance_profile == "" ? module.iam[0].iam_instance_profile : var.iam_instance_profile + asg = var.asg + spot = var.spot tags = merge({ "Role" = "agent", diff --git a/modules/agent-nodepool/variables.tf b/modules/agent-nodepool/variables.tf index 221044e..0815274 100644 --- a/modules/agent-nodepool/variables.tf +++ b/modules/agent-nodepool/variables.tf @@ -61,6 +61,13 @@ variable "block_device_mappings" { } } +variable "extra_block_device_mappings" { + description = "Used to specify additional block device mapping configurations" + type = list(map(string)) + default = [ + ] +} + variable "asg" { description = "Node pool AutoScalingGroup scaling definition" type = object({ diff --git a/modules/nodepool/main.tf b/modules/nodepool/main.tf index 8a5205a..47aa618 100644 --- a/modules/nodepool/main.tf +++ b/modules/nodepool/main.tf @@ -29,6 +29,21 @@ resource "aws_launch_template" "this" { } } + dynamic "block_device_mappings" { + for_each = var.extra_block_device_mappings + content { + device_name = lookup(block_device_mappings.value, "device_name", "null") + ebs { + volume_type = lookup(block_device_mappings.value, "type", null) + volume_size = lookup(block_device_mappings.value, "size", null) + iops = lookup(block_device_mappings.value, "iops", null) + kms_key_id = lookup(block_device_mappings.value, "kms_key_id", null) + encrypted = lookup(block_device_mappings.value, "encrypted", null) + delete_on_termination = lookup(block_device_mappings.value, "delete_on_termination", null) + } + } + } + iam_instance_profile { name = var.iam_instance_profile } diff --git a/modules/nodepool/variables.tf b/modules/nodepool/variables.tf index c1c7648..6e9b01e 100644 --- a/modules/nodepool/variables.tf +++ b/modules/nodepool/variables.tf @@ -63,6 +63,12 @@ variable "block_device_mappings" { } } +variable "extra_block_device_mappings" { + type = list(map(string)) + default = [ + ] +} + variable "asg" { type = object({ min = number diff --git a/variables.tf b/variables.tf index 155909a..2d0b7f2 100644 --- a/variables.tf +++ b/variables.tf @@ -54,6 +54,13 @@ variable "block_device_mappings" { } } +variable "extra_block_device_mappings" { + description = "Used to specify additional block device mapping configurations" + type = list(map(string)) + default = [ + ] +} + variable "servers" { description = "Number of servers to create" type = number @@ -136,4 +143,4 @@ variable "enable_ccm" { description = "Toggle enabling the cluster as aws aware, this will ensure the appropriate IAM policies are present" type = bool default = false -} \ No newline at end of file +}