mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-23 09:51:04 +01:00
fix: Ensure the correct service CIDR and IP family is used in the rendered user data (#2963)
* fix: Ensuring the correct service CIDR and IP family is used in the rendered user data * chore: Updates from testing and validating * chore: Fix example destroy instructions * fix: Only require `cluster_service_cidr` when `create = true` * chore: Clean up commented out code and add note on check length
This commit is contained in:
@@ -4,6 +4,7 @@ locals {
|
||||
cluster_endpoint = "https://012345678903AB2BAE5D1E0BFE0E2B50.gr7.us-east-1.eks.amazonaws.com"
|
||||
cluster_auth_base64 = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM1ekNDQWMrZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKbXFqQ1VqNGdGR2w3ZW5PeWthWnZ2RjROOTVOUEZCM2o0cGhVZUsrWGFtN2ZSQnZya0d6OGxKZmZEZWF2b2plTwpQK2xOZFlqdHZncmxCUEpYdHZIZmFzTzYxVzdIZmdWQ2EvamdRM2w3RmkvL1dpQmxFOG9oWUZkdWpjc0s1SXM2CnNkbk5KTTNYUWN2TysrSitkV09NT2ZlNzlsSWdncmdQLzgvRU9CYkw3eUY1aU1hS3lsb1RHL1V3TlhPUWt3ZUcKblBNcjdiUmdkQ1NCZTlXYXowOGdGRmlxV2FOditsTDhsODBTdFZLcWVNVlUxbjQyejVwOVpQRTd4T2l6L0xTNQpYV2lXWkVkT3pMN0xBWGVCS2gzdkhnczFxMkI2d1BKZnZnS1NzWllQRGFpZTloT1NNOUJkNFNPY3JrZTRYSVBOCkVvcXVhMlYrUDRlTWJEQzhMUkVWRDdCdVZDdWdMTldWOTBoL3VJUy9WU2VOcEdUOGVScE5DakszSjc2aFlsWm8KWjNGRG5QWUY0MWpWTHhiOXF0U1ROdEp6amYwWXBEYnFWci9xZzNmQWlxbVorMzd3YWM1eHlqMDZ4cmlaRUgzZgpUM002d2lCUEVHYVlGeWN5TmNYTk5aYW9DWDJVL0N1d2JsUHAKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQ=="
|
||||
cluster_service_ipv4_cidr = "172.16.0.0/16"
|
||||
cluster_service_ipv6_cidr = "fdd3:7636:68bc::/108"
|
||||
cluster_service_cidr = "192.168.0.0/16"
|
||||
}
|
||||
|
||||
@@ -11,13 +12,25 @@ locals {
|
||||
# EKS managed node group - AL2
|
||||
################################################################################
|
||||
|
||||
module "eks_mng_al2_disabled" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
create = false
|
||||
}
|
||||
|
||||
module "eks_mng_al2_no_op" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
}
|
||||
|
||||
module "eks_mng_al2_additional" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
pre_bootstrap_user_data = <<-EOT
|
||||
export USE_MAX_PODS=false
|
||||
EOT
|
||||
@@ -26,10 +39,32 @@ module "eks_mng_al2_additional" {
|
||||
module "eks_mng_al2_custom_ami" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_service_ipv4_cidr = local.cluster_service_ipv4_cidr
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_service_cidr = local.cluster_service_ipv4_cidr
|
||||
|
||||
enable_bootstrap_user_data = true
|
||||
|
||||
pre_bootstrap_user_data = <<-EOT
|
||||
export FOO=bar
|
||||
EOT
|
||||
|
||||
bootstrap_extra_args = "--kubelet-extra-args '--instance-type t3a.large'"
|
||||
|
||||
post_bootstrap_user_data = <<-EOT
|
||||
echo "All done"
|
||||
EOT
|
||||
}
|
||||
|
||||
module "eks_mng_al2_custom_ami_ipv6" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_ip_family = "ipv6"
|
||||
cluster_service_cidr = local.cluster_service_ipv6_cidr
|
||||
|
||||
enable_bootstrap_user_data = true
|
||||
|
||||
@@ -47,9 +82,10 @@ module "eks_mng_al2_custom_ami" {
|
||||
module "eks_mng_al2_custom_template" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_service_cidr = local.cluster_service_ipv4_cidr
|
||||
|
||||
user_data_template_path = "${path.module}/templates/linux_custom.tpl"
|
||||
|
||||
@@ -73,6 +109,9 @@ module "eks_mng_al2023_no_op" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
platform = "al2023"
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
}
|
||||
|
||||
module "eks_mng_al2023_additional" {
|
||||
@@ -80,6 +119,9 @@ module "eks_mng_al2023_additional" {
|
||||
|
||||
platform = "al2023"
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
cloudinit_pre_nodeadm = [{
|
||||
content = <<-EOT
|
||||
---
|
||||
@@ -106,9 +148,6 @@ module "eks_mng_al2023_custom_ami" {
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
# Should do nothing
|
||||
cluster_service_ipv4_cidr = local.cluster_service_ipv4_cidr
|
||||
|
||||
enable_bootstrap_user_data = true
|
||||
|
||||
cloudinit_pre_nodeadm = [{
|
||||
@@ -178,15 +217,16 @@ module "eks_mng_bottlerocket_no_op" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
platform = "bottlerocket"
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
}
|
||||
|
||||
module "eks_mng_bottlerocket_additional" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
platform = "bottlerocket"
|
||||
|
||||
# Should do nothing
|
||||
cluster_service_ipv4_cidr = local.cluster_service_ipv4_cidr
|
||||
platform = "bottlerocket"
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
bootstrap_extra_args = <<-EOT
|
||||
# extra args added
|
||||
@@ -200,9 +240,10 @@ module "eks_mng_bottlerocket_custom_ami" {
|
||||
|
||||
platform = "bottlerocket"
|
||||
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
enable_bootstrap_user_data = true
|
||||
|
||||
@@ -221,6 +262,8 @@ module "eks_mng_bottlerocket_custom_template" {
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
user_data_template_path = "${path.module}/templates/bottlerocket_custom.tpl"
|
||||
|
||||
@@ -239,6 +282,9 @@ module "eks_mng_windows_no_op" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
platform = "windows"
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
}
|
||||
|
||||
module "eks_mng_windows_additional" {
|
||||
@@ -246,8 +292,8 @@ module "eks_mng_windows_additional" {
|
||||
|
||||
platform = "windows"
|
||||
|
||||
# Should do nothing
|
||||
cluster_service_ipv4_cidr = local.cluster_service_ipv4_cidr
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
pre_bootstrap_user_data = <<-EOT
|
||||
[string]$Something = 'IDoNotKnowAnyPowerShell ¯\_(ツ)_/¯'
|
||||
@@ -262,6 +308,8 @@ module "eks_mng_windows_custom_ami" {
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
enable_bootstrap_user_data = true
|
||||
|
||||
@@ -285,6 +333,9 @@ module "eks_mng_windows_custom_template" {
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
enable_bootstrap_user_data = true
|
||||
|
||||
user_data_template_path = "${path.module}/templates/windows_custom.tpl"
|
||||
@@ -308,6 +359,9 @@ module "self_mng_al2_no_op" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
is_eks_managed_node_group = false
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
}
|
||||
|
||||
module "self_mng_al2_bootstrap" {
|
||||
@@ -316,9 +370,34 @@ module "self_mng_al2_bootstrap" {
|
||||
enable_bootstrap_user_data = true
|
||||
is_eks_managed_node_group = false
|
||||
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_service_cidr = local.cluster_service_ipv4_cidr
|
||||
|
||||
pre_bootstrap_user_data = <<-EOT
|
||||
echo "foo"
|
||||
export FOO=bar
|
||||
EOT
|
||||
|
||||
bootstrap_extra_args = "--kubelet-extra-args '--node-labels=node.kubernetes.io/lifecycle=spot'"
|
||||
|
||||
post_bootstrap_user_data = <<-EOT
|
||||
echo "All done"
|
||||
EOT
|
||||
}
|
||||
|
||||
module "self_mng_al2_bootstrap_ipv6" {
|
||||
source = "../../modules/_user_data"
|
||||
|
||||
enable_bootstrap_user_data = true
|
||||
is_eks_managed_node_group = false
|
||||
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_ip_family = "ipv6"
|
||||
cluster_service_cidr = local.cluster_service_ipv6_cidr
|
||||
|
||||
pre_bootstrap_user_data = <<-EOT
|
||||
echo "foo"
|
||||
@@ -338,9 +417,10 @@ module "self_mng_al2_custom_template" {
|
||||
enable_bootstrap_user_data = true
|
||||
is_eks_managed_node_group = false
|
||||
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_name = local.name
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
cluster_service_cidr = local.cluster_service_ipv4_cidr
|
||||
|
||||
user_data_template_path = "${path.module}/templates/linux_custom.tpl"
|
||||
|
||||
@@ -366,6 +446,9 @@ module "self_mng_al2023_no_op" {
|
||||
platform = "al2023"
|
||||
|
||||
is_eks_managed_node_group = false
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
}
|
||||
|
||||
module "self_mng_al2023_bootstrap" {
|
||||
@@ -452,6 +535,9 @@ module "self_mng_bottlerocket_no_op" {
|
||||
platform = "bottlerocket"
|
||||
|
||||
is_eks_managed_node_group = false
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
}
|
||||
|
||||
module "self_mng_bottlerocket_bootstrap" {
|
||||
@@ -466,8 +552,8 @@ module "self_mng_bottlerocket_bootstrap" {
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
|
||||
# Should do nothing
|
||||
cluster_service_ipv4_cidr = local.cluster_service_ipv4_cidr
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
bootstrap_extra_args = <<-EOT
|
||||
# extra args added
|
||||
@@ -488,6 +574,9 @@ module "self_mng_bottlerocket_custom_template" {
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
user_data_template_path = "${path.module}/templates/bottlerocket_custom.tpl"
|
||||
|
||||
bootstrap_extra_args = <<-EOT
|
||||
@@ -507,6 +596,9 @@ module "self_mng_windows_no_op" {
|
||||
platform = "windows"
|
||||
|
||||
is_eks_managed_node_group = false
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
}
|
||||
|
||||
module "self_mng_windows_bootstrap" {
|
||||
@@ -521,8 +613,8 @@ module "self_mng_windows_bootstrap" {
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
|
||||
# Should do nothing
|
||||
cluster_service_ipv4_cidr = local.cluster_service_ipv4_cidr
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
pre_bootstrap_user_data = <<-EOT
|
||||
[string]$Something = 'IDoNotKnowAnyPowerShell ¯\_(ツ)_/¯'
|
||||
@@ -547,6 +639,9 @@ module "self_mng_windows_custom_template" {
|
||||
cluster_endpoint = local.cluster_endpoint
|
||||
cluster_auth_base64 = local.cluster_auth_base64
|
||||
|
||||
# Hard requirement
|
||||
cluster_service_cidr = local.cluster_service_cidr
|
||||
|
||||
user_data_template_path = "${path.module}/templates/windows_custom.tpl"
|
||||
|
||||
pre_bootstrap_user_data = <<-EOT
|
||||
|
||||
Reference in New Issue
Block a user