Skip to content

Commit

Permalink
feat: Support single zone node_group (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciiiii authored May 21, 2024
1 parent 4c1b508 commit 8038bdf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ _Note: Since this module manages all of the Kubernetes addon dependencies requir

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.49.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >=3.61.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.2.0 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.16.1 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >=2.6.1 |

## Modules

Expand Down Expand Up @@ -334,6 +334,7 @@ _Note: Since this module manages all of the Kubernetes addon dependencies requir
| <a name="input_migration_mode"></a> [migration\_mode](#input\_migration\_mode) | Whether to enable migration mode for the cluster. This is used to migrate details from existing security groups, which have had their names and description changed in versions v18.X of the community EKS module. | `bool` | `false` | no |
| <a name="input_migration_mode_node_sg_name"></a> [migration\_mode\_node\_sg\_name](#input\_migration\_mode\_node\_sg\_name) | The name (not ID!) of the existing security group used by worker nodes. This is required when "migration\_mode" is set to "true", otherwise the parent module will attempt to set a new security group name and destroy the existin one. | `string` | `null` | no |
| <a name="input_node_pool_ami_id"></a> [node\_pool\_ami\_id](#input\_node\_pool\_ami\_id) | The AMI ID to use for the EKS cluster nodes. Defaults to the latest EKS Optimized AMI provided by AWS. | `string` | `""` | no |
| <a name="input_node_pool_azs"></a> [node\_pool\_azs](#input\_node\_pool\_azs) | A list of availability zones to use for the EKS node group. If not set, the module will use the same availability zones with the cluster. | `list(string)` | `[]` | no |
| <a name="input_node_pool_block_device_name"></a> [node\_pool\_block\_device\_name](#input\_node\_pool\_block\_device\_name) | The name of the block device to use for the EKS cluster nodes. | `string` | `"/dev/nvme0n1"` | no |
| <a name="input_node_pool_desired_size"></a> [node\_pool\_desired\_size](#input\_node\_pool\_desired\_size) | Desired number of worker nodes in the node pool. | `number` | `0` | no |
| <a name="input_node_pool_disk_iops"></a> [node\_pool\_disk\_iops](#input\_node\_pool\_disk\_iops) | The amount of provisioned IOPS for the worker node root EBS volume. | `number` | `3000` | no |
Expand Down Expand Up @@ -397,6 +398,7 @@ _Note: Since this module manages all of the Kubernetes addon dependencies requir
| <a name="output_eks_node_group_security_group_id"></a> [eks\_node\_group\_security\_group\_id](#output\_eks\_node\_group\_security\_group\_id) | Security group ID attached to the EKS node groups |
| <a name="output_eks_node_groups"></a> [eks\_node\_groups](#output\_eks\_node\_groups) | Map of all attributes of the EKS node groups created by this module |
| <a name="output_external_dns_arn"></a> [external\_dns\_arn](#output\_external\_dns\_arn) | The ARN for External DNS |
| <a name="output_inuse_azs"></a> [inuse\_azs](#output\_inuse\_azs) | The availability zones in which the EKS nodes is deployed |
| <a name="output_tiered_storage_s3_bucket_arn"></a> [tiered\_storage\_s3\_bucket\_arn](#output\_tiered\_storage\_s3\_bucket\_arn) | The ARN for the tiered storage S3 bucket created by this module |
| <a name="output_velero_arn"></a> [velero\_arn](#output\_velero\_arn) | ARN for Velero |
| <a name="output_velero_s3_bucket_arn"></a> [velero\_s3\_bucket\_arn](#output\_velero\_s3\_bucket\_arn) | The ARN for the Velero S3 bucket created by this module |
Expand Down
14 changes: 12 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ data "aws_subnet" "private_subnets" {
id = var.private_subnet_ids[count.index]
}

data "aws_subnet" "public_subnets" {
count = length(var.public_subnet_ids)
id = var.public_subnet_ids[count.index]
}

data "aws_kms_key" "ebs_default" {
key_id = "alias/aws/ebs"
}
Expand All @@ -38,7 +43,12 @@ locals {
default_service_policy_arn = "arn:${local.aws_partition}:iam::${local.account_id}:policy/StreamNative/StreamNativeCloudRuntimePolicy"
ebs_kms_key = var.disk_encryption_kms_key_arn == "" ? data.aws_kms_key.ebs_default.arn : var.disk_encryption_kms_key_arn
oidc_issuer = trimprefix(module.eks.cluster_oidc_issuer_url, "https://")
nodes_subnet_ids = var.enable_nodes_use_public_subnet ? var.public_subnet_ids : var.private_subnet_ids

nodes_available_subnets = var.enable_nodes_use_public_subnet ? data.aws_subnet.public_subnets : data.aws_subnet.private_subnets
node_group_subnets = length(var.node_pool_azs) != 0 ? [
for index, subnet in local.nodes_available_subnets : subnet if contains(var.node_pool_azs, subnet.availability_zone)
] : local.nodes_available_subnets
node_group_subnet_ids = [for index, subnet in local.node_group_subnets : subnet.id]

tags = merge(
{
Expand Down Expand Up @@ -134,7 +144,7 @@ locals {

v3_node_groups = tomap({
"snc-core" = {
subnet_ids = local.nodes_subnet_ids
subnet_ids = local.node_group_subnet_ids
instance_types = [var.v3_node_group_core_instance_type]
name = "snc-core"
taints = local.v3_node_taints
Expand Down
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ output "eks" {
value = module.eks
description = "All outputs of module.eks for provide convenient approach to access child module's outputs."
}

output "inuse_azs" {
value = distinct([for index, subnet in local.node_group_subnets : subnet.availability_zone])
description = "The availability zones in which the EKS nodes is deployed"
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ variable "node_pool_instance_types" {
type = list(string)
}

variable "node_pool_azs" {
type = list(string)
description = "A list of availability zones to use for the EKS node group. If not set, the module will use the same availability zones with the cluster."
default = []
}

variable "node_pool_labels" {
default = {}
description = "A map of kubernetes labels to add to the node pool."
Expand Down

0 comments on commit 8038bdf

Please sign in to comment.