Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ _Note: Since this module manages all of the Kubernetes addon dependencies requir
| <a name="input_map_additional_iam_roles"></a> [map\_additional\_iam\_roles](#input\_map\_additional\_iam\_roles) | A list of IAM role bindings to add to the aws-auth ConfigMap. | <pre>list(object({<br/> rolearn = string<br/> username = string<br/> groups = list(string)<br/> }))</pre> | `[]` | no |
| <a name="input_node_groups"></a> [node\_groups](#input\_node\_groups) | Map of EKS managed node group definitions to create | `any` | `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_ami_type"></a> [node\_pool\_ami\_type](#input\_node\_pool\_ami\_type) | Type of Amazon Machine Image (AMI) associated with the EKS Node Group. See the [AWS documentation](https://docs.aws.amazon.com/eks/latest/APIReference/API_Nodegroup.html#AmazonEKS-Type-Nodegroup-amiType) for valid values | `string` | `null` | 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_capacity_type"></a> [node\_pool\_capacity\_type](#input\_node\_pool\_capacity\_type) | The capacity type for the node group. Defaults to "ON\_DEMAND". If set to "SPOT", the node group will be a spot instance node group. | `string` | `"ON_DEMAND"` | 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 |
Expand Down
53 changes: 26 additions & 27 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,23 @@ locals {
node_group_iam_role_arn = replace(aws_iam_role.ng.arn, replace(var.iam_path, "/^//", ""), "") # Work around for https://github.com/kubernetes-sigs/aws-iam-authenticator/issues/153

node_group_defaults = {
create_security_group = false
ami_id = var.node_pool_ami_id
create_iam_role = false # We create the IAM role ourselves to reduce complexity in managing the aws-auth configmap
iam_role_arn = local.node_group_iam_role_arn

ami_type = var.node_pool_ami_type
capacity_type = var.node_pool_capacity_type
desired_size = var.node_pool_desired_size
min_size = var.node_pool_min_size
max_size = var.node_pool_max_size
update_config = {
max_unavailable = 1
}

create_launch_template = true
ami_id = var.node_pool_ami_id
ebs_optimized = var.node_pool_ebs_optimized
pre_bootstrap_user_data = var.node_pool_pre_userdata
enable_monitoring = var.enable_node_pool_monitoring
block_device_mappings = {
xvda = {
device_name = "/dev/xvda"
Expand All @@ -87,20 +102,8 @@ locals {
}
}
}
update_config = {
max_unavailable = 1
}
create_iam_role = false # We create the IAM role ourselves to reduce complexity in managing the aws-auth configmap
iam_role_arn = local.node_group_iam_role_arn
create_launch_template = true
desired_size = var.node_pool_desired_size
ebs_optimized = var.node_pool_ebs_optimized
enable_monitoring = var.enable_node_pool_monitoring
capacity_type = var.node_pool_capacity_type
min_size = var.node_pool_min_size
max_size = var.node_pool_max_size
pre_bootstrap_user_data = var.node_pool_pre_userdata
taints = local.node_pool_taints

taints = local.node_pool_taints
tags = merge(var.node_pool_tags, local.tags, {
"k8s.io/cluster-autoscaler/enabled" = "true",
format("k8s.io/cluster-autoscaler/%s", var.cluster_name) = "owned",
Expand Down Expand Up @@ -138,15 +141,11 @@ locals {

v3_node_groups = {
"snc-core" = {
subnet_ids = local.node_group_subnet_ids
instance_types = [var.v3_node_group_core_instance_type]
capacity_type = var.node_pool_capacity_type
name = "snc-core"
use_name_prefix = true
instance_types = [var.v3_node_group_core_instance_type]
subnet_ids = local.node_group_subnet_ids
taints = local.v3_node_taints
desired_size = var.node_pool_desired_size
min_size = var.node_pool_min_size
max_size = var.node_pool_max_size
labels = tomap(merge(var.node_pool_labels, {
"cloud.streamnative.io/instance-type" = "Small"
"cloud.streamnative.io/instance-group" = "Core"
Expand All @@ -155,12 +154,12 @@ locals {
}

node_groups = var.enable_v3_node_migration ? merge(local.v3_node_groups, local.v2_node_groups) : var.enable_v3_node_groups ? local.v3_node_groups : local.v2_node_groups
defaulted_node_groups = var.node_groups != null ? {
for k, v in var.node_groups : k => merge(
v,
contains(keys(v), "subnet_ids") ? {} : { "subnet_ids" = local.node_group_subnet_ids },
defaulted_node_groups = {
for k in try(keys(var.node_groups), []) : k => merge(
lookup(local.v3_node_groups, k, {}),
var.node_groups[k]
)
} : {}
}
eks_managed_node_groups = [local.defaulted_node_groups, local.node_groups][var.node_groups != null ? 0 : 1]

## Node Security Group Configuration
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ variable "node_pool_ami_id" {
type = string
}

variable "node_pool_ami_type" {
type = string
default = null
description = "Type of Amazon Machine Image (AMI) associated with the EKS Node Group. See the [AWS documentation](https://docs.aws.amazon.com/eks/latest/APIReference/API_Nodegroup.html#AmazonEKS-Type-Nodegroup-amiType) for valid values"
}

variable "node_pool_disk_iops" {
default = 3000
description = "The amount of provisioned IOPS for the worker node root EBS volume."
Expand Down
Loading