mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-16 00:34:31 +01:00
feat: Add support for enabling EFA resources (#2936)
* feat: Add support for enabling EFA resources * feat: Add support for creating placement group and ensuring subnet ID used supports the instance type provided * chore: Update README and examples * feat: Update AWS provider MSV to support `maximum_network_cards` attribute * fix: Update self-managed example after last round of testing; improve EFA support wording
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/antonbabenko/pre-commit-terraform
|
- repo: https://github.com/antonbabenko/pre-commit-terraform
|
||||||
rev: v1.87.1
|
rev: v1.88.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: terraform_fmt
|
- id: terraform_fmt
|
||||||
- id: terraform_validate
|
- id: terraform_validate
|
||||||
|
|||||||
59
README.md
59
README.md
@@ -113,6 +113,60 @@ On clusters that were created prior to CAM support, there will be an existing ac
|
|||||||
|
|
||||||
Setting the `bootstrap_cluster_creator_admin_permissions` is a one time operation when the cluster is created; it cannot be modified later through the EKS API. In this project we are hardcoding this to `false`. If users wish to achieve the same functionality, we will do that through an access entry which can be enabled or disabled at any time of their choosing using the variable `enable_cluster_creator_admin_permissions`
|
Setting the `bootstrap_cluster_creator_admin_permissions` is a one time operation when the cluster is created; it cannot be modified later through the EKS API. In this project we are hardcoding this to `false`. If users wish to achieve the same functionality, we will do that through an access entry which can be enabled or disabled at any time of their choosing using the variable `enable_cluster_creator_admin_permissions`
|
||||||
|
|
||||||
|
### Enabling EFA Support
|
||||||
|
|
||||||
|
When enabling EFA support via `enable_efa_support = true`, there are two locations this can be specified - one at the cluster level, and one at the nodegroup level. Enabling at the cluster level will add the EFA required ingress/egress rules to the shared security group created for the nodegroup(s). Enabling at the nodegroup level will do the following (per nodegroup where enabled):
|
||||||
|
|
||||||
|
1. All EFA interfaces supported by the instance will be exposed on the launch template used by the nodegroup
|
||||||
|
2. A placement group with `strategy = "clustered"` per EFA requirements is created and passed to the launch template used by the nodegroup
|
||||||
|
3. Data sources will reverse lookup the availability zones that support the instance type selected based on the subnets provided, ensuring that only the associated subnets are passed to the launch template and therefore used by the placement group. This avoids the placement group being created in an availability zone that does not support the instance type selected.
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> Use the [aws-efa-k8s-device-plugin](https://github.com/aws/eks-charts/tree/master/stable/aws-efa-k8s-device-plugin) Helm chart to expose the EFA interfaces on the nodes as an extended resource, and allow pods to request the interfaces be mounted to their containers.
|
||||||
|
>
|
||||||
|
> The EKS AL2 GPU AMI comes with the necessary EFA components pre-installed - you just need to expose the EFA devices on the nodes via their launch templates, ensure the required EFA security group rules are in place, and deploy the `aws-efa-k8s-device-plugin` in order to start utilizing EFA within your cluster. Your application container will need to have the necessary libraries and runtime in order to utilize communication over the EFA interfaces (NCCL, aws-ofi-nccl, hwloc, libfabric, aws-neuornx-collectives, CUDA, etc.).
|
||||||
|
|
||||||
|
If you disable the creation and use of the managed nodegroup custom launch template (`create_launch_template = false` and/or `use_custom_launch_template = false`), this will interfere with the EFA functionality provided. In addition, if you do not supply an `instance_type` for self-managed nodegroup(s), or `instance_types` for the managed nodegroup(s), this will also interfere with the functionality. In order to support the EFA functionality provided by `enable_efa_support = true`, you must utilize the custom launch template created/provided by this module, and supply an `instance_type`/`instance_types` for the respective nodegroup.
|
||||||
|
|
||||||
|
The logic behind supporting EFA uses a data source to lookup the instance type to retrieve the number of interfaces that the instance supports in order to enumerate and expose those interfaces on the launch template created. For managed nodegroups where a list of instance types are supported, the first instance type in the list is used to calculate the number of EFA interfaces supported. Mixing instance types with varying number of interfaces is not recommended for EFA (or in some cases, mixing instance types is not supported - i.e. - p5.48xlarge and p4d.24xlarge). In addition to exposing the EFA interfaces and updating the security group rules, a placement group is created per the EFA requirements and only the availability zones that support the instance type selected are used in the subnets provided to the nodegroup.
|
||||||
|
|
||||||
|
In order to enable EFA support, you will have to specify `enable_efa_support = true` on both the cluster and each nodegroup that you wish to enable EFA support for:
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
module "eks" {
|
||||||
|
source = "terraform-aws-modules/eks/aws"
|
||||||
|
version = "~> 20.0"
|
||||||
|
|
||||||
|
# Truncated for brevity ...
|
||||||
|
|
||||||
|
# Adds the EFA required security group rules to the shared
|
||||||
|
# security group created for the nodegroup(s)
|
||||||
|
enable_efa_support = true
|
||||||
|
|
||||||
|
eks_managed_node_groups = {
|
||||||
|
example = {
|
||||||
|
instance_types = ["p5.48xlarge"]
|
||||||
|
|
||||||
|
# Exposes all EFA interfaces on the launch template created by the nodegroup(s)
|
||||||
|
# This would expose all 32 EFA interfaces for the p5.48xlarge instance type
|
||||||
|
enable_efa_support = true
|
||||||
|
|
||||||
|
pre_bootstrap_user_data = <<-EOT
|
||||||
|
# Mount NVME instance store volumes since they are typically
|
||||||
|
# available on instance types that support EFA
|
||||||
|
setup-local-disks raid0
|
||||||
|
EOT
|
||||||
|
|
||||||
|
# EFA should only be enabled when connecting 2 or more nodes
|
||||||
|
# Do not use EFA on a single node workload
|
||||||
|
min_size = 2
|
||||||
|
max_size = 10
|
||||||
|
desired_size = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
- [EKS Managed Node Group](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/examples/eks_managed_node_group): EKS Cluster using EKS managed node groups
|
- [EKS Managed Node Group](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/examples/eks_managed_node_group): EKS Cluster using EKS managed node groups
|
||||||
@@ -135,7 +189,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9 |
|
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9 |
|
||||||
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 3.0 |
|
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | >= 3.0 |
|
||||||
|
|
||||||
@@ -143,7 +197,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
|
|||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
| <a name="provider_time"></a> [time](#provider\_time) | >= 0.9 |
|
| <a name="provider_time"></a> [time](#provider\_time) | >= 0.9 |
|
||||||
| <a name="provider_tls"></a> [tls](#provider\_tls) | >= 3.0 |
|
| <a name="provider_tls"></a> [tls](#provider\_tls) | >= 3.0 |
|
||||||
|
|
||||||
@@ -240,6 +294,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
|
|||||||
| <a name="input_eks_managed_node_group_defaults"></a> [eks\_managed\_node\_group\_defaults](#input\_eks\_managed\_node\_group\_defaults) | Map of EKS managed node group default configurations | `any` | `{}` | no |
|
| <a name="input_eks_managed_node_group_defaults"></a> [eks\_managed\_node\_group\_defaults](#input\_eks\_managed\_node\_group\_defaults) | Map of EKS managed node group default configurations | `any` | `{}` | no |
|
||||||
| <a name="input_eks_managed_node_groups"></a> [eks\_managed\_node\_groups](#input\_eks\_managed\_node\_groups) | Map of EKS managed node group definitions to create | `any` | `{}` | no |
|
| <a name="input_eks_managed_node_groups"></a> [eks\_managed\_node\_groups](#input\_eks\_managed\_node\_groups) | Map of EKS managed node group definitions to create | `any` | `{}` | no |
|
||||||
| <a name="input_enable_cluster_creator_admin_permissions"></a> [enable\_cluster\_creator\_admin\_permissions](#input\_enable\_cluster\_creator\_admin\_permissions) | Indicates whether or not to add the cluster creator (the identity used by Terraform) as an administrator via access entry | `bool` | `false` | no |
|
| <a name="input_enable_cluster_creator_admin_permissions"></a> [enable\_cluster\_creator\_admin\_permissions](#input\_enable\_cluster\_creator\_admin\_permissions) | Indicates whether or not to add the cluster creator (the identity used by Terraform) as an administrator via access entry | `bool` | `false` | no |
|
||||||
|
| <a name="input_enable_efa_support"></a> [enable\_efa\_support](#input\_enable\_efa\_support) | Determines whether to enable Elastic Fabric Adapter (EFA) support | `bool` | `false` | no |
|
||||||
| <a name="input_enable_irsa"></a> [enable\_irsa](#input\_enable\_irsa) | Determines whether to create an OpenID Connect Provider for EKS to enable IRSA | `bool` | `true` | no |
|
| <a name="input_enable_irsa"></a> [enable\_irsa](#input\_enable\_irsa) | Determines whether to create an OpenID Connect Provider for EKS to enable IRSA | `bool` | `true` | no |
|
||||||
| <a name="input_enable_kms_key_rotation"></a> [enable\_kms\_key\_rotation](#input\_enable\_kms\_key\_rotation) | Specifies whether key rotation is enabled | `bool` | `true` | no |
|
| <a name="input_enable_kms_key_rotation"></a> [enable\_kms\_key\_rotation](#input\_enable\_kms\_key\_rotation) | Specifies whether key rotation is enabled | `bool` | `true` | no |
|
||||||
| <a name="input_fargate_profile_defaults"></a> [fargate\_profile\_defaults](#input\_fargate\_profile\_defaults) | Map of Fargate Profile default configurations | `any` | `{}` | no |
|
| <a name="input_fargate_profile_defaults"></a> [fargate\_profile\_defaults](#input\_fargate\_profile\_defaults) | Map of Fargate Profile default configurations | `any` | `{}` | no |
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ Note that this example may create resources which cost money. Run `terraform des
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Providers
|
## Providers
|
||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ data "aws_availability_zones" "available" {}
|
|||||||
|
|
||||||
locals {
|
locals {
|
||||||
name = "ex-${replace(basename(path.cwd), "_", "-")}"
|
name = "ex-${replace(basename(path.cwd), "_", "-")}"
|
||||||
cluster_version = "1.27"
|
cluster_version = "1.29"
|
||||||
region = "eu-west-1"
|
region = "eu-west-1"
|
||||||
|
|
||||||
vpc_cidr = "10.0.0.0/16"
|
vpc_cidr = "10.0.0.0/16"
|
||||||
@@ -37,6 +37,10 @@ module "eks" {
|
|||||||
|
|
||||||
enable_cluster_creator_admin_permissions = true
|
enable_cluster_creator_admin_permissions = true
|
||||||
|
|
||||||
|
# Enable EFA support by adding necessary security group rules
|
||||||
|
# to the shared node security group
|
||||||
|
enable_efa_support = true
|
||||||
|
|
||||||
cluster_addons = {
|
cluster_addons = {
|
||||||
coredns = {
|
coredns = {
|
||||||
most_recent = true
|
most_recent = true
|
||||||
@@ -241,6 +245,26 @@ module "eks" {
|
|||||||
ExtraTag = "EKS managed node group complete example"
|
ExtraTag = "EKS managed node group complete example"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
efa = {
|
||||||
|
# Disabling automatic creation due to instance type/quota availability
|
||||||
|
# Can be enabled when appropriate for testing/validation
|
||||||
|
create = false
|
||||||
|
|
||||||
|
instance_types = ["trn1n.32xlarge"]
|
||||||
|
ami_type = "AL2_x86_64_GPU"
|
||||||
|
|
||||||
|
enable_efa_support = true
|
||||||
|
pre_bootstrap_user_data = <<-EOT
|
||||||
|
# Mount NVME instance store volumes since they are typically
|
||||||
|
# available on instances that support EFA
|
||||||
|
setup-local-disks raid0
|
||||||
|
EOT
|
||||||
|
|
||||||
|
min_size = 2
|
||||||
|
max_size = 2
|
||||||
|
desired_size = 2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
access_entries = {
|
access_entries = {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ Note that this example may create resources which cost money. Run `terraform des
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Providers
|
## Providers
|
||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Note that this example may create resources which cost money. Run `terraform des
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.7 |
|
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.7 |
|
||||||
| <a name="requirement_kubectl"></a> [kubectl](#requirement\_kubectl) | >= 2.0 |
|
| <a name="requirement_kubectl"></a> [kubectl](#requirement\_kubectl) | >= 2.0 |
|
||||||
|
|
||||||
@@ -63,8 +63,8 @@ Note that this example may create resources which cost money. Run `terraform des
|
|||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
| <a name="provider_aws.virginia"></a> [aws.virginia](#provider\_aws.virginia) | >= 5.34 |
|
| <a name="provider_aws.virginia"></a> [aws.virginia](#provider\_aws.virginia) | >= 5.38 |
|
||||||
| <a name="provider_helm"></a> [helm](#provider\_helm) | >= 2.7 |
|
| <a name="provider_helm"></a> [helm](#provider\_helm) | >= 2.7 |
|
||||||
| <a name="provider_kubectl"></a> [kubectl](#provider\_kubectl) | >= 2.0 |
|
| <a name="provider_kubectl"></a> [kubectl](#provider\_kubectl) | >= 2.0 |
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
helm = {
|
helm = {
|
||||||
source = "hashicorp/helm"
|
source = "hashicorp/helm"
|
||||||
|
|||||||
@@ -49,14 +49,14 @@ terraform destroy
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.20 |
|
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.20 |
|
||||||
|
|
||||||
## Providers
|
## Providers
|
||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.20 |
|
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.20 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
kubernetes = {
|
kubernetes = {
|
||||||
source = "hashicorp/kubernetes"
|
source = "hashicorp/kubernetes"
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ Note that this example may create resources which cost money. Run `terraform des
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Providers
|
## Providers
|
||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ module "eks" {
|
|||||||
cluster_version = local.cluster_version
|
cluster_version = local.cluster_version
|
||||||
cluster_endpoint_public_access = true
|
cluster_endpoint_public_access = true
|
||||||
|
|
||||||
|
enable_cluster_creator_admin_permissions = true
|
||||||
|
|
||||||
|
# Enable EFA support by adding necessary security group rules
|
||||||
|
# to the shared node security group
|
||||||
|
enable_efa_support = true
|
||||||
|
|
||||||
cluster_addons = {
|
cluster_addons = {
|
||||||
coredns = {
|
coredns = {
|
||||||
most_recent = true
|
most_recent = true
|
||||||
@@ -252,6 +258,25 @@ module "eks" {
|
|||||||
ExtraTag = "Self managed node group complete example"
|
ExtraTag = "Self managed node group complete example"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
efa = {
|
||||||
|
# Disabling automatic creation due to instance type/quota availability
|
||||||
|
# Can be enabled when appropriate for testing/validation
|
||||||
|
create = false
|
||||||
|
|
||||||
|
instance_type = "trn1n.32xlarge"
|
||||||
|
|
||||||
|
enable_efa_support = true
|
||||||
|
pre_bootstrap_user_data = <<-EOT
|
||||||
|
# Mount NVME instance store volumes since they are typically
|
||||||
|
# available on instances that support EFA
|
||||||
|
setup-local-disks raid0
|
||||||
|
EOT
|
||||||
|
|
||||||
|
min_size = 2
|
||||||
|
max_size = 2
|
||||||
|
desired_size = 2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tags = local.tags
|
tags = local.tags
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,13 +64,13 @@ module "eks_managed_node_group" {
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Providers
|
## Providers
|
||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
@@ -88,9 +88,13 @@ module "eks_managed_node_group" {
|
|||||||
| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||||
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||||
| [aws_launch_template.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource |
|
| [aws_launch_template.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource |
|
||||||
|
| [aws_placement_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/placement_group) | resource |
|
||||||
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
|
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
|
||||||
|
| [aws_ec2_instance_type.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_instance_type) | data source |
|
||||||
|
| [aws_ec2_instance_type_offerings.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_instance_type_offerings) | data source |
|
||||||
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||||
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
|
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
|
||||||
|
| [aws_subnets.efa](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnets) | data source |
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
@@ -123,6 +127,7 @@ module "eks_managed_node_group" {
|
|||||||
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `any` | `{}` | no |
|
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `any` | `{}` | no |
|
||||||
| <a name="input_elastic_inference_accelerator"></a> [elastic\_inference\_accelerator](#input\_elastic\_inference\_accelerator) | Configuration block containing an Elastic Inference Accelerator to attach to the instance | `map(string)` | `{}` | no |
|
| <a name="input_elastic_inference_accelerator"></a> [elastic\_inference\_accelerator](#input\_elastic\_inference\_accelerator) | Configuration block containing an Elastic Inference Accelerator to attach to the instance | `map(string)` | `{}` | no |
|
||||||
| <a name="input_enable_bootstrap_user_data"></a> [enable\_bootstrap\_user\_data](#input\_enable\_bootstrap\_user\_data) | Determines whether the bootstrap configurations are populated within the user data template. Only valid when using a custom AMI via `ami_id` | `bool` | `false` | no |
|
| <a name="input_enable_bootstrap_user_data"></a> [enable\_bootstrap\_user\_data](#input\_enable\_bootstrap\_user\_data) | Determines whether the bootstrap configurations are populated within the user data template. Only valid when using a custom AMI via `ami_id` | `bool` | `false` | no |
|
||||||
|
| <a name="input_enable_efa_support"></a> [enable\_efa\_support](#input\_enable\_efa\_support) | Determines whether to enable Elastic Fabric Adapter (EFA) support | `bool` | `false` | no |
|
||||||
| <a name="input_enable_monitoring"></a> [enable\_monitoring](#input\_enable\_monitoring) | Enables/disables detailed monitoring | `bool` | `true` | no |
|
| <a name="input_enable_monitoring"></a> [enable\_monitoring](#input\_enable\_monitoring) | Enables/disables detailed monitoring | `bool` | `true` | no |
|
||||||
| <a name="input_enclave_options"></a> [enclave\_options](#input\_enclave\_options) | Enable Nitro Enclaves on launched instances | `map(string)` | `{}` | no |
|
| <a name="input_enclave_options"></a> [enclave\_options](#input\_enclave\_options) | Enable Nitro Enclaves on launched instances | `map(string)` | `{}` | no |
|
||||||
| <a name="input_force_update_version"></a> [force\_update\_version](#input\_force\_update\_version) | Force version update if existing pods are unable to be drained due to a pod disruption budget issue | `bool` | `null` | no |
|
| <a name="input_force_update_version"></a> [force\_update\_version](#input\_force\_update\_version) | Force version update if existing pods are unable to be drained due to a pod disruption budget issue | `bool` | `null` | no |
|
||||||
|
|||||||
@@ -24,6 +24,33 @@ module "user_data" {
|
|||||||
user_data_template_path = var.user_data_template_path
|
user_data_template_path = var.user_data_template_path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EFA Support
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
data "aws_ec2_instance_type" "this" {
|
||||||
|
count = var.enable_efa_support ? 1 : 0
|
||||||
|
|
||||||
|
instance_type = local.efa_instance_type
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
efa_instance_type = try(element(var.instance_types, 0), "")
|
||||||
|
num_network_cards = try(data.aws_ec2_instance_type.this[0].maximum_network_cards, 0)
|
||||||
|
|
||||||
|
efa_network_interfaces = [
|
||||||
|
for i in range(local.num_network_cards) : {
|
||||||
|
associate_public_ip_address = false
|
||||||
|
delete_on_termination = true
|
||||||
|
device_index = i == 0 ? 0 : 1
|
||||||
|
network_card_index = i
|
||||||
|
interface_type = "efa"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
network_interfaces = var.enable_efa_support ? local.efa_network_interfaces : var.network_interfaces
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Launch template
|
# Launch template
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -31,6 +58,8 @@ module "user_data" {
|
|||||||
locals {
|
locals {
|
||||||
launch_template_name = coalesce(var.launch_template_name, "${var.name}-eks-node-group")
|
launch_template_name = coalesce(var.launch_template_name, "${var.name}-eks-node-group")
|
||||||
security_group_ids = compact(concat([var.cluster_primary_security_group_id], var.vpc_security_group_ids))
|
security_group_ids = compact(concat([var.cluster_primary_security_group_id], var.vpc_security_group_ids))
|
||||||
|
|
||||||
|
placement = var.create && var.enable_efa_support ? { group_name = aws_placement_group.this[0].name } : var.placement
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_launch_template" "this" {
|
resource "aws_launch_template" "this" {
|
||||||
@@ -215,7 +244,8 @@ resource "aws_launch_template" "this" {
|
|||||||
name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name}-" : null
|
name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name}-" : null
|
||||||
|
|
||||||
dynamic "network_interfaces" {
|
dynamic "network_interfaces" {
|
||||||
for_each = var.network_interfaces
|
for_each = local.network_interfaces
|
||||||
|
|
||||||
content {
|
content {
|
||||||
associate_carrier_ip_address = try(network_interfaces.value.associate_carrier_ip_address, null)
|
associate_carrier_ip_address = try(network_interfaces.value.associate_carrier_ip_address, null)
|
||||||
associate_public_ip_address = try(network_interfaces.value.associate_public_ip_address, null)
|
associate_public_ip_address = try(network_interfaces.value.associate_public_ip_address, null)
|
||||||
@@ -243,14 +273,14 @@ resource "aws_launch_template" "this" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dynamic "placement" {
|
dynamic "placement" {
|
||||||
for_each = length(var.placement) > 0 ? [var.placement] : []
|
for_each = length(local.placement) > 0 ? [local.placement] : []
|
||||||
|
|
||||||
content {
|
content {
|
||||||
affinity = try(placement.value.affinity, null)
|
affinity = try(placement.value.affinity, null)
|
||||||
availability_zone = try(placement.value.availability_zone, null)
|
availability_zone = lookup(placement.value, "availability_zone", null)
|
||||||
group_name = try(placement.value.group_name, null)
|
group_name = lookup(placement.value, "group_name", null)
|
||||||
host_id = try(placement.value.host_id, null)
|
host_id = lookup(placement.value, "host_id", null)
|
||||||
host_resource_group_arn = try(placement.value.host_resource_group_arn, null)
|
host_resource_group_arn = lookup(placement.value, "host_resource_group_arn", null)
|
||||||
partition_number = try(placement.value.partition_number, null)
|
partition_number = try(placement.value.partition_number, null)
|
||||||
spread_domain = try(placement.value.spread_domain, null)
|
spread_domain = try(placement.value.spread_domain, null)
|
||||||
tenancy = try(placement.value.tenancy, null)
|
tenancy = try(placement.value.tenancy, null)
|
||||||
@@ -280,7 +310,7 @@ resource "aws_launch_template" "this" {
|
|||||||
|
|
||||||
update_default_version = var.update_launch_template_default_version
|
update_default_version = var.update_launch_template_default_version
|
||||||
user_data = module.user_data.user_data
|
user_data = module.user_data.user_data
|
||||||
vpc_security_group_ids = length(var.network_interfaces) > 0 ? [] : local.security_group_ids
|
vpc_security_group_ids = length(local.network_interfaces) > 0 ? [] : local.security_group_ids
|
||||||
|
|
||||||
tags = var.tags
|
tags = var.tags
|
||||||
|
|
||||||
@@ -311,7 +341,7 @@ resource "aws_eks_node_group" "this" {
|
|||||||
# Required
|
# Required
|
||||||
cluster_name = var.cluster_name
|
cluster_name = var.cluster_name
|
||||||
node_role_arn = var.create_iam_role ? aws_iam_role.this[0].arn : var.iam_role_arn
|
node_role_arn = var.create_iam_role ? aws_iam_role.this[0].arn : var.iam_role_arn
|
||||||
subnet_ids = var.subnet_ids
|
subnet_ids = var.enable_efa_support ? data.aws_subnets.efa[0].ids : var.subnet_ids
|
||||||
|
|
||||||
scaling_config {
|
scaling_config {
|
||||||
min_size = var.min_size
|
min_size = var.min_size
|
||||||
@@ -448,6 +478,56 @@ resource "aws_iam_role_policy_attachment" "additional" {
|
|||||||
role = aws_iam_role.this[0].name
|
role = aws_iam_role.this[0].name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Placement Group
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
resource "aws_placement_group" "this" {
|
||||||
|
count = var.create && var.enable_efa_support ? 1 : 0
|
||||||
|
|
||||||
|
name = "${var.cluster_name}-${var.name}"
|
||||||
|
strategy = "cluster"
|
||||||
|
|
||||||
|
tags = var.tags
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Instance AZ Lookup
|
||||||
|
|
||||||
|
# Instances usually used in placement groups w/ EFA are only available in
|
||||||
|
# select availability zones. These data sources will cross reference the availability
|
||||||
|
# zones supported by the instance type with the subnets provided to ensure only
|
||||||
|
# AZs/subnets that are supported are used.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Find the availability zones supported by the instance type
|
||||||
|
data "aws_ec2_instance_type_offerings" "this" {
|
||||||
|
count = var.create && var.enable_efa_support ? 1 : 0
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "instance-type"
|
||||||
|
values = [local.efa_instance_type]
|
||||||
|
}
|
||||||
|
|
||||||
|
location_type = "availability-zone-id"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reverse the lookup to find one of the subnets provided based on the availability
|
||||||
|
# availability zone ID of the queried instance type (supported)
|
||||||
|
data "aws_subnets" "efa" {
|
||||||
|
count = var.create && var.enable_efa_support ? 1 : 0
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "subnet-id"
|
||||||
|
values = var.subnet_ids
|
||||||
|
}
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "availability-zone-id"
|
||||||
|
values = data.aws_ec2_instance_type_offerings.this[0].locations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Autoscaling Group Schedule
|
# Autoscaling Group Schedule
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
@@ -250,6 +250,12 @@ variable "enable_monitoring" {
|
|||||||
default = true
|
default = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "enable_efa_support" {
|
||||||
|
description = "Determines whether to enable Elastic Fabric Adapter (EFA) support"
|
||||||
|
type = bool
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
variable "network_interfaces" {
|
variable "network_interfaces" {
|
||||||
description = "Customize network interfaces to be attached at instance boot time"
|
description = "Customize network interfaces to be attached at instance boot time"
|
||||||
type = list(any)
|
type = list(any)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ module "fargate_profile" {
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Providers
|
## Providers
|
||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,13 +85,13 @@ module "karpenter" {
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Providers
|
## Providers
|
||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,13 +43,13 @@ module "self_managed_node_group" {
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
|
||||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.34 |
|
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Providers
|
## Providers
|
||||||
|
|
||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.34 |
|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
@@ -69,10 +69,14 @@ module "self_managed_node_group" {
|
|||||||
| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
| [aws_iam_role_policy_attachment.additional](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||||
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
|
||||||
| [aws_launch_template.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource |
|
| [aws_launch_template.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource |
|
||||||
|
| [aws_placement_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/placement_group) | resource |
|
||||||
| [aws_ami.eks_default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
|
| [aws_ami.eks_default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
|
||||||
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
|
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
|
||||||
|
| [aws_ec2_instance_type.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_instance_type) | data source |
|
||||||
|
| [aws_ec2_instance_type_offerings.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_instance_type_offerings) | data source |
|
||||||
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||||
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
|
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
|
||||||
|
| [aws_subnets.efa](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnets) | data source |
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
@@ -108,6 +112,7 @@ module "self_managed_node_group" {
|
|||||||
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `null` | no |
|
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `null` | no |
|
||||||
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `any` | `{}` | no |
|
| <a name="input_elastic_gpu_specifications"></a> [elastic\_gpu\_specifications](#input\_elastic\_gpu\_specifications) | The elastic GPU to attach to the instance | `any` | `{}` | no |
|
||||||
| <a name="input_elastic_inference_accelerator"></a> [elastic\_inference\_accelerator](#input\_elastic\_inference\_accelerator) | Configuration block containing an Elastic Inference Accelerator to attach to the instance | `map(string)` | `{}` | no |
|
| <a name="input_elastic_inference_accelerator"></a> [elastic\_inference\_accelerator](#input\_elastic\_inference\_accelerator) | Configuration block containing an Elastic Inference Accelerator to attach to the instance | `map(string)` | `{}` | no |
|
||||||
|
| <a name="input_enable_efa_support"></a> [enable\_efa\_support](#input\_enable\_efa\_support) | Determines whether to enable Elastic Fabric Adapter (EFA) support | `bool` | `false` | no |
|
||||||
| <a name="input_enable_monitoring"></a> [enable\_monitoring](#input\_enable\_monitoring) | Enables/disables detailed monitoring | `bool` | `true` | no |
|
| <a name="input_enable_monitoring"></a> [enable\_monitoring](#input\_enable\_monitoring) | Enables/disables detailed monitoring | `bool` | `true` | no |
|
||||||
| <a name="input_enabled_metrics"></a> [enabled\_metrics](#input\_enabled\_metrics) | A list of metrics to collect. The allowed values are `GroupDesiredCapacity`, `GroupInServiceCapacity`, `GroupPendingCapacity`, `GroupMinSize`, `GroupMaxSize`, `GroupInServiceInstances`, `GroupPendingInstances`, `GroupStandbyInstances`, `GroupStandbyCapacity`, `GroupTerminatingCapacity`, `GroupTerminatingInstances`, `GroupTotalCapacity`, `GroupTotalInstances` | `list(string)` | `[]` | no |
|
| <a name="input_enabled_metrics"></a> [enabled\_metrics](#input\_enabled\_metrics) | A list of metrics to collect. The allowed values are `GroupDesiredCapacity`, `GroupInServiceCapacity`, `GroupPendingCapacity`, `GroupMinSize`, `GroupMaxSize`, `GroupInServiceInstances`, `GroupPendingInstances`, `GroupStandbyInstances`, `GroupStandbyCapacity`, `GroupTerminatingCapacity`, `GroupTerminatingInstances`, `GroupTotalCapacity`, `GroupTotalInstances` | `list(string)` | `[]` | no |
|
||||||
| <a name="input_enclave_options"></a> [enclave\_options](#input\_enclave\_options) | Enable Nitro Enclaves on launched instances | `map(string)` | `{}` | no |
|
| <a name="input_enclave_options"></a> [enclave\_options](#input\_enclave\_options) | Enable Nitro Enclaves on launched instances | `map(string)` | `{}` | no |
|
||||||
|
|||||||
@@ -35,6 +35,33 @@ module "user_data" {
|
|||||||
user_data_template_path = var.user_data_template_path
|
user_data_template_path = var.user_data_template_path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EFA Support
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
data "aws_ec2_instance_type" "this" {
|
||||||
|
count = var.enable_efa_support && local.instance_type_provided ? 1 : 0
|
||||||
|
|
||||||
|
instance_type = var.instance_type
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
instance_type_provided = var.instance_type != ""
|
||||||
|
num_network_cards = try(data.aws_ec2_instance_type.this[0].maximum_network_cards, 0)
|
||||||
|
|
||||||
|
efa_network_interfaces = [
|
||||||
|
for i in range(local.num_network_cards) : {
|
||||||
|
associate_public_ip_address = false
|
||||||
|
delete_on_termination = true
|
||||||
|
device_index = i == 0 ? 0 : 1
|
||||||
|
network_card_index = i
|
||||||
|
interface_type = "efa"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
network_interfaces = var.enable_efa_support && local.instance_type_provided ? local.efa_network_interfaces : var.network_interfaces
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Launch template
|
# Launch template
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -42,6 +69,8 @@ module "user_data" {
|
|||||||
locals {
|
locals {
|
||||||
launch_template_name = coalesce(var.launch_template_name, "${var.name}-node-group")
|
launch_template_name = coalesce(var.launch_template_name, "${var.name}-node-group")
|
||||||
security_group_ids = compact(concat([var.cluster_primary_security_group_id], var.vpc_security_group_ids))
|
security_group_ids = compact(concat([var.cluster_primary_security_group_id], var.vpc_security_group_ids))
|
||||||
|
|
||||||
|
placement = var.create && var.enable_efa_support ? { group_name = aws_placement_group.this[0].name } : var.placement
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_launch_template" "this" {
|
resource "aws_launch_template" "this" {
|
||||||
@@ -321,7 +350,8 @@ resource "aws_launch_template" "this" {
|
|||||||
name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name}-" : null
|
name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name}-" : null
|
||||||
|
|
||||||
dynamic "network_interfaces" {
|
dynamic "network_interfaces" {
|
||||||
for_each = var.network_interfaces
|
for_each = local.network_interfaces
|
||||||
|
|
||||||
content {
|
content {
|
||||||
associate_carrier_ip_address = try(network_interfaces.value.associate_carrier_ip_address, null)
|
associate_carrier_ip_address = try(network_interfaces.value.associate_carrier_ip_address, null)
|
||||||
associate_public_ip_address = try(network_interfaces.value.associate_public_ip_address, null)
|
associate_public_ip_address = try(network_interfaces.value.associate_public_ip_address, null)
|
||||||
@@ -347,14 +377,14 @@ resource "aws_launch_template" "this" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dynamic "placement" {
|
dynamic "placement" {
|
||||||
for_each = length(var.placement) > 0 ? [var.placement] : []
|
for_each = length(local.placement) > 0 ? [local.placement] : []
|
||||||
|
|
||||||
content {
|
content {
|
||||||
affinity = try(placement.value.affinity, null)
|
affinity = try(placement.value.affinity, null)
|
||||||
availability_zone = try(placement.value.availability_zone, null)
|
availability_zone = lookup(placement.value, "availability_zone", null)
|
||||||
group_name = try(placement.value.group_name, null)
|
group_name = lookup(placement.value, "group_name", null)
|
||||||
host_id = try(placement.value.host_id, null)
|
host_id = lookup(placement.value, "host_id", null)
|
||||||
host_resource_group_arn = try(placement.value.host_resource_group_arn, null)
|
host_resource_group_arn = lookup(placement.value, "host_resource_group_arn", null)
|
||||||
partition_number = try(placement.value.partition_number, null)
|
partition_number = try(placement.value.partition_number, null)
|
||||||
spread_domain = try(placement.value.spread_domain, null)
|
spread_domain = try(placement.value.spread_domain, null)
|
||||||
tenancy = try(placement.value.tenancy, null)
|
tenancy = try(placement.value.tenancy, null)
|
||||||
@@ -384,7 +414,7 @@ resource "aws_launch_template" "this" {
|
|||||||
|
|
||||||
update_default_version = var.update_launch_template_default_version
|
update_default_version = var.update_launch_template_default_version
|
||||||
user_data = module.user_data.user_data
|
user_data = module.user_data.user_data
|
||||||
vpc_security_group_ids = length(var.network_interfaces) > 0 ? [] : local.security_group_ids
|
vpc_security_group_ids = length(local.network_interfaces) > 0 ? [] : local.security_group_ids
|
||||||
|
|
||||||
tags = var.tags
|
tags = var.tags
|
||||||
|
|
||||||
@@ -664,7 +694,7 @@ resource "aws_autoscaling_group" "this" {
|
|||||||
|
|
||||||
target_group_arns = var.target_group_arns
|
target_group_arns = var.target_group_arns
|
||||||
termination_policies = var.termination_policies
|
termination_policies = var.termination_policies
|
||||||
vpc_zone_identifier = var.subnet_ids
|
vpc_zone_identifier = var.enable_efa_support ? data.aws_subnets.efa[0].ids : var.subnet_ids
|
||||||
wait_for_capacity_timeout = var.wait_for_capacity_timeout
|
wait_for_capacity_timeout = var.wait_for_capacity_timeout
|
||||||
wait_for_elb_capacity = var.wait_for_elb_capacity
|
wait_for_elb_capacity = var.wait_for_elb_capacity
|
||||||
|
|
||||||
@@ -771,6 +801,56 @@ resource "aws_iam_instance_profile" "this" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Placement Group
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
resource "aws_placement_group" "this" {
|
||||||
|
count = var.create && var.enable_efa_support ? 1 : 0
|
||||||
|
|
||||||
|
name = "${var.cluster_name}-${var.name}"
|
||||||
|
strategy = "cluster"
|
||||||
|
|
||||||
|
tags = var.tags
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Instance AZ Lookup
|
||||||
|
|
||||||
|
# Instances usually used in placement groups w/ EFA are only available in
|
||||||
|
# select availability zones. These data sources will cross reference the availability
|
||||||
|
# zones supported by the instance type with the subnets provided to ensure only
|
||||||
|
# AZs/subnets that are supported are used.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Find the availability zones supported by the instance type
|
||||||
|
data "aws_ec2_instance_type_offerings" "this" {
|
||||||
|
count = var.create && var.enable_efa_support ? 1 : 0
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "instance-type"
|
||||||
|
values = [var.instance_type]
|
||||||
|
}
|
||||||
|
|
||||||
|
location_type = "availability-zone-id"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reverse the lookup to find one of the subnets provided based on the availability
|
||||||
|
# availability zone ID of the queried instance type (supported)
|
||||||
|
data "aws_subnets" "efa" {
|
||||||
|
count = var.create && var.enable_efa_support ? 1 : 0
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "subnet-id"
|
||||||
|
values = var.subnet_ids
|
||||||
|
}
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "availability-zone-id"
|
||||||
|
values = data.aws_ec2_instance_type_offerings.this[0].locations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Access Entry
|
# Access Entry
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
@@ -270,6 +270,12 @@ variable "enable_monitoring" {
|
|||||||
default = true
|
default = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "enable_efa_support" {
|
||||||
|
description = "Determines whether to enable Elastic Fabric Adapter (EFA) support"
|
||||||
|
type = bool
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
variable "metadata_options" {
|
variable "metadata_options" {
|
||||||
description = "Customize the metadata options for the instance"
|
description = "Customize the metadata options for the instance"
|
||||||
type = map(string)
|
type = map(string)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,6 +179,27 @@ locals {
|
|||||||
ipv6_cidr_blocks = var.cluster_ip_family == "ipv6" ? ["::/0"] : null
|
ipv6_cidr_blocks = var.cluster_ip_family == "ipv6" ? ["::/0"] : null
|
||||||
}
|
}
|
||||||
} : k => v if var.node_security_group_enable_recommended_rules }
|
} : k => v if var.node_security_group_enable_recommended_rules }
|
||||||
|
|
||||||
|
efa_security_group_rules = { for k, v in
|
||||||
|
{
|
||||||
|
ingress_all_self_efa = {
|
||||||
|
description = "Node to node EFA"
|
||||||
|
protocol = "-1"
|
||||||
|
from_port = 0
|
||||||
|
to_port = 0
|
||||||
|
type = "ingress"
|
||||||
|
self = true
|
||||||
|
}
|
||||||
|
egress_all_self_efa = {
|
||||||
|
description = "Node to node EFA"
|
||||||
|
protocol = "-1"
|
||||||
|
from_port = 0
|
||||||
|
to_port = 0
|
||||||
|
type = "egress"
|
||||||
|
self = true
|
||||||
|
}
|
||||||
|
} : k => v if var.enable_efa_support
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_security_group" "node" {
|
resource "aws_security_group" "node" {
|
||||||
@@ -205,6 +226,7 @@ resource "aws_security_group" "node" {
|
|||||||
|
|
||||||
resource "aws_security_group_rule" "node" {
|
resource "aws_security_group_rule" "node" {
|
||||||
for_each = { for k, v in merge(
|
for_each = { for k, v in merge(
|
||||||
|
local.efa_security_group_rules,
|
||||||
local.node_security_group_rules,
|
local.node_security_group_rules,
|
||||||
local.node_security_group_recommended_rules,
|
local.node_security_group_recommended_rules,
|
||||||
var.node_security_group_additional_rules,
|
var.node_security_group_additional_rules,
|
||||||
@@ -343,6 +365,7 @@ module "eks_managed_node_group" {
|
|||||||
license_specifications = try(each.value.license_specifications, var.eks_managed_node_group_defaults.license_specifications, {})
|
license_specifications = try(each.value.license_specifications, var.eks_managed_node_group_defaults.license_specifications, {})
|
||||||
metadata_options = try(each.value.metadata_options, var.eks_managed_node_group_defaults.metadata_options, local.metadata_options)
|
metadata_options = try(each.value.metadata_options, var.eks_managed_node_group_defaults.metadata_options, local.metadata_options)
|
||||||
enable_monitoring = try(each.value.enable_monitoring, var.eks_managed_node_group_defaults.enable_monitoring, true)
|
enable_monitoring = try(each.value.enable_monitoring, var.eks_managed_node_group_defaults.enable_monitoring, true)
|
||||||
|
enable_efa_support = try(each.value.enable_efa_support, var.eks_managed_node_group_defaults.enable_efa_support, false)
|
||||||
network_interfaces = try(each.value.network_interfaces, var.eks_managed_node_group_defaults.network_interfaces, [])
|
network_interfaces = try(each.value.network_interfaces, var.eks_managed_node_group_defaults.network_interfaces, [])
|
||||||
placement = try(each.value.placement, var.eks_managed_node_group_defaults.placement, {})
|
placement = try(each.value.placement, var.eks_managed_node_group_defaults.placement, {})
|
||||||
maintenance_options = try(each.value.maintenance_options, var.eks_managed_node_group_defaults.maintenance_options, {})
|
maintenance_options = try(each.value.maintenance_options, var.eks_managed_node_group_defaults.maintenance_options, {})
|
||||||
@@ -478,6 +501,7 @@ module "self_managed_node_group" {
|
|||||||
license_specifications = try(each.value.license_specifications, var.self_managed_node_group_defaults.license_specifications, {})
|
license_specifications = try(each.value.license_specifications, var.self_managed_node_group_defaults.license_specifications, {})
|
||||||
metadata_options = try(each.value.metadata_options, var.self_managed_node_group_defaults.metadata_options, local.metadata_options)
|
metadata_options = try(each.value.metadata_options, var.self_managed_node_group_defaults.metadata_options, local.metadata_options)
|
||||||
enable_monitoring = try(each.value.enable_monitoring, var.self_managed_node_group_defaults.enable_monitoring, true)
|
enable_monitoring = try(each.value.enable_monitoring, var.self_managed_node_group_defaults.enable_monitoring, true)
|
||||||
|
enable_efa_support = try(each.value.enable_efa_support, var.self_managed_node_group_defaults.enable_efa_support, false)
|
||||||
network_interfaces = try(each.value.network_interfaces, var.self_managed_node_group_defaults.network_interfaces, [])
|
network_interfaces = try(each.value.network_interfaces, var.self_managed_node_group_defaults.network_interfaces, [])
|
||||||
placement = try(each.value.placement, var.self_managed_node_group_defaults.placement, {})
|
placement = try(each.value.placement, var.self_managed_node_group_defaults.placement, {})
|
||||||
maintenance_options = try(each.value.maintenance_options, var.self_managed_node_group_defaults.maintenance_options, {})
|
maintenance_options = try(each.value.maintenance_options, var.self_managed_node_group_defaults.maintenance_options, {})
|
||||||
|
|||||||
@@ -376,6 +376,12 @@ variable "node_security_group_tags" {
|
|||||||
default = {}
|
default = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "enable_efa_support" {
|
||||||
|
description = "Determines whether to enable Elastic Fabric Adapter (EFA) support"
|
||||||
|
type = bool
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# IRSA
|
# IRSA
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
version = ">= 5.34"
|
version = ">= 5.38"
|
||||||
}
|
}
|
||||||
tls = {
|
tls = {
|
||||||
source = "hashicorp/tls"
|
source = "hashicorp/tls"
|
||||||
|
|||||||
Reference in New Issue
Block a user