mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-04-26 10:28:41 +02:00
feat: Add instance store volume option for instances with local disk (#1213)
This commit is contained in:
93
local.tf
93
local.tf
@@ -29,51 +29,54 @@ locals {
|
|||||||
|
|
||||||
policy_arn_prefix = "arn:${data.aws_partition.current.partition}:iam::aws:policy"
|
policy_arn_prefix = "arn:${data.aws_partition.current.partition}:iam::aws:policy"
|
||||||
workers_group_defaults_defaults = {
|
workers_group_defaults_defaults = {
|
||||||
name = "count.index" # Name of the worker group. Literal count.index will never be used but if name is not set, the count.index interpolation will be used.
|
name = "count.index" # Name of the worker group. Literal count.index will never be used but if name is not set, the count.index interpolation will be used.
|
||||||
tags = [] # A list of map defining extra tags to be applied to the worker group autoscaling group.
|
tags = [] # A list of map defining extra tags to be applied to the worker group autoscaling group.
|
||||||
ami_id = "" # AMI ID for the eks linux based workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI based on platform.
|
ami_id = "" # AMI ID for the eks linux based workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI based on platform.
|
||||||
ami_id_windows = "" # AMI ID for the eks windows based workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI based on platform.
|
ami_id_windows = "" # AMI ID for the eks windows based workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI based on platform.
|
||||||
asg_desired_capacity = "1" # Desired worker capacity in the autoscaling group and changing its value will not affect the autoscaling group's desired capacity because the cluster-autoscaler manages up and down scaling of the nodes. Cluster-autoscaler add nodes when pods are in pending state and remove the nodes when they are not required by modifying the desirec_capacity of the autoscaling group. Although an issue exists in which if the value of the asg_min_size is changed it modifies the value of asg_desired_capacity.
|
asg_desired_capacity = "1" # Desired worker capacity in the autoscaling group and changing its value will not affect the autoscaling group's desired capacity because the cluster-autoscaler manages up and down scaling of the nodes. Cluster-autoscaler add nodes when pods are in pending state and remove the nodes when they are not required by modifying the desirec_capacity of the autoscaling group. Although an issue exists in which if the value of the asg_min_size is changed it modifies the value of asg_desired_capacity.
|
||||||
asg_max_size = "3" # Maximum worker capacity in the autoscaling group.
|
asg_max_size = "3" # Maximum worker capacity in the autoscaling group.
|
||||||
asg_min_size = "1" # Minimum worker capacity in the autoscaling group. NOTE: Change in this paramater will affect the asg_desired_capacity, like changing its value to 2 will change asg_desired_capacity value to 2 but bringing back it to 1 will not affect the asg_desired_capacity.
|
asg_min_size = "1" # Minimum worker capacity in the autoscaling group. NOTE: Change in this paramater will affect the asg_desired_capacity, like changing its value to 2 will change asg_desired_capacity value to 2 but bringing back it to 1 will not affect the asg_desired_capacity.
|
||||||
asg_force_delete = false # Enable forced deletion for the autoscaling group.
|
asg_force_delete = false # Enable forced deletion for the autoscaling group.
|
||||||
asg_initial_lifecycle_hooks = [] # Initial lifecycle hook for the autoscaling group.
|
asg_initial_lifecycle_hooks = [] # Initital lifecycle hook for the autoscaling group.
|
||||||
default_cooldown = null # The amount of time, in seconds, after a scaling activity completes before another scaling activity can start.
|
default_cooldown = null # The amount of time, in seconds, after a scaling activity completes before another scaling activity can start.
|
||||||
health_check_type = null # Controls how health checking is done. Valid values are "EC2" or "ELB".
|
health_check_type = null # Controls how health checking is done. Valid values are "EC2" or "ELB".
|
||||||
health_check_grace_period = null # Time in seconds after instance comes into service before checking health.
|
health_check_grace_period = null # Time in seconds after instance comes into service before checking health.
|
||||||
instance_type = "m4.large" # Size of the workers instances.
|
instance_type = "m4.large" # Size of the workers instances.
|
||||||
spot_price = "" # Cost of spot instance.
|
instance_store_virtual_name = "ephemeral0" # "virtual_name" of the instance store volume.
|
||||||
placement_tenancy = "" # The tenancy of the instance. Valid values are "default" or "dedicated".
|
spot_price = "" # Cost of spot instance.
|
||||||
root_volume_size = "100" # root volume size of workers instances.
|
placement_tenancy = "" # The tenancy of the instance. Valid values are "default" or "dedicated".
|
||||||
root_volume_type = "gp2" # root volume type of workers instances, can be 'standard', 'gp3' (for Launch Template), 'gp2', or 'io1'
|
root_volume_size = "100" # root volume size of workers instances.
|
||||||
root_iops = "0" # The amount of provisioned IOPS. This must be set with a volume_type of "io1".
|
root_volume_type = "gp3" # root volume type of workers instances, can be "standard", "gp3", "gp2", or "io1"
|
||||||
root_volume_throughput = null # The amount of throughput to provision for a gp3 volume.
|
root_iops = "0" # The amount of provisioned IOPS. This must be set with a volume_type of "io1".
|
||||||
key_name = "" # The key pair name that should be used for the instances in the autoscaling group
|
root_volume_throughput = null # The amount of throughput to provision for a gp3 volume.
|
||||||
pre_userdata = "" # userdata to pre-append to the default userdata.
|
key_name = "" # The key pair name that should be used for the instances in the autoscaling group
|
||||||
userdata_template_file = "" # alternate template to use for userdata
|
pre_userdata = "" # userdata to pre-append to the default userdata.
|
||||||
userdata_template_extra_args = {} # Additional arguments to use when expanding the userdata template file
|
userdata_template_file = "" # alternate template to use for userdata
|
||||||
bootstrap_extra_args = "" # Extra arguments passed to the bootstrap.sh script from the EKS AMI (Amazon Machine Image).
|
userdata_template_extra_args = {} # Additional arguments to use when expanding the userdata template file
|
||||||
additional_userdata = "" # userdata to append to the default userdata.
|
bootstrap_extra_args = "" # Extra arguments passed to the bootstrap.sh script from the EKS AMI (Amazon Machine Image).
|
||||||
ebs_optimized = true # sets whether to use ebs optimization on supported types.
|
additional_userdata = "" # userdata to append to the default userdata.
|
||||||
enable_monitoring = true # Enables/disables detailed monitoring.
|
ebs_optimized = true # sets whether to use ebs optimization on supported types.
|
||||||
enclave_support = false # Enables/disables enclave support
|
enable_monitoring = true # Enables/disables detailed monitoring.
|
||||||
public_ip = false # Associate a public ip address with a worker
|
enclave_support = false # Enables/disables enclave support
|
||||||
kubelet_extra_args = "" # This string is passed directly to kubelet if set. Useful for adding labels or taints.
|
public_ip = false # Associate a public ip address with a worker
|
||||||
subnets = var.subnets # A list of subnets to place the worker nodes in. i.e. ["subnet-123", "subnet-456", "subnet-789"]
|
kubelet_extra_args = "" # This string is passed directly to kubelet if set. Useful for adding labels or taints.
|
||||||
additional_security_group_ids = [] # A list of additional security group ids to include in worker launch config
|
subnets = var.subnets # A list of subnets to place the worker nodes in. i.e. ["subnet-123", "subnet-456", "subnet-789"]
|
||||||
protect_from_scale_in = false # Prevent AWS from scaling in, so that cluster-autoscaler is solely responsible.
|
additional_security_group_ids = [] # A list of additional security group ids to include in worker launch config
|
||||||
iam_instance_profile_name = "" # A custom IAM instance profile name. Used when manage_worker_iam_resources is set to false. Incompatible with iam_role_id.
|
protect_from_scale_in = false # Prevent AWS from scaling in, so that cluster-autoscaler is solely responsible.
|
||||||
iam_role_id = "local.default_iam_role_id" # A custom IAM role id. Incompatible with iam_instance_profile_name. Literal local.default_iam_role_id will never be used but if iam_role_id is not set, the local.default_iam_role_id interpolation will be used.
|
iam_instance_profile_name = "" # A custom IAM instance profile name. Used when manage_worker_iam_resources is set to false. Incompatible with iam_role_id.
|
||||||
suspended_processes = ["AZRebalance"] # A list of processes to suspend. i.e. ["AZRebalance", "HealthCheck", "ReplaceUnhealthy"]
|
iam_role_id = "local.default_iam_role_id" # A custom IAM role id. Incompatible with iam_instance_profile_name. Literal local.default_iam_role_id will never be used but if iam_role_id is not set, the local.default_iam_role_id interpolation will be used.
|
||||||
target_group_arns = null # A list of Application LoadBalancer (ALB) target group ARNs to be associated to the autoscaling group
|
suspended_processes = ["AZRebalance"] # A list of processes to suspend. i.e. ["AZRebalance", "HealthCheck", "ReplaceUnhealthy"]
|
||||||
load_balancers = null # A list of Classic LoadBalancer (CLB)'s name to be associated to the autoscaling group
|
target_group_arns = null # A list of Application LoadBalancer (ALB) target group ARNs to be associated to the autoscaling group
|
||||||
enabled_metrics = [] # A list of metrics to be collected i.e. ["GroupMinSize", "GroupMaxSize", "GroupDesiredCapacity"]
|
load_balancers = null # A list of Classic LoadBalancer (CLB)'s name to be associated to the autoscaling group
|
||||||
placement_group = null # The name of the placement group into which to launch the instances, if any.
|
enabled_metrics = [] # A list of metrics to be collected i.e. ["GroupMinSize", "GroupMaxSize", "GroupDesiredCapacity"]
|
||||||
service_linked_role_arn = "" # Arn of custom service linked role that Auto Scaling group will use. Useful when you have encrypted EBS
|
placement_group = null # The name of the placement group into which to launch the instances, if any.
|
||||||
termination_policies = [] # A list of policies to decide how the instances in the auto scale group should be terminated.
|
service_linked_role_arn = "" # Arn of custom service linked role that Auto Scaling group will use. Useful when you have encrypted EBS
|
||||||
platform = "linux" # Platform of workers. either "linux" or "windows"
|
termination_policies = [] # A list of policies to decide how the instances in the auto scale group should be terminated.
|
||||||
additional_ebs_volumes = [] # A list of additional volumes to be attached to the instances on this Auto Scaling group. Each volume should be an object with the following: block_device_name (required), volume_size, volume_type, iops, encrypted, kms_key_id (only on launch-template), delete_on_termination. Optional values are grabbed from root volume or from defaults
|
platform = "linux" # Platform of workers. either "linux" or "windows"
|
||||||
warm_pool = null # If this block is configured, add a Warm Pool to the specified Auto Scaling group.
|
additional_ebs_volumes = [] # A list of additional volumes to be attached to the instances on this Auto Scaling group. Each volume should be an object with the following: block_device_name (required), volume_size, volume_type, iops, encrypted, kms_key_id (only on launch-template), delete_on_termination. Optional values are grabbed from root volume or from defaults
|
||||||
|
additional_instance_store_volumes = [] # A list of additional instance store (local disk) volumes to be attached to the instances on this Auto Scaling group. Each volume should be an object with the following: block_device_name (required), virtual_name.
|
||||||
|
warm_pool = null # If this block is configured, add a Warm Pool to the specified Auto Scaling group.
|
||||||
|
|
||||||
# Settings for launch templates
|
# Settings for launch templates
|
||||||
root_block_device_name = concat(data.aws_ami.eks_worker.*.root_device_name, [""])[0] # Root device name for workers. If non is provided, will assume default AMI was used.
|
root_block_device_name = concat(data.aws_ami.eks_worker.*.root_device_name, [""])[0] # Root device name for workers. If non is provided, will assume default AMI was used.
|
||||||
root_kms_key_id = "" # The KMS key to use when encrypting the root storage device
|
root_kms_key_id = "" # The KMS key to use when encrypting the root storage device
|
||||||
|
|||||||
@@ -518,6 +518,18 @@ resource "aws_launch_template" "workers_launch_template" {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dynamic "block_device_mappings" {
|
||||||
|
for_each = lookup(var.worker_groups_launch_template[count.index], "additional_instance_store_volumes", local.workers_group_defaults["additional_instance_store_volumes"])
|
||||||
|
content {
|
||||||
|
device_name = block_device_mappings.value.block_device_name
|
||||||
|
virtual_name = lookup(
|
||||||
|
block_device_mappings.value,
|
||||||
|
"virtual_name",
|
||||||
|
local.workers_group_defaults["instance_store_virtual_name"],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tag_specifications {
|
tag_specifications {
|
||||||
resource_type = "volume"
|
resource_type = "volume"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user