Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ECS NGINX workload #6

Open
wants to merge 3 commits into
base: kohrapha/eks-nginx
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/ecs/prometheus-nginx-workload/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
13 changes: 13 additions & 0 deletions examples/ecs/prometheus-nginx-workload/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Steps:
1. Build the reverse-proxy container and push the image:
```
docker build -t kohrapha/reverse-proxy .
docker push kohrapha/reverse-proxy`
```
2. Configure `config.yaml` with `sample-config.yml`.
2. Build and push AOC image:
```
make docker-build
make docker-push
```
3. Upload task definition (`ecs-nginx-sidecar.json`) to ECS.
164 changes: 164 additions & 0 deletions examples/ecs/prometheus-nginx-workload/ecs-nginx-sidecar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"family": "aoc-ec2-nginx",
"taskRoleArn": "ecs-aoc",
"executionRoleArn": "ecs-aoc",
"networkMode": "bridge",
"containerDefinitions": [
{
"name": "apple",
"image": "hashicorp/http-echo",
"cpu": "100",
"memory": "100",
"essential": true,
"command": ["-text=apple"],
"portMappings": [
{
"containerPort": 5678
}
],
"dependsOn": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aoc-ec2-nginx-apple",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "ecs",
"awslogs-create-group": "True"
}
}
},
{
"name": "banana",
"image": "hashicorp/http-echo",
"cpu": "100",
"memory": "100",
"essential": true,
"command": ["-text=banana"],
"dependsOn": [],
"portMappings": [
{
"containerPort": 5678
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aoc-ec2-nginx-banana",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "ecs",
"awslogs-create-group": "True"
}
}
},
{
"name": "traffic-generator",
"image": "ellerbrock/alpine-bash-curl-ssl",
"cpu": "100",
"memory": "100",
"essential": true,
"command": ["/bin/bash", "-c", "while :; do curl http://nginx-reverse-proxy/apple > /dev/null 2>&1; curl http://nginx-reverse-proxy/banana > /dev/null 2>&1; sleep 1; done"],
"dependsOn": [
{
"containerName": "nginx-reverse-proxy",
"condition": "START"
}
],
"links": [
"nginx-reverse-proxy"
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aoc-ec2-nginx-traffic-generator",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "ecs",
"awslogs-create-group": "True"
}
}
},
{
"name": "nginx-reverse-proxy",
"image": "kohrapha/reverse-proxy",
"cpu": "256",
"memory": "256",
"essential": true,
"portMappings": [
{
"containerPort": 80
}
],
"links": [
"apple",
"banana"
],
"dependsOn": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aoc-ecs-nginx-reverse-proxy",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "ecs",
"awslogs-create-group": "True"
}
}
},
{
"name": "nginx-prometheus-exporter",
"image": "nginx/nginx-prometheus-exporter:0.8.0",
"cpu": "256",
"memory": "256",
"essential": true,
"command": ["-nginx.scrape-uri", "http://nginx-reverse-proxy:80/metrics"],
"portMappings": [
{
"containerPort": 9113
}
],
"links": [
"nginx-reverse-proxy"
],
"dependsOn": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aoc-ecs-nginx-prometheus-exporter",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "ecs",
"awslogs-create-group": "True"
}
}
},
{
"name": "aws-otel-collector",
"image": "kohrapha/awscollector:v0.1.0",
"cpu": "1000",
"memory": "1000",
"portMappings": [
{
"containerPort": 55680,
"hostPort": 55680,
"protocol": "tcp"
}
],
"essential": true,
"command": ["--config=/etc/otel-config.yaml", "--log-level=DEBUG"],
"links": [
"nginx-prometheus-exporter"
],
"dependsOn": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/aoc-ecs-collector",
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "ecs",
"awslogs-create-group": "True"
}
}
}
],
"requiresCompatibilities": [
"EC2"
]
}

21 changes: 21 additions & 0 deletions examples/ecs/prometheus-nginx-workload/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
events {
worker_connections 768;
}

http {
server {
listen 80;

location /apple {
proxy_pass http://apple:5678;
}

location /banana {
proxy_pass http://banana:5678;
}

location /metrics {
stub_status;
}
}
}
26 changes: 26 additions & 0 deletions examples/ecs/prometheus-nginx-workload/sample-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
extensions:
health_check:

receivers:
prometheus:
config:
scrape_configs:
- job_name: ec2
static_configs:
- targets: ['nginx-prometheus-exporter:9113']

exporters:
awsemf:
log_group_name: 'awscollector'
region: 'us-west-2'
log_stream_name: otel-stream
dimension_rollup_option: 'NoDimensionRollup'

service:
pipelines:
metrics:
receivers: [prometheus]
exporters: [awsemf]

extensions: [health_check]