From eb157a624c3a24de58ae0fd81bd4e20b47522d33 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Thu, 14 Nov 2024 16:27:17 -0500 Subject: [PATCH 01/19] Add E2E EKS Terraform environment. --- terraform/e2e/eks/main.tf | 165 ++++++++++++++++++ terraform/e2e/eks/providers.tf | 25 +++ terraform/e2e/eks/variables.tf | 82 +++++++++ .../jmx/files/cwagent_configs/jvm_tomcat.json | 30 ++++ test/e2e/jmx/validate_test.go | 1 + 5 files changed, 303 insertions(+) create mode 100644 terraform/e2e/eks/main.tf create mode 100644 terraform/e2e/eks/providers.tf create mode 100644 terraform/e2e/eks/variables.tf create mode 100644 test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json create mode 100644 test/e2e/jmx/validate_test.go diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf new file mode 100644 index 000000000..896b4dca1 --- /dev/null +++ b/terraform/e2e/eks/main.tf @@ -0,0 +1,165 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + +module "common" { + source = "../../common" +} + +module "basic_components" { + source = "../../basic_components" +} + +locals { + aws_eks = "aws eks --region ${var.region}" + cluster_name = var.cluster_name != "" ? var.cluster_name : "cwagent-monitoring-config-e2e-eks" + agent-config = fileexists(var.agent-config) ? var.agent-config : "" +} + +data "aws_eks_cluster_auth" "this" { + name = aws_eks_cluster.this.name +} + +resource "aws_eks_cluster" "this" { + name = "${local.cluster_name}-${module.common.testing_id}" + role_arn = module.basic_components.role_arn + version = var.k8s_version + vpc_config { + subnet_ids = module.basic_components.public_subnet_ids + security_group_ids = [module.basic_components.security_group] + } +} + +resource "aws_eks_node_group" "this" { + cluster_name = aws_eks_cluster.this.name + node_group_name = "${local.cluster_name}-node" + node_role_arn = aws_iam_role.node_role.arn + subnet_ids = module.basic_components.public_subnet_ids + + scaling_config { + desired_size = 1 + max_size = 1 + min_size = 1 + } + + ami_type = "AL2_x86_64" + capacity_type = "ON_DEMAND" + disk_size = 20 + instance_types = ["t3a.medium"] + + depends_on = [ + aws_iam_role_policy_attachment.node_CloudWatchAgentServerPolicy, + aws_iam_role_policy_attachment.node_AmazonEC2ContainerRegistryReadOnly, + aws_iam_role_policy_attachment.node_AmazonEKS_CNI_Policy, + aws_iam_role_policy_attachment.node_AmazonEKSWorkerNodePolicy + ] +} + +resource "aws_iam_role" "node_role" { + name = "${local.cluster_name}-Worker-Role-${module.common.testing_id}" + + assume_role_policy = < Date: Thu, 14 Nov 2024 16:30:06 -0500 Subject: [PATCH 02/19] Remove files. --- terraform/e2e/eks/$HOME/.kube/config | 51 +++++++++++++++++++ terraform/e2e/eks/helm-charts | 1 + .../jmx/files/cwagent_configs/jvm_tomcat.json | 30 ----------- test/e2e/jmx/validate_test.go | 1 - 4 files changed, 52 insertions(+), 31 deletions(-) create mode 100644 terraform/e2e/eks/$HOME/.kube/config create mode 160000 terraform/e2e/eks/helm-charts delete mode 100644 test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json delete mode 100644 test/e2e/jmx/validate_test.go diff --git a/terraform/e2e/eks/$HOME/.kube/config b/terraform/e2e/eks/$HOME/.kube/config new file mode 100644 index 000000000..b1f1b877d --- /dev/null +++ b/terraform/e2e/eks/$HOME/.kube/config @@ -0,0 +1,51 @@ +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQWV5Z0F3SUJBZ0lIZVhUTi9jOWtRREFOQmdrcWhraUc5dzBCQVFzRkFEQVZNUk13RVFZRFZRUUQKRXdwcmRXSmxjbTVsZEdWek1CNFhEVEkwTVRFeE5ERTRORGswTlZvWERUTTBNVEV4TWpFNE5UUTBOVm93RlRFVApNQkVHQTFVRUF4TUthM1ZpWlhKdVpYUmxjekNDQVNJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DCmdnRUJBUFFiVmdUa20wQnF4NTA4UnhCczZETmdlQnFva1hBd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K1ZIYkE4dHRjRGVlbTJEeUQKK1FvVVAvN25tZ0U9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K + server: https://815134A5AA1C2E4604C5B7AFE69DC525.gr7.us-west-2.eks.amazonaws.com + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCVENDQWUyZ0F3SUJBZ0lJTUZtWEF4QloyeXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRFeE1UUXlNREEzTlRoYUZ3MHpOREV4TVRJeU1ERXlOVGhhTUJVeApFekFSQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLCkFvSUJBUUMrcGhDTlFBTW1iWWtZRUpRQkhkbVQzWGh5ay80VVV6VDlBSDFzQXQ2M0REN2hJRkZaZmVuTlR2cUEKcXUwTjdQOGNDcFdrSFNzQStETTE2alBLcE0yUVFJNkg4eHlRUzhYSnRucjVvVGxZQnJDTDgvdGJlTCs1MVlQdgpnQ0xXVU4xenFJbXhhVXphMEllMXp6WXluMjJhZU1hRDQraDA5eCt2T1cvcE1QUmNjdWxHMkZpSXZHYVNHNXFRCkRNK2RwZjhnMW91VXNuMWJMZzhDRThCTFUvaXFKbmlHOFNoaGhjYzJ0RTd1QkVtNmZIS3ZwN1NHQ09oditDUVcKNlhyMFNJUEYrcnFYaUFNQjdVTmZvajhLcGN0bk9KYUhxUTdLV1ljbkFwdi9uQVlPOURzMURISEdzVFBNNEQySQpMcVNaaWpQeE9nMEozeGhOYVU5NmdHSU5wV2VoQWdNQkFBR2pXVEJYTUE0R0ExVWREd0VCL3dRRUF3SUNwREFQCkJnTlZIUk1CQWY4RUJUQURBUUgvTUIwR0ExVWREZ1FXQkJRZHpZc2w0QVAvOVJZVnlqSTNLL2dCMERvSEpEQVYKQmdOVkhSRUVEakFNZ2dwcmRXSmxjbTVsZEdWek1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQkFRQjl3ZytQYjBnMApSeHFZczh1K2ZCZEszZHpaY1NuVE9idW9DU0pvZEI2NzVic3VWRlkvYk9HeTJHb0VsazdMbDIrTnBsVGM1UitvCm4xNlRMVGxMb1FEZE1qa0tXcDRmK09FbHlLb09vRi9Objd4OG9waDBNaEVzZXE1NzZvUjhsMExsRkF4QyticXYKMUdYWG9GR3JQY0JGMitjbk1tbkcyTU1iRVEwL0NRV0M3dkx0ZUNqYll4a0FZejZZd3JIbC9HQ3k2TENFMmhMdgpLZkkxS0JZUkkvU2wya2d2L1FFbTQrb25KM3RHcHBGNmsyU0tFMkplNzErR1pXUXphcGJGK1JZWFFuRHJuN3FzCjIybmJZSnpMblptUXRvbVFVZ0MwbitKNG95QjFtSmlMVk4vaHJBaDAvV29Wd2VoQ2xmRjNEVW1JZ1JUQ1dVM3UKZk1UYUNEaE5XemUyCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K + server: https://92BAADEAD75DB06218CE1125A95FFA4B.gr7.us-west-2.eks.amazonaws.com + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +contexts: +- context: + cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 +- context: + cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +current-context: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +kind: Config +preferences: {} +users: +- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + user: + exec: + apiVersion: client.authentication.k8s.io/v1beta1 + args: + - --region + - us-west-2 + - eks + - get-token + - --cluster-name + - cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + - --output + - json + command: aws +- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + user: + exec: + apiVersion: client.authentication.k8s.io/v1beta1 + args: + - --region + - us-west-2 + - eks + - get-token + - --cluster-name + - cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + - --output + - json + command: aws diff --git a/terraform/e2e/eks/helm-charts b/terraform/e2e/eks/helm-charts new file mode 160000 index 000000000..0f274dd75 --- /dev/null +++ b/terraform/e2e/eks/helm-charts @@ -0,0 +1 @@ +Subproject commit 0f274dd75b84e284bc51130089028d64e3001fea diff --git a/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json b/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json deleted file mode 100644 index f5e592544..000000000 --- a/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "metrics": { - "namespace": "JVMXX", - "metrics_collected": { - "jmx": { - "endpoint": "localhost:9999", - "jvm": { - "measurement": [ - "jvm.classes.loaded", - "jvm.gc.collections.count", - "jvm.gc.collections.elapsed", - "jvm.memory.heap.committed", - "jvm.memory.heap.init", - "jvm.memory.heap.max", - "jvm.memory.heap.used", - "jvm.memory.nonheap.committed", - "jvm.memory.nonheap.init", - "jvm.memory.nonheap.max", - "jvm.memory.nonheap.used", - "jvm.memory.pool.committed", - "jvm.memory.pool.init", - "jvm.memory.pool.max", - "jvm.memory.pool.used", - "jvm.threads.count" - ] - } - } - } - } -} \ No newline at end of file diff --git a/test/e2e/jmx/validate_test.go b/test/e2e/jmx/validate_test.go deleted file mode 100644 index f9f0a6231..000000000 --- a/test/e2e/jmx/validate_test.go +++ /dev/null @@ -1 +0,0 @@ -package jmx From da92a760eb38e3c7f9bd583c5bc88b9075a4d951 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Thu, 14 Nov 2024 16:32:05 -0500 Subject: [PATCH 03/19] Remove files. --- terraform/e2e/eks/$HOME/.kube/config | 51 ---------------------------- terraform/e2e/eks/helm-charts | 1 - 2 files changed, 52 deletions(-) delete mode 100644 terraform/e2e/eks/$HOME/.kube/config delete mode 160000 terraform/e2e/eks/helm-charts diff --git a/terraform/e2e/eks/$HOME/.kube/config b/terraform/e2e/eks/$HOME/.kube/config deleted file mode 100644 index b1f1b877d..000000000 --- a/terraform/e2e/eks/$HOME/.kube/config +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: v1 -clusters: -- cluster: - certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQWV5Z0F3SUJBZ0lIZVhUTi9jOWtRREFOQmdrcWhraUc5dzBCQVFzRkFEQVZNUk13RVFZRFZRUUQKRXdwcmRXSmxjbTVsZEdWek1CNFhEVEkwTVRFeE5ERTRORGswTlZvWERUTTBNVEV4TWpFNE5UUTBOVm93RlRFVApNQkVHQTFVRUF4TUthM1ZpWlhKdVpYUmxjekNDQVNJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DCmdnRUJBUFFiVmdUa20wQnF4NTA4UnhCczZETmdlQnFva1hBdW9SUnpOT2RwVlQrbGhhTW11U3RTNElFQnNBbWgKNWQyMTFrRy9RMnV3L0NJVXNTc25Kdm5PU1UxTU9mdVVpRFRublJIUGhuT3hTbklaSjNwSFlTTXJrdGljVzRHSgp6dTMyeHhUdEk3WWpZVG1QcUUyS1JBcjZSN2c4R1dkN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W9DU0pvZEI2NzVic3VWRlkvYk9HeTJHb0VsazdMbDIrTnBsVGM1UitvCm4xNlRMVGxMb1FEZE1qa0tXcDRmK09FbHlLb09vRi9Objd4OG9waDBNaEVzZXE1NzZvUjhsMExsRkF4QyticXYKMUdYWG9GR3JQY0JGMitjbk1tbkcyTU1iRVEwL0NRV0M3dkx0ZUNqYll4a0FZejZZd3JIbC9HQ3k2TENFMmhMdgpLZkkxS0JZUkkvU2wya2d2L1FFbTQrb25KM3RHcHBGNmsyU0tFMkplNzErR1pXUXphcGJGK1JZWFFuRHJuN3FzCjIybmJZSnpMblptUXRvbVFVZ0MwbitKNG95QjFtSmlMVk4vaHJBaDAvV29Wd2VoQ2xmRjNEVW1JZ1JUQ1dVM3UKZk1UYUNEaE5XemUyCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K - server: https://92BAADEAD75DB06218CE1125A95FFA4B.gr7.us-west-2.eks.amazonaws.com - name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 -contexts: -- context: - cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 - user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 - name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 -- context: - cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 - user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 - name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 -current-context: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 -kind: Config -preferences: {} -users: -- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 - user: - exec: - apiVersion: client.authentication.k8s.io/v1beta1 - args: - - --region - - us-west-2 - - eks - - get-token - - --cluster-name - - cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 - - --output - - json - command: aws -- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 - user: - exec: - apiVersion: client.authentication.k8s.io/v1beta1 - args: - - --region - - us-west-2 - - eks - - get-token - - --cluster-name - - cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 - - --output - - json - command: aws diff --git a/terraform/e2e/eks/helm-charts b/terraform/e2e/eks/helm-charts deleted file mode 160000 index 0f274dd75..000000000 --- a/terraform/e2e/eks/helm-charts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0f274dd75b84e284bc51130089028d64e3001fea From ef3d5ee8a28938b8d13ae1efd3c7baad9f9e73ee Mon Sep 17 00:00:00 2001 From: musa-asad Date: Thu, 14 Nov 2024 16:34:41 -0500 Subject: [PATCH 04/19] Remove unused local. --- terraform/e2e/eks/main.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index 896b4dca1..bc9cc96e7 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -12,7 +12,6 @@ module "basic_components" { locals { aws_eks = "aws eks --region ${var.region}" cluster_name = var.cluster_name != "" ? var.cluster_name : "cwagent-monitoring-config-e2e-eks" - agent-config = fileexists(var.agent-config) ? var.agent-config : "" } data "aws_eks_cluster_auth" "this" { From 661107a8327011f309b5771f141ddd6dcdccd83e Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 12:25:58 -0500 Subject: [PATCH 05/19] Add sample applicatin configuration. --- terraform/e2e/eks/$HOME/.kube/config | 51 +++++++++++++++++++ terraform/e2e/eks/main.tf | 19 ++++--- terraform/e2e/eks/variables.tf | 10 ++++ .../jmx/files/cwagent_configs/jvm_tomcat.json | 40 +++++++++++++++ .../tomcat-deployment.yaml | 0 test/e2e/jmx/validate_test.go | 14 +++++ 6 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 terraform/e2e/eks/$HOME/.kube/config create mode 100644 test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json create mode 100644 test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml create mode 100644 test/e2e/jmx/validate_test.go diff --git a/terraform/e2e/eks/$HOME/.kube/config b/terraform/e2e/eks/$HOME/.kube/config new file mode 100644 index 000000000..b1f1b877d --- /dev/null +++ b/terraform/e2e/eks/$HOME/.kube/config @@ -0,0 +1,51 @@ +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQWV5Z0F3SUJBZ0lIZVhUTi9jOWtRREFOQmdrcWhraUc5dzBCQVFzRkFEQVZNUk13RVFZRFZRUUQKRXdwcmRXSmxjbTVsZEdWek1CNFhEVEkwTVRFeE5ERTRORGswTlZvWERUTTBNVEV4TWpFNE5UUTBOVm93RlRFVApNQkVHQTFVRUF4TUthM1ZpWlhKdVpYUmxjekNDQVNJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DCmdnRUJBUFFiVmdUa20wQnF4NTA4UnhCczZETmdlQnFva1hBdW9SUnpOT2RwVlQrbGhhTW11U3RTNElFQnNBbWgKNWQyMTFrRy9RMnV3L0NJVXNTc25Kdm5PU1UxTU9mdVVpRFRublJIUGhuT3hTbklaSjNwSFlTTXJrdGljVzRHSgp6dTMyeHhUdEk3WWpZVG1QcUUyS1JBcjZSN2c4R1dkNGpmVzUyb1RHMTRxVE9QNDVyNlJsYmQvSUtmUi9KN01iCm81cVdrdW9PVnFyNkt3ZGh2eG04aGlaL0t0UDMyTWJUbzdxajFrUEpGQVhPK2ZWNGlDWnd5ZXZnRGd2bUJEZ1MKeGVwTDZSdUNRa2JwZldieXdFRmcwU2tWYVVibTB5ZUJCUXpFWDdjSU5ZQkJaN3ptN3NqdGNuaWZNd1B1RlJueApwK2VlZ2tkU1dUTVNqcjIrd21KVjJhQXcxb01DQXdFQUFhTlpNRmN3RGdZRFZSMFBBUUgvQkFRREFnS2tNQThHCkExVWRFd0VCL3dRRk1BTUJBZjh3SFFZRFZSME9CQllFRktQcWlsakFMSk4rRWIveUZrREM3YXZKZVE1aU1CVUcKQTFVZEVRUU9NQXlDQ210MVltVnlibVYwWlhNd0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFBeisxZUViK0VnNgo2QUhFVTlHOUVnSFBNUHpQSE4veHd3WXY4NlEyWE5aRWRIOWFOakpHTjN4ZDl1WnZvWjBmbzJnNmdSbHE5d0lFCmxHVjl2TEljZS8xVnhlcDFaL21WMDY5dUFwTnlWZkZQekJPTXJXSTJxbW5VTVc1NWJYZktnbnNUM1E3dWVDYlIKa1I2c3RrY0JkMmNYME14THVaanNEa0tOcU5vVDkxUzhyOFpVWnNPRzUrSWN6K09ySWEyOUhaNWR0Rk96WHVYYQpqZ1pJc0JvdTQwNVF1L1ZlL0pkS3haTDJjbE9BUk5FN0NjVEZpSmJ6WkNQbnJXdVFhQUZCdTgvTkx1K2x6dXlSCllMZ1UrNWVjcDdXVm5oYVhPYk50Rk5INTR0TzZ2d2s0NXhBWDVRMVhnVi9jVk8zK1ZIYkE4dHRjRGVlbTJEeUQKK1FvVVAvN25tZ0U9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K + server: https://815134A5AA1C2E4604C5B7AFE69DC525.gr7.us-west-2.eks.amazonaws.com + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCVENDQWUyZ0F3SUJBZ0lJTUZtWEF4QloyeXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzV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VEwL0NRV0M3dkx0ZUNqYll4a0FZejZZd3JIbC9HQ3k2TENFMmhMdgpLZkkxS0JZUkkvU2wya2d2L1FFbTQrb25KM3RHcHBGNmsyU0tFMkplNzErR1pXUXphcGJGK1JZWFFuRHJuN3FzCjIybmJZSnpMblptUXRvbVFVZ0MwbitKNG95QjFtSmlMVk4vaHJBaDAvV29Wd2VoQ2xmRjNEVW1JZ1JUQ1dVM3UKZk1UYUNEaE5XemUyCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K + server: https://92BAADEAD75DB06218CE1125A95FFA4B.gr7.us-west-2.eks.amazonaws.com + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +contexts: +- context: + cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 +- context: + cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +current-context: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 +kind: Config +preferences: {} +users: +- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + user: + exec: + apiVersion: client.authentication.k8s.io/v1beta1 + args: + - --region + - us-west-2 + - eks + - get-token + - --cluster-name + - cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 + - --output + - json + command: aws +- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + user: + exec: + apiVersion: client.authentication.k8s.io/v1beta1 + args: + - --region + - us-west-2 + - eks + - get-token + - --cluster-name + - cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 + - --output + - json + command: aws diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index bc9cc96e7..0bd9efb93 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -35,9 +35,9 @@ resource "aws_eks_node_group" "this" { subnet_ids = module.basic_components.public_subnet_ids scaling_config { - desired_size = 1 - max_size = 1 - min_size = 1 + desired_size = 2 + max_size = 2 + min_size = 2 } ami_type = "AL2_x86_64" @@ -121,14 +121,18 @@ resource "null_resource" "helm_charts" { } } -resource "null_resource" "install_helm_release" { +resource "null_resource" "install_helm_release_and_sample_app" { depends_on = [ null_resource.kubectl, - aws_eks_cluster.this + null_resource.helm_charts, + aws_eks_cluster.this, + aws_eks_node_group.this ] provisioner "local-exec" { command = <<-EOT + ${local.aws_eks} update-kubeconfig --name ${aws_eks_cluster.this.name} + helm upgrade --install amazon-cloudwatch-observability \ ${path.module}/helm-charts/charts/amazon-cloudwatch-observability \ --values ${path.module}/helm-charts/charts/amazon-cloudwatch-observability/values.yaml \ @@ -145,6 +149,9 @@ resource "null_resource" "install_helm_release" { ${var.agent-config != "" ? "--set-json agent.config='${jsonencode(jsondecode(file(var.agent-config)))}'" : ""} \ ${var.otel-config != "" ? "--set-file agent.otelConfig=${yamlencode(yamldecode(file(var.otel-config)))}" : ""} \ ${var.prometheus-config != "" ? "--set-file agent.prometheus.config=${yamlencode(yamldecode(file(var.prometheus-config)))}" : ""} + + kubectl apply -f ${var.sample-app} + kubectl wait --for=condition=available --timeout=300s deployment/${var.sample-app-name} EOT environment = { @@ -155,7 +162,7 @@ resource "null_resource" "install_helm_release" { resource "null_resource" "test" { depends_on = [ - null_resource.install_helm_release + null_resource.install_helm_release_and_sample_app ] provisioner "local-exec" { diff --git a/terraform/e2e/eks/variables.tf b/terraform/e2e/eks/variables.tf index 8c2dc04f0..f3494742e 100644 --- a/terraform/e2e/eks/variables.tf +++ b/terraform/e2e/eks/variables.tf @@ -79,4 +79,14 @@ variable "cloudwatch_agent_operator_repository_url" { variable "validate_test" { type = string default = "../../../test/e2e/jmx/validate_test.go" +} + +variable "sample-app" { + type = string + default = "../../../test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml" +} + +variable "sample-app-name" { + type = string + default = "tomcat-deployment" } \ No newline at end of file diff --git a/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json b/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json new file mode 100644 index 000000000..c0c2a10dd --- /dev/null +++ b/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json @@ -0,0 +1,40 @@ +{ + "metrics": { + "namespace": "JVM_TOMCAT_E2E", + "metrics_collected": { + "jmx": { + "jvm": { + "measurement": [ + "jvm.classes.loaded", + "jvm.gc.collections.count", + "jvm.gc.collections.elapsed", + "jvm.memory.heap.committed", + "jvm.memory.heap.init", + "jvm.memory.heap.max", + "jvm.memory.heap.used", + "jvm.memory.nonheap.committed", + "jvm.memory.nonheap.init", + "jvm.memory.nonheap.max", + "jvm.memory.nonheap.used", + "jvm.memory.pool.committed", + "jvm.memory.pool.init", + "jvm.memory.pool.max", + "jvm.memory.pool.used", + "jvm.threads.count" + ] + }, + "tomcat": { + "measurement": [ + "tomcat.sessions", + "tomcat.errors", + "tomcat.request_count", + "tomcat.max_time", + "tomcat.processing_time", + "tomcat.traffic", + "tomcat.threads" + ] + } + } + } + } +} \ No newline at end of file diff --git a/test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml b/test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/test/e2e/jmx/validate_test.go b/test/e2e/jmx/validate_test.go new file mode 100644 index 000000000..73093fee3 --- /dev/null +++ b/test/e2e/jmx/validate_test.go @@ -0,0 +1,14 @@ +package jmx + +import ( + "fmt" + "testing" +) + +func TestMetrics(t *testing.T) { + fmt.Printf("TestMetrics") +} + +func TestResources(t *testing.T) { + fmt.Printf("TestResources") +} From ef60c954496a3065d4eaa456c9aab61ad86546a6 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 12:27:55 -0500 Subject: [PATCH 06/19] Remove files. --- terraform/e2e/eks/$HOME/.kube/config | 51 ------------------- .../jmx/files/cwagent_configs/jvm_tomcat.json | 40 --------------- .../tomcat-deployment.yaml | 0 test/e2e/jmx/validate_test.go | 14 ----- 4 files changed, 105 deletions(-) delete mode 100644 terraform/e2e/eks/$HOME/.kube/config delete mode 100644 test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json delete mode 100644 test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml delete mode 100644 test/e2e/jmx/validate_test.go diff --git a/terraform/e2e/eks/$HOME/.kube/config b/terraform/e2e/eks/$HOME/.kube/config deleted file mode 100644 index b1f1b877d..000000000 --- a/terraform/e2e/eks/$HOME/.kube/config +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: v1 -clusters: -- cluster: - certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQWV5Z0F3SUJBZ0lIZVhUTi9jOWtRREFOQmdrcWhraUc5dzBCQVFzRkFEQVZNUk13RVFZRFZRUUQKRXdwcmRXSmxjbTVsZEdWek1CNFhEVEkwTVRFeE5ERTRORGswTlZvWERUTTBNVEV4TWpFNE5UUTBOVm93RlRFVApNQkVHQTFVRUF4TUthM1ZpWlhKdVpYUmxjekNDQVNJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DCmdnRUJBUFFiVmdUa20wQnF4NTA4UnhCczZETmdlQnFva1hBdW9SUnpOT2RwVlQrbGhhTW11U3RTNElFQnNBbWgKNWQyMTFrRy9RMnV3L0NJVXNTc25Kdm5PU1UxTU9mdVVpRFRublJIUGhuT3hTbklaSj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69DC525.gr7.us-west-2.eks.amazonaws.com - name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 -- cluster: - certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCVENDQWUyZ0F3SUJBZ0lJTUZtWEF4QloyeXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRFeE1UUXlNREEzTlRoYUZ3MHpOREV4TVRJeU1ERXlOVGhhTUJVeApFekFSQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLCkFvSUJBUUMrcGhDTlFBTW1iWWtZRUpRQkhkbVQzWGh5ay80VVV6VDlBSDFzQXQ2M0REN2hJRkZaZmVuTlR2cUEKcXUwTjdQOGNDcFdrSFNzQStETTE2alBLcE0yUVFJNkg4eHlRUzhYSnRucjVvVGxZQnJDTDgvdGJlTCs1MVlQdgpnQ0xXVU4xenFJbXhhVXphMEllMXp6WXluMjJhZU1hRDQraDA5eCt2T1cvcE1QUmNjdWxHMkZpSXZHYVNHNXFRCkRNK2RwZjhnMW91VXNuMWJMZzhDRThCTFUvaXFKbmlHOFNoaGhjYzJ0RTd1QkVtNmZIS3ZwN1NHQ09oditDUVcKNlhyMFNJUEYrcnFYaUFNQjdVTmZvajhLcGN0bk9KYUhxUTdLV1ljbkFwdi9uQVlPOURzMURISEdzVFBNNEQySQpMcVNaaWpQeE9nMEozeGhOYVU5NmdHSU5wV2VoQWdNQkFBR2pXVEJYTUE0R0ExVWREd0VCL3dRRUF3SUNwREFQCkJnTlZIUk1CQWY4RUJUQURBUUgvTUIwR0ExVWREZ1FXQkJRZHpZc2w0QVAvOVJZVnlqSTNLL2dCMERvSEpEQVYKQmdOVkhSRUVEakFNZ2dwcmRXSmxjbTVsZEdWek1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQkFRQjl3ZytQYjBnMApSeHFZczh1K2ZCZEszZHpaY1NuVE9idW9DU0pvZEI2NzVic3VWRlkvYk9HeTJHb0VsazdMbDIrTnBsVGM1UitvCm4xNlRMVGxMb1FEZE1qa0tXcDRmK09FbHlLb09vRi9Objd4OG9waDBNaEVzZXE1NzZvUjhsMExsRkF4QyticXYKMUdYWG9GR3JQY0JGMitjbk1tbkcyTU1iRVEwL0NRV0M3dkx0ZUNqYll4a0FZejZZd3JIbC9HQ3k2TENFMmhMdgpLZkkxS0JZUkkvU2wya2d2L1FFbTQrb25KM3RHcHBGNmsyU0tFMkplNzErR1pXUXphcGJGK1JZWFFuRHJuN3FzCjIybmJZSnpMblptUXRvbVFVZ0MwbitKNG95QjFtSmlMVk4vaHJBaDAvV29Wd2VoQ2xmRjNEVW1JZ1JUQ1dVM3UKZk1UYUNEaE5XemUyCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K - server: https://92BAADEAD75DB06218CE1125A95FFA4B.gr7.us-west-2.eks.amazonaws.com - name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 -contexts: -- context: - cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 - user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 - name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 -- context: - cluster: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 - user: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 - name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 -current-context: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 -kind: Config -preferences: {} -users: -- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 - user: - exec: - apiVersion: client.authentication.k8s.io/v1beta1 - args: - - --region - - us-west-2 - - eks - - get-token - - --cluster-name - - cwagent-otel-config-e2e-eks-a99ef5b36c745ce4 - - --output - - json - command: aws -- name: arn:aws:eks:us-west-2:637423426239:cluster/cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 - user: - exec: - apiVersion: client.authentication.k8s.io/v1beta1 - args: - - --region - - us-west-2 - - eks - - get-token - - --cluster-name - - cwagent-otel-config-e2e-eks-a6f5c8bba2ff85f1 - - --output - - json - command: aws diff --git a/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json b/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json deleted file mode 100644 index c0c2a10dd..000000000 --- a/test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "metrics": { - "namespace": "JVM_TOMCAT_E2E", - "metrics_collected": { - "jmx": { - "jvm": { - "measurement": [ - "jvm.classes.loaded", - "jvm.gc.collections.count", - "jvm.gc.collections.elapsed", - "jvm.memory.heap.committed", - "jvm.memory.heap.init", - "jvm.memory.heap.max", - "jvm.memory.heap.used", - "jvm.memory.nonheap.committed", - "jvm.memory.nonheap.init", - "jvm.memory.nonheap.max", - "jvm.memory.nonheap.used", - "jvm.memory.pool.committed", - "jvm.memory.pool.init", - "jvm.memory.pool.max", - "jvm.memory.pool.used", - "jvm.threads.count" - ] - }, - "tomcat": { - "measurement": [ - "tomcat.sessions", - "tomcat.errors", - "tomcat.request_count", - "tomcat.max_time", - "tomcat.processing_time", - "tomcat.traffic", - "tomcat.threads" - ] - } - } - } - } -} \ No newline at end of file diff --git a/test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml b/test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/e2e/jmx/validate_test.go b/test/e2e/jmx/validate_test.go deleted file mode 100644 index 73093fee3..000000000 --- a/test/e2e/jmx/validate_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package jmx - -import ( - "fmt" - "testing" -) - -func TestMetrics(t *testing.T) { - fmt.Printf("TestMetrics") -} - -func TestResources(t *testing.T) { - fmt.Printf("TestResources") -} From d18ce5921ba9cabbf864d32f10f76e64478f19d5 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 12:31:24 -0500 Subject: [PATCH 07/19] Remove helm chart creation. --- terraform/e2e/eks/main.tf | 43 --------------------------------------- 1 file changed, 43 deletions(-) diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index 0bd9efb93..38a455dbf 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -121,50 +121,7 @@ resource "null_resource" "helm_charts" { } } -resource "null_resource" "install_helm_release_and_sample_app" { - depends_on = [ - null_resource.kubectl, - null_resource.helm_charts, - aws_eks_cluster.this, - aws_eks_node_group.this - ] - - provisioner "local-exec" { - command = <<-EOT - ${local.aws_eks} update-kubeconfig --name ${aws_eks_cluster.this.name} - - helm upgrade --install amazon-cloudwatch-observability \ - ${path.module}/helm-charts/charts/amazon-cloudwatch-observability \ - --values ${path.module}/helm-charts/charts/amazon-cloudwatch-observability/values.yaml \ - --set clusterName=${aws_eks_cluster.this.name} \ - --set region=${var.region} \ - --set agent.image.repository=${var.cloudwatch_agent_repository} \ - --set agent.image.tag=${var.cloudwatch_agent_tag} \ - --set agent.image.repositoryDomainMap.public=${var.cloudwatch_agent_repository_url} \ - --set manager.image.repository=${var.cloudwatch_agent_operator_repository} \ - --set manager.image.tag=${var.cloudwatch_agent_operator_tag} \ - --set manager.image.repositoryDomainMap.public=${var.cloudwatch_agent_operator_repository_url} \ - --namespace amazon-cloudwatch \ - --create-namespace \ - ${var.agent-config != "" ? "--set-json agent.config='${jsonencode(jsondecode(file(var.agent-config)))}'" : ""} \ - ${var.otel-config != "" ? "--set-file agent.otelConfig=${yamlencode(yamldecode(file(var.otel-config)))}" : ""} \ - ${var.prometheus-config != "" ? "--set-file agent.prometheus.config=${yamlencode(yamldecode(file(var.prometheus-config)))}" : ""} - - kubectl apply -f ${var.sample-app} - kubectl wait --for=condition=available --timeout=300s deployment/${var.sample-app-name} - EOT - - environment = { - KUBECONFIG = "$HOME/.kube/config" - } - } -} - resource "null_resource" "test" { - depends_on = [ - null_resource.install_helm_release_and_sample_app - ] - provisioner "local-exec" { command = "go test -v ${var.validate_test}" } From 53669da47b29726977ba4312aca1603c2767ef87 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 13:13:55 -0500 Subject: [PATCH 08/19] Make fmt. --- terraform/e2e/eks/variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/e2e/eks/variables.tf b/terraform/e2e/eks/variables.tf index f3494742e..df8af4b4f 100644 --- a/terraform/e2e/eks/variables.tf +++ b/terraform/e2e/eks/variables.tf @@ -82,11 +82,11 @@ variable "validate_test" { } variable "sample-app" { - type = string + type = string default = "../../../test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml" } variable "sample-app-name" { - type = string + type = string default = "tomcat-deployment" } \ No newline at end of file From d127eb021a73da21f352e11e0fdd12b2a2dc2b9a Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 15:10:57 -0500 Subject: [PATCH 09/19] Fix helm. --- terraform/e2e/eks/main.tf | 43 +++++++++++++++++++++++++++------- terraform/e2e/eks/providers.tf | 4 ---- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index 38a455dbf..57b33e5fc 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -106,22 +106,49 @@ resource "null_resource" "kubectl" { } } -resource "null_resource" "helm_charts" { +resource "null_resource" "install_helm_release_and_sample_app" { + depends_on = [ + null_resource.kubectl, + aws_eks_cluster.this, + aws_eks_node_group.this + ] + provisioner "local-exec" { command = <<-EOT - git clone https://github.com/aws-observability/helm-charts.git helm-charts - cd helm-charts - git checkout ${var.helm_charts_branch} + ${local.aws_eks} update-kubeconfig --name ${aws_eks_cluster.this.name} + + helm upgrade --install amazon-cloudwatch-observability \ + ${path.module}/helm-charts/charts/amazon-cloudwatch-observability \ + --values ${path.module}/helm-charts/charts/amazon-cloudwatch-observability/values.yaml \ + --set clusterName=${aws_eks_cluster.this.name} \ + --set region=${var.region} \ + --set agent.image.repository=${var.cloudwatch_agent_repository} \ + --set agent.image.tag=${var.cloudwatch_agent_tag} \ + --set agent.image.repositoryDomainMap.public=${var.cloudwatch_agent_repository_url} \ + --set manager.image.repository=${var.cloudwatch_agent_operator_repository} \ + --set manager.image.tag=${var.cloudwatch_agent_operator_tag} \ + --set manager.image.repositoryDomainMap.public=${var.cloudwatch_agent_operator_repository_url} \ + --namespace amazon-cloudwatch \ + --create-namespace \ + ${var.agent-config != "" ? "--set-json agent.config='${jsonencode(jsondecode(file(var.agent-config)))}'" : ""} \ + ${var.otel-config != "" ? "--set-file agent.otelConfig=${yamlencode(yamldecode(file(var.otel-config)))}" : ""} \ + ${var.prometheus-config != "" ? "--set-file agent.prometheus.config=${yamlencode(yamldecode(file(var.prometheus-config)))}" : ""} + + kubectl apply -f ${var.sample-app} + kubectl wait --for=condition=available --timeout=300s deployment/${var.sample-app-name} EOT - } - provisioner "local-exec" { - when = destroy - command = "rm -rf ${path.module}/helm-charts" + environment = { + KUBECONFIG = "$HOME/.kube/config" + } } } resource "null_resource" "test" { + depends_on = [ + null_resource.install_helm_release_and_sample_app + ] + provisioner "local-exec" { command = "go test -v ${var.validate_test}" } diff --git a/terraform/e2e/eks/providers.tf b/terraform/e2e/eks/providers.tf index 38c7b0215..3c2d72ffe 100644 --- a/terraform/e2e/eks/providers.tf +++ b/terraform/e2e/eks/providers.tf @@ -10,10 +10,6 @@ terraform { } } -provider "docker" { - host = "unix:///var/run/docker.sock" -} - provider "aws" { region = var.region } From 83ae4435264cb006643b2a9fb11887df395dc158 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 15:22:28 -0500 Subject: [PATCH 10/19] Fix region. --- terraform/e2e/eks/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index 57b33e5fc..3022f17db 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -10,7 +10,7 @@ module "basic_components" { } locals { - aws_eks = "aws eks --region ${var.region}" + aws_eks = "aws eks" cluster_name = var.cluster_name != "" ? var.cluster_name : "cwagent-monitoring-config-e2e-eks" } From 6ea0508fe20180a003b461fed9943d69feaa5717 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 16:36:26 -0500 Subject: [PATCH 11/19] Remove helm (will add for testing). --- terraform/e2e/eks/main.tf | 56 --------------------------------------- 1 file changed, 56 deletions(-) diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index 3022f17db..89f67fd3a 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -92,63 +92,7 @@ resource "aws_iam_role_policy_attachment" "node_CloudWatchAgentServerPolicy" { role = aws_iam_role.node_role.name } -resource "null_resource" "kubectl" { - depends_on = [ - aws_eks_cluster.this, - aws_eks_node_group.this - ] - provisioner "local-exec" { - command = <<-EOT - ${local.aws_eks} update-kubeconfig --name ${aws_eks_cluster.this.name} - ${local.aws_eks} list-clusters --output text - ${local.aws_eks} describe-cluster --name ${aws_eks_cluster.this.name} --output text - EOT - } -} - -resource "null_resource" "install_helm_release_and_sample_app" { - depends_on = [ - null_resource.kubectl, - aws_eks_cluster.this, - aws_eks_node_group.this - ] - - provisioner "local-exec" { - command = <<-EOT - ${local.aws_eks} update-kubeconfig --name ${aws_eks_cluster.this.name} - - helm upgrade --install amazon-cloudwatch-observability \ - ${path.module}/helm-charts/charts/amazon-cloudwatch-observability \ - --values ${path.module}/helm-charts/charts/amazon-cloudwatch-observability/values.yaml \ - --set clusterName=${aws_eks_cluster.this.name} \ - --set region=${var.region} \ - --set agent.image.repository=${var.cloudwatch_agent_repository} \ - --set agent.image.tag=${var.cloudwatch_agent_tag} \ - --set agent.image.repositoryDomainMap.public=${var.cloudwatch_agent_repository_url} \ - --set manager.image.repository=${var.cloudwatch_agent_operator_repository} \ - --set manager.image.tag=${var.cloudwatch_agent_operator_tag} \ - --set manager.image.repositoryDomainMap.public=${var.cloudwatch_agent_operator_repository_url} \ - --namespace amazon-cloudwatch \ - --create-namespace \ - ${var.agent-config != "" ? "--set-json agent.config='${jsonencode(jsondecode(file(var.agent-config)))}'" : ""} \ - ${var.otel-config != "" ? "--set-file agent.otelConfig=${yamlencode(yamldecode(file(var.otel-config)))}" : ""} \ - ${var.prometheus-config != "" ? "--set-file agent.prometheus.config=${yamlencode(yamldecode(file(var.prometheus-config)))}" : ""} - - kubectl apply -f ${var.sample-app} - kubectl wait --for=condition=available --timeout=300s deployment/${var.sample-app-name} - EOT - - environment = { - KUBECONFIG = "$HOME/.kube/config" - } - } -} - resource "null_resource" "test" { - depends_on = [ - null_resource.install_helm_release_and_sample_app - ] - provisioner "local-exec" { command = "go test -v ${var.validate_test}" } From 0c259da118cd3f349ab31844ac1457b0e63ec1a9 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 16:46:09 -0500 Subject: [PATCH 12/19] Add variables. --- terraform/e2e/eks/main.tf | 21 ++++++++++++++++++++- terraform/e2e/eks/variables.tf | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index 89f67fd3a..2966b9772 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -94,6 +94,25 @@ resource "aws_iam_role_policy_attachment" "node_CloudWatchAgentServerPolicy" { resource "null_resource" "test" { provisioner "local-exec" { - command = "go test -v ${var.validate_test}" + command = <<-EOT + go test -v ${var.validate_test} \ + -region=${var.region} \ + -k8s_version=${var.k8s_version} \ + -cluster_name=${var.cluster_name} \ + -agent_branch=${var.agent_branch} \ + -operator_branch=${var.operator_branch} \ + -helm_charts_branch=${var.helm_charts_branch} \ + -otel-config=${var.otel-config} \ + -agent-config=${var.agent-config} \ + -prometheus-config=${var.prometheus-config} \ + -cloudwatch_agent_repository=${var.cloudwatch_agent_repository} \ + -cloudwatch_agent_tag=${var.cloudwatch_agent_tag} \ + -cloudwatch_agent_repository_url=${var.cloudwatch_agent_repository_url} \ + -cloudwatch_agent_operator_repository=${var.cloudwatch_agent_operator_repository} \ + -cloudwatch_agent_operator_tag=${var.cloudwatch_agent_operator_tag} \ + -cloudwatch_agent_operator_repository_url=${var.cloudwatch_agent_operator_repository_url} \ + -sample-app=${var.sample-app} \ + -sample-app-name=${var.sample-app-name} + EOT } } diff --git a/terraform/e2e/eks/variables.tf b/terraform/e2e/eks/variables.tf index df8af4b4f..ac06773d4 100644 --- a/terraform/e2e/eks/variables.tf +++ b/terraform/e2e/eks/variables.tf @@ -78,12 +78,12 @@ variable "cloudwatch_agent_operator_repository_url" { variable "validate_test" { type = string - default = "../../../test/e2e/jmx/validate_test.go" + default = "" } variable "sample-app" { type = string - default = "../../../test/e2e/jmx/files/sample_applications/tomcat-deployment.yaml" + default = "" } variable "sample-app-name" { From de1082a81a5b010373459b0e48ace076e0366721 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 16:48:11 -0500 Subject: [PATCH 13/19] Remove sample app. --- terraform/e2e/eks/main.tf | 9 +-------- terraform/e2e/eks/variables.tf | 35 ---------------------------------- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index 2966b9772..58803d8f5 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -99,20 +99,13 @@ resource "null_resource" "test" { -region=${var.region} \ -k8s_version=${var.k8s_version} \ -cluster_name=${var.cluster_name} \ - -agent_branch=${var.agent_branch} \ - -operator_branch=${var.operator_branch} \ -helm_charts_branch=${var.helm_charts_branch} \ - -otel-config=${var.otel-config} \ - -agent-config=${var.agent-config} \ - -prometheus-config=${var.prometheus-config} \ -cloudwatch_agent_repository=${var.cloudwatch_agent_repository} \ -cloudwatch_agent_tag=${var.cloudwatch_agent_tag} \ -cloudwatch_agent_repository_url=${var.cloudwatch_agent_repository_url} \ -cloudwatch_agent_operator_repository=${var.cloudwatch_agent_operator_repository} \ -cloudwatch_agent_operator_tag=${var.cloudwatch_agent_operator_tag} \ - -cloudwatch_agent_operator_repository_url=${var.cloudwatch_agent_operator_repository_url} \ - -sample-app=${var.sample-app} \ - -sample-app-name=${var.sample-app-name} + -cloudwatch_agent_operator_repository_url=${var.cloudwatch_agent_operator_repository_url} EOT } } diff --git a/terraform/e2e/eks/variables.tf b/terraform/e2e/eks/variables.tf index ac06773d4..09d3f0f58 100644 --- a/terraform/e2e/eks/variables.tf +++ b/terraform/e2e/eks/variables.tf @@ -16,36 +16,11 @@ variable "cluster_name" { default = "cwagent-otel-config-e2e-eks" } -variable "agent_branch" { - type = string - default = "main" -} - -variable "operator_branch" { - type = string - default = "main" -} - variable "helm_charts_branch" { type = string default = "main" } -variable "otel-config" { - type = string - default = "" -} - -variable "agent-config" { - type = string - default = "../../../test/e2e/jmx/files/cwagent_configs/jvm_tomcat.json" -} - -variable "prometheus-config" { - type = string - default = "" -} - variable "cloudwatch_agent_repository" { type = string default = "cloudwatch-agent" @@ -79,14 +54,4 @@ variable "cloudwatch_agent_operator_repository_url" { variable "validate_test" { type = string default = "" -} - -variable "sample-app" { - type = string - default = "" -} - -variable "sample-app-name" { - type = string - default = "tomcat-deployment" } \ No newline at end of file From 7ee61bcdf7537a3ec17f8189bba9f0945aa385d3 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Fri, 15 Nov 2024 16:49:04 -0500 Subject: [PATCH 14/19] Remove helm. --- terraform/e2e/eks/providers.tf | 6 ------ 1 file changed, 6 deletions(-) diff --git a/terraform/e2e/eks/providers.tf b/terraform/e2e/eks/providers.tf index 3c2d72ffe..1c2b6fff6 100644 --- a/terraform/e2e/eks/providers.tf +++ b/terraform/e2e/eks/providers.tf @@ -12,10 +12,4 @@ terraform { provider "aws" { region = var.region -} - -provider "helm" { - kubernetes { - config_path = "~/.kube/config" - } } \ No newline at end of file From 48d5038c657363e3454b9ba5ad8711ac7cc22645 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Sun, 17 Nov 2024 23:14:00 -0500 Subject: [PATCH 15/19] Add sample app. --- terraform/e2e/eks/main.tf | 11 +++++++++-- terraform/e2e/eks/variables.tf | 27 ++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/terraform/e2e/eks/main.tf b/terraform/e2e/eks/main.tf index 58803d8f5..dcbe56430 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/e2e/eks/main.tf @@ -93,19 +93,26 @@ resource "aws_iam_role_policy_attachment" "node_CloudWatchAgentServerPolicy" { } resource "null_resource" "test" { + depends_on = [aws_eks_cluster.this, aws_eks_node_group.this] + provisioner "local-exec" { command = <<-EOT go test -v ${var.validate_test} \ -region=${var.region} \ -k8s_version=${var.k8s_version} \ - -cluster_name=${var.cluster_name} \ + -cluster_name=${aws_eks_cluster.this.name} \ -helm_charts_branch=${var.helm_charts_branch} \ -cloudwatch_agent_repository=${var.cloudwatch_agent_repository} \ -cloudwatch_agent_tag=${var.cloudwatch_agent_tag} \ -cloudwatch_agent_repository_url=${var.cloudwatch_agent_repository_url} \ -cloudwatch_agent_operator_repository=${var.cloudwatch_agent_operator_repository} \ -cloudwatch_agent_operator_tag=${var.cloudwatch_agent_operator_tag} \ - -cloudwatch_agent_operator_repository_url=${var.cloudwatch_agent_operator_repository_url} + -cloudwatch_agent_operator_repository_url=${var.cloudwatch_agent_operator_repository_url} \ + -agent_config=${var.agent_config} \ + -otel_config=${var.otel_config} \ + -prometheus_config=${var.prometheus_config} \ + -sample_app=${var.sample_app} \ + -sample_app_name=${var.sample_app_name} EOT } } diff --git a/terraform/e2e/eks/variables.tf b/terraform/e2e/eks/variables.tf index 09d3f0f58..6ea30bd23 100644 --- a/terraform/e2e/eks/variables.tf +++ b/terraform/e2e/eks/variables.tf @@ -54,4 +54,29 @@ variable "cloudwatch_agent_operator_repository_url" { variable "validate_test" { type = string default = "" -} \ No newline at end of file +} + +variable "agent_config" { + type = string + default = "" +} + +variable "otel_config" { + type = string + default = "" +} + +variable "prometheus_config" { + type = string + default = "" +} + +variable "sample_app" { + type = string + default = "" +} + +variable "sample_app_name" { + type = string + default = "" +} From f545c65ac079857e1fd65ab26d90711962c312af Mon Sep 17 00:00:00 2001 From: musa-asad Date: Wed, 27 Nov 2024 09:00:38 -0500 Subject: [PATCH 16/19] Update variables. --- terraform/{e2e/eks => eks/e2e}/main.tf | 29 +++++++++++++++------ terraform/{e2e/eks => eks/e2e}/providers.tf | 0 terraform/{e2e/eks => eks/e2e}/variables.tf | 4 +-- 3 files changed, 23 insertions(+), 10 deletions(-) rename terraform/{e2e/eks => eks/e2e}/main.tf (83%) rename terraform/{e2e/eks => eks/e2e}/providers.tf (100%) rename terraform/{e2e/eks => eks/e2e}/variables.tf (94%) diff --git a/terraform/e2e/eks/main.tf b/terraform/eks/e2e/main.tf similarity index 83% rename from terraform/e2e/eks/main.tf rename to terraform/eks/e2e/main.tf index dcbe56430..268f79cfd 100644 --- a/terraform/e2e/eks/main.tf +++ b/terraform/eks/e2e/main.tf @@ -10,7 +10,6 @@ module "basic_components" { } locals { - aws_eks = "aws eks" cluster_name = var.cluster_name != "" ? var.cluster_name : "cwagent-monitoring-config-e2e-eks" } @@ -23,8 +22,8 @@ resource "aws_eks_cluster" "this" { role_arn = module.basic_components.role_arn version = var.k8s_version vpc_config { - subnet_ids = module.basic_components.public_subnet_ids - security_group_ids = [module.basic_components.security_group] + subnet_ids = module.basic_components.public_subnet_ids + security_group_ids = [module.basic_components.security_group] } } @@ -92,12 +91,27 @@ resource "aws_iam_role_policy_attachment" "node_CloudWatchAgentServerPolicy" { role = aws_iam_role.node_role.name } +resource "null_resource" "helm_charts" { + provisioner "local-exec" { + command = <<-EOT + git clone https://github.com/aws-observability/helm-charts.git helm-charts + cd helm-charts + git checkout ${var.helm_charts_branch} + EOT + } + + provisioner "local-exec" { + when = destroy + command = "rm -rf ${path.module}/helm-charts" + } +} + resource "null_resource" "test" { - depends_on = [aws_eks_cluster.this, aws_eks_node_group.this] + depends_on = [aws_eks_cluster.this, aws_eks_node_group.this, null_resource.helm_charts] provisioner "local-exec" { command = <<-EOT - go test -v ${var.validate_test} \ + go test -v ${var.test_dir} \ -region=${var.region} \ -k8s_version=${var.k8s_version} \ -cluster_name=${aws_eks_cluster.this.name} \ @@ -111,8 +125,7 @@ resource "null_resource" "test" { -agent_config=${var.agent_config} \ -otel_config=${var.otel_config} \ -prometheus_config=${var.prometheus_config} \ - -sample_app=${var.sample_app} \ - -sample_app_name=${var.sample_app_name} + -sample_app=${var.sample_app} EOT } -} +} \ No newline at end of file diff --git a/terraform/e2e/eks/providers.tf b/terraform/eks/e2e/providers.tf similarity index 100% rename from terraform/e2e/eks/providers.tf rename to terraform/eks/e2e/providers.tf diff --git a/terraform/e2e/eks/variables.tf b/terraform/eks/e2e/variables.tf similarity index 94% rename from terraform/e2e/eks/variables.tf rename to terraform/eks/e2e/variables.tf index 6ea30bd23..1959df2ef 100644 --- a/terraform/e2e/eks/variables.tf +++ b/terraform/eks/e2e/variables.tf @@ -13,7 +13,7 @@ variable "k8s_version" { variable "cluster_name" { type = string - default = "cwagent-otel-config-e2e-eks" + default = "cwagent-monitoring-config-e2e-eks" } variable "helm_charts_branch" { @@ -51,7 +51,7 @@ variable "cloudwatch_agent_operator_repository_url" { default = "public.ecr.aws/cloudwatch-agent" } -variable "validate_test" { +variable "test_dir" { type = string default = "" } From 5611fbb2ba869d091e46ea67252674022d6fb4cc Mon Sep 17 00:00:00 2001 From: musa-asad Date: Wed, 27 Nov 2024 09:05:04 -0500 Subject: [PATCH 17/19] Make fmt. --- terraform/eks/e2e/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/eks/e2e/main.tf b/terraform/eks/e2e/main.tf index 268f79cfd..2aa954421 100644 --- a/terraform/eks/e2e/main.tf +++ b/terraform/eks/e2e/main.tf @@ -22,8 +22,8 @@ resource "aws_eks_cluster" "this" { role_arn = module.basic_components.role_arn version = var.k8s_version vpc_config { - subnet_ids = module.basic_components.public_subnet_ids - security_group_ids = [module.basic_components.security_group] + subnet_ids = module.basic_components.public_subnet_ids + security_group_ids = [module.basic_components.security_group] } } From 3d1d9d04ec63be070e75769525c3ecd29f06dfe7 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Wed, 27 Nov 2024 09:07:02 -0500 Subject: [PATCH 18/19] Remove unused variable. --- terraform/eks/e2e/variables.tf | 5 ----- 1 file changed, 5 deletions(-) diff --git a/terraform/eks/e2e/variables.tf b/terraform/eks/e2e/variables.tf index 1959df2ef..00c8e4166 100644 --- a/terraform/eks/e2e/variables.tf +++ b/terraform/eks/e2e/variables.tf @@ -75,8 +75,3 @@ variable "sample_app" { type = string default = "" } - -variable "sample_app_name" { - type = string - default = "" -} From 1299df65b95782af5c329ba2b54f9760058a0969 Mon Sep 17 00:00:00 2001 From: musa-asad Date: Wed, 27 Nov 2024 09:55:31 -0500 Subject: [PATCH 19/19] Add logs. --- terraform/eks/e2e/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terraform/eks/e2e/main.tf b/terraform/eks/e2e/main.tf index 2aa954421..5be0e9c60 100644 --- a/terraform/eks/e2e/main.tf +++ b/terraform/eks/e2e/main.tf @@ -106,11 +106,12 @@ resource "null_resource" "helm_charts" { } } -resource "null_resource" "test" { +resource "null_resource" "validator" { depends_on = [aws_eks_cluster.this, aws_eks_node_group.this, null_resource.helm_charts] provisioner "local-exec" { command = <<-EOT + echo "Validating K8s resources and metrics" go test -v ${var.test_dir} \ -region=${var.region} \ -k8s_version=${var.k8s_version} \