From e686c5ff13fea7e58167b188a2b3d791c098c468 Mon Sep 17 00:00:00 2001 From: alade001 Date: Wed, 4 Sep 2024 17:43:47 -0400 Subject: [PATCH 1/4] uncommented .terraform.lock.hcl in the .gitignore file --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 98d790c..6864ea0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ **/.terragrunt-cache/* # terraform lock file. -**/.terraform.lock.hcl +.terraform.lock.hcl # .tfstate files *.tfstate From d877e2966f23396508fc09fda859930a071510ad Mon Sep 17 00:00:00 2001 From: alade001 Date: Fri, 6 Sep 2024 09:04:02 -0400 Subject: [PATCH 2/4] uncommented .terraform.lock.hcl in the .gitignore file --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6864ea0..98d790c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ **/.terragrunt-cache/* # terraform lock file. -.terraform.lock.hcl +**/.terraform.lock.hcl # .tfstate files *.tfstate From 7ffc8b83c72cc3a5a02f14b5d72756df0f18dda8 Mon Sep 17 00:00:00 2001 From: mcgin314 Date: Fri, 13 Sep 2024 07:32:45 -0400 Subject: [PATCH 3/4] Add finops tags to karpenter provisioned nodes --- ec2_node_class.yaml.tpl | 3 +++ main.tf | 1 + 2 files changed, 4 insertions(+) diff --git a/ec2_node_class.yaml.tpl b/ec2_node_class.yaml.tpl index 74c4172..2a8deef 100644 --- a/ec2_node_class.yaml.tpl +++ b/ec2_node_class.yaml.tpl @@ -58,3 +58,6 @@ spec: # Optional, configures detailed monitoring for the instance detailedMonitoring: true + + # Add finops tags to karpenter provisioned nodes + tags: ${tags} diff --git a/main.tf b/main.tf index 8831008..2860b72 100644 --- a/main.tf +++ b/main.tf @@ -200,6 +200,7 @@ resource "kubectl_manifest" "karpenter_ec2_node_class" { ] yaml_body = templatefile("${path.module}/ec2_node_class.yaml.tpl", { cluster_name = var.cluster_name + tags = jsonencode(var.tags) amd_ami_family = "Bottlerocket" amd_ami_alias = "bottlerocket" }) From 0b9b0adfc13532dbd305b57b8e571e68fe875907 Mon Sep 17 00:00:00 2001 From: mcgin314 Date: Fri, 13 Sep 2024 08:17:40 -0400 Subject: [PATCH 4/4] Lookup tags to pass to karpenter CRD --- main.tf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 2860b72..c010bbc 100644 --- a/main.tf +++ b/main.tf @@ -192,6 +192,9 @@ resource "aws_iam_service_linked_role" "ec2_spot" { aws_service_name = "spot.amazonaws.com" } +# Get the default tags from the provider +data "aws_default_tags" "default_tags" {} + # SHOULD PROBABLY PUT THESE OBJECTS INTO A HELM CHART # Create karpenter default resource "kubectl_manifest" "karpenter_ec2_node_class" { @@ -200,7 +203,7 @@ resource "kubectl_manifest" "karpenter_ec2_node_class" { ] yaml_body = templatefile("${path.module}/ec2_node_class.yaml.tpl", { cluster_name = var.cluster_name - tags = jsonencode(var.tags) + tags = jsonencode(data.aws_default_tags.default_tags.tags) amd_ami_family = "Bottlerocket" amd_ami_alias = "bottlerocket" })