From a6c0875586f3a6a51533f9a648e481510913433b Mon Sep 17 00:00:00 2001 From: Rafael Pereyra <31078199+rafaelpereyra@users.noreply.github.com> Date: Thu, 7 Sep 2023 09:48:44 -0400 Subject: [PATCH] Added updated example for traffic generator (#230) * Added updated example for traffic generator * Updated readme and docs * Pre-commit fixes --- docs/eks/nginx.md | 2 +- examples/existing-cluster-nginx/README.md | 2 +- .../sample_traffic/nginix-traffic-sample.yaml | 124 ++++++++++++++++++ 3 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 examples/existing-cluster-nginx/sample_traffic/nginix-traffic-sample.yaml diff --git a/docs/eks/nginx.md b/docs/eks/nginx.md index ecf5b006..17fdd9bb 100644 --- a/docs/eks/nginx.md +++ b/docs/eks/nginx.md @@ -103,7 +103,7 @@ EXTERNAL_IP=your-nginx-controller-external-ip ```sh SAMPLE_TRAFFIC_NAMESPACE=nginx-sample-traffic -curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/master/k8s-deployment-manifest-templates/deployment-mode/service/cwagent-prometheus/sample_traffic/nginx-traffic/nginx-traffic-sample.yaml | +curl https://raw.githubusercontent.com/aws-observability/terraform-aws-observability-accelerator/main/examples/existing-cluster-nginx/sample_traffic/nginx-traffic-sample.yaml | sed "s/{{external_ip}}/$EXTERNAL_IP/g" | sed "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" | kubectl apply -f - diff --git a/examples/existing-cluster-nginx/README.md b/examples/existing-cluster-nginx/README.md index 6c1c6f7d..36144632 100644 --- a/examples/existing-cluster-nginx/README.md +++ b/examples/existing-cluster-nginx/README.md @@ -160,7 +160,7 @@ EXTERNAL_IP=your-nginx-controller-external-ip ```sh SAMPLE_TRAFFIC_NAMESPACE=nginx-sample-traffic -curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/master/k8s-deployment-manifest-templates/deployment-mode/service/cwagent-prometheus/sample_traffic/nginx-traffic/nginx-traffic-sample.yaml | +cat ./sample_traffic/nginx-traffic-sample.yaml | sed "s/{{external_ip}}/$EXTERNAL_IP/g" | sed "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" | kubectl apply -f - diff --git a/examples/existing-cluster-nginx/sample_traffic/nginix-traffic-sample.yaml b/examples/existing-cluster-nginx/sample_traffic/nginix-traffic-sample.yaml new file mode 100644 index 00000000..ec5ffff5 --- /dev/null +++ b/examples/existing-cluster-nginx/sample_traffic/nginix-traffic-sample.yaml @@ -0,0 +1,124 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: {{namespace}} + labels: + name: {{namespace}} + +--- + +kind: Pod +apiVersion: v1 +metadata: + name: banana-app + namespace: {{namespace}} + labels: + app: banana +spec: + containers: + - name: banana-app + image: hashicorp/http-echo + args: + - "-text=banana" + resources: + limits: + cpu: 100m + memory: 100Mi + requests: + cpu: 50m + memory: 50Mi +--- + +kind: Service +apiVersion: v1 +metadata: + name: banana-service + namespace: {{namespace}} +spec: + selector: + app: banana + ports: + - port: 5678 # Default port for image + +--- + +kind: Pod +apiVersion: v1 +metadata: + name: apple-app + namespace: {{namespace}} + labels: + app: apple +spec: + containers: + - name: apple-app + image: hashicorp/http-echo + args: + - "-text=apple" + resources: + limits: + cpu: 100m + memory: 100Mi + requests: + cpu: 50m + memory: 50Mi +--- + +kind: Service +apiVersion: v1 +metadata: + name: apple-service + namespace: {{namespace}} +spec: + selector: + app: apple + ports: + - port: 5678 # Default port for image + +--- + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-nginx-demo + namespace: {{namespace}} +spec: + rules: + - host: {{external_ip}} + http: + paths: + - path: /apple + pathType: Prefix + backend: + service: + name: apple-service + port: + number: 5678 + - path: /banana + pathType: Prefix + backend: + service: + name: banana-service + port: + number: 5678 + +--- + +apiVersion: v1 +kind: Pod +metadata: + name: traffic-generator + namespace: {{namespace}} +spec: + containers: + - name: traffic-generator + image: ellerbrock/alpine-bash-curl-ssl + command: ["/bin/bash"] + args: ["-c", "while :; do curl http://{{external_ip}}/apple > /dev/null 2>&1; curl http://{{external_ip}}/banana > /dev/null 2>&1; sleep 1; done"] + resources: + limits: + cpu: 100m + memory: 100Mi + requests: + cpu: 50m + memory: 50Mi