-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating EKS container insights to replace deamonset with tf resource
- Loading branch information
Showing
10 changed files
with
129 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
data "aws_partition" "current" {} | ||
|
||
data "aws_caller_identity" "current" {} | ||
|
||
data "aws_region" "current" {} | ||
|
||
data "aws_eks_cluster" "eks_cluster" { | ||
name = var.eks_cluster_id | ||
} | ||
|
||
locals { | ||
eks_cluster_endpoint = data.aws_eks_cluster.eks_cluster.endpoint | ||
name = "amazon-cloudwatch-observability" | ||
kubernetes_version = var.eks_cluster_version | ||
eks_oidc_issuer_url = replace(data.aws_eks_cluster.eks_cluster.identity[0].oidc[0].issuer, "https://", "") | ||
|
||
addon_context = { | ||
aws_caller_identity_account_id = data.aws_caller_identity.current.account_id | ||
aws_caller_identity_arn = data.aws_caller_identity.current.arn | ||
aws_partition_id = data.aws_partition.current.partition | ||
aws_region_name = data.aws_region.current.name | ||
eks_oidc_provider_arn = "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${local.eks_oidc_issuer_url}" | ||
eks_cluster_id = data.aws_eks_cluster.eks_cluster.id | ||
tags = var.tags | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,7 @@ | ||
provider "aws" { | ||
region = var.aws_region | ||
} | ||
|
||
provider "kubernetes" { | ||
host = local.eks_cluster_endpoint | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster.certificate_authority[0].data) | ||
exec { | ||
api_version = "client.authentication.k8s.io/v1beta1" | ||
args = ["eks", "get-token", "--cluster-name", var.eks_cluster_id] | ||
command = "aws" | ||
} | ||
} | ||
|
||
provider "helm" { | ||
kubernetes { | ||
host = local.eks_cluster_endpoint | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster.certificate_authority[0].data) | ||
exec { | ||
api_version = "client.authentication.k8s.io/v1beta1" | ||
args = ["eks", "get-token", "--cluster-name", var.eks_cluster_id] | ||
command = "aws" | ||
} | ||
} | ||
} | ||
|
||
|
||
# Deploy the CW Application Signals and Container Insights | ||
|
||
module "eks_container_insights" { | ||
source = "../../modules/eks-container-insights" | ||
eks_cluster_id = var.eks_cluster_id | ||
source = "./modules/eks-container-insights" | ||
cluster_name = var.cluster_name | ||
enable_amazon_eks_cw_observability = true | ||
create_cloudwatch_observability_irsa_role = true | ||
eks_oidc_provider_arn = local.addon_context.eks_oidc_provider_arn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,46 @@ | ||
provider "kubernetes" { | ||
host = data.aws_eks_cluster.eks_cluster.endpoint | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster.certificate_authority[0].data) | ||
exec { | ||
api_version = "client.authentication.k8s.io/v1beta1" | ||
args = ["eks", "get-token", "--cluster-name", local.addon_context.eks_cluster_id] | ||
command = "aws" | ||
} | ||
locals { | ||
name = "amazon-cloudwatch-observability" | ||
} | ||
|
||
provider "helm" { | ||
kubernetes { | ||
host = data.aws_eks_cluster.eks_cluster.endpoint | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster.certificate_authority[0].data) | ||
exec { | ||
api_version = "client.authentication.k8s.io/v1beta1" | ||
args = ["eks", "get-token", "--cluster-name", local.addon_context.eks_cluster_id] | ||
command = "aws" | ||
module "cloudwatch_observability_irsa_role" { | ||
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" | ||
count = var.create_cloudwatch_observability_irsa_role ? 1 : 0 | ||
|
||
role_name = "cloudwatch-observability" | ||
attach_cloudwatch_observability_policy = true | ||
|
||
oidc_providers = { | ||
ex = { | ||
provider_arn = var.eks_oidc_provider_arn | ||
namespace_service_accounts = ["amazon-cloudwatch:cloudwatch-agent"] | ||
} | ||
} | ||
} | ||
|
||
module "helm_addon" { | ||
source = "github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon?ref=v4.32.1" | ||
manage_via_gitops = var.manage_via_gitops | ||
set_values = local.set_values | ||
helm_config = local.helm_config | ||
irsa_config = local.irsa_config | ||
addon_context = local.addon_context | ||
data "aws_eks_addon_version" "eks_addon_version" { | ||
addon_name = local.name | ||
kubernetes_version = var.kubernetes_version | ||
most_recent = var.most_recent | ||
} | ||
|
||
resource "aws_eks_addon" "amazon-cloudwatch-observability" { | ||
count = var.enable_amazon_eks_cw_observability ? 1 : 0 | ||
|
||
cluster_name = var.cluster_name | ||
addon_name = local.name | ||
addon_version = try(var.addon_config.addon_version, data.aws_eks_addon_version.eks_addon_version.version) | ||
resolve_conflicts_on_create = try(var.addon_config.resolve_conflicts_on_create, "OVERWRITE") | ||
service_account_role_arn = try(module.cloudwatch_observability_irsa_role[0].iam_role_arn, null) | ||
preserve = try(var.addon_config.preserve, true) | ||
configuration_values = try(var.addon_config.configuration_values, null) | ||
|
||
tags = merge( | ||
# var.addon_context.tags, | ||
try(var.addon_config.tags, {}) | ||
) | ||
} | ||
|
||
resource "aws_iam_service_linked_role" "application-signals-cw" { | ||
count = var.create_cloudwatch_application_signals_role ? 1 : 0 | ||
aws_service_name = "application-signals.cloudwatch.amazonaws.com" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +0,0 @@ | ||
output "release_metadata" { | ||
description = "Map of attributes of the Helm release metadata" | ||
value = module.helm_addon.release_metadata | ||
} | ||
|
||
output "irsa_arn" { | ||
description = "IAM role ARN for the service account" | ||
value = module.helm_addon.irsa_arn | ||
} | ||
|
||
output "irsa_name" { | ||
description = "IAM role name for the service account" | ||
value = module.helm_addon.irsa_name | ||
} | ||
|
||
output "service_account" { | ||
description = "Name of Kubernetes service account" | ||
value = module.helm_addon.service_account | ||
} | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,50 @@ | ||
variable "helm_config" { | ||
description = "Helm provider config for adot-exporter-for-eks-on-ec2" | ||
type = any | ||
default = {} | ||
variable "cluster_name" { | ||
default = "eks-cw" | ||
type = string | ||
} | ||
|
||
variable "manage_via_gitops" { | ||
variable "enable_amazon_eks_cw_observability" { | ||
description = "Enable Amazon EKS CloudWatch Observability add-on" | ||
type = bool | ||
description = "Determines if the add-on should be managed via GitOps." | ||
default = false | ||
} | ||
|
||
variable "irsa_policies" { | ||
description = "Additional IAM policies for a IAM role for service accounts" | ||
type = list(string) | ||
default = [] | ||
variable "addon_config" { | ||
description = "Amazon EKS Managed CloudWatch Observability Add-on config" | ||
type = any | ||
default = {} | ||
} | ||
|
||
variable "eks_cluster_id" { | ||
description = "EKS Cluster Id" | ||
variable "cluster_version" { | ||
description = "The Version of Kubernetes to deploy" | ||
type = string | ||
default = "1.25" | ||
} | ||
|
||
variable "aws_cloudwatch_metrics_chart_verison" { | ||
description = "AWS CloudWatch Observability Metrics helm chart version" | ||
variable "kubernetes_version" { | ||
description = "Kubernetes version" | ||
type = string | ||
default = "0.0.7" | ||
default = "1.28" | ||
} | ||
|
||
variable "tags" { | ||
description = "Additional tags (e.g. `map('BusinessUnit`,`XYZ`)" | ||
type = map(string) | ||
default = {} | ||
variable "most_recent" { | ||
type = string | ||
default = "false" | ||
} | ||
|
||
variable "eks_oidc_provider_arn" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "irsa_iam_role_path" { | ||
description = "IAM role path for IRSA roles" | ||
variable "create_cloudwatch_observability_irsa_role" { | ||
type = string | ||
default = "/" | ||
default = true | ||
description = "Create a Cloudwatch Observability IRSA" | ||
} | ||
|
||
variable "irsa_iam_permissions_boundary" { | ||
description = "IAM permissions boundary for IRSA roles" | ||
variable "create_cloudwatch_application_signals_role" { | ||
type = string | ||
default = null | ||
default = true | ||
description = "Create a Cloudwatch Application Signals service-linked role" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters