- start with metalapp and popapp taskdefinition
cd 1-Setup
aws ecs register-task-definition --cli-input-json file://td-metalapp-setup.json --region eu-central-1
aws ecs register-task-definition --cli-input-json file://td-popapp-setup.json --region eu-central-1
- create ECS service for both, metalapp and popapp both without public URL assignment and without LB
- grab URLs (host:port) of both services and set it in the td-jukebox.json taskdefinition, environment variables
- create taskdefinition for jukeboxapp (the frontend)
aws ecs register-task-definition --cli-input-json file://td-jukebox-setup.json --region eu-central-1
- create jukebox service
- grab public URL of jukebox ALB Url and make some requests
Extend role ecsTaskRole by attaching policy AWSXRayDaemonWriteAccess
Updating the task definitions to add xray-daemon sidecar container and additional env properties.
cd 2-Tracing-Logging
aws ecs register-task-definition --cli-input-json file://td-metalapp-tracing.json --region eu-central-1
aws ecs register-task-definition --cli-input-json file://td-popapp-tracing.json --region eu-central-1
aws ecs register-task-definition --cli-input-json file://td-jukebox-tracing.json --region eu-central-1
Ensure to update the final IP addresses of the metal- / pop-app within the jukebox taskdefinition, section environment variables
To apply all the changes, redeploy the corresponding ECS service and select the latest revision of the task definition.
- metalapp and popapp PORT 80, instead of 9001/9002
- adjust security groups "metalsvc" and "popsvc" to allow port 80
- adjust jukebox task definition to replace the METAL_HOST and POP_HOST env variables by the DNS names of the corresponding services, metalsvc.ecs-course.local and popsvc.ecs-course.local
- apply the changed task definitions
- delete existing services for metal- , and popsvc
- recreate service for metal- , and popsvc including service discovery
- redeploy the jukebox service with latest revision
- namespace: ecs-course.local
- service discovery services: metalsvc and popsvc
cd 3-ServiceDiscovery
aws ecs register-task-definition --cli-input-json file://td-metalapp-servicediscovery.json --region eu-central-1
aws ecs register-task-definition --cli-input-json file://td-popapp-servicediscovery.json --region eu-central-1
aws ecs register-task-definition --cli-input-json file://td-jukebox-servicediscovery.json --region eu-central-1
attach policy AWSAppMeshEnvoyAccess
- open AWS mgm console, AppMesh service
- click Create Mesh
- provide name jukebox-mesh and click button Create mesh
- create AppMesh components
aws cloudformation create-stack --stack-name appmesh-resources --template-body file://./mesh-resources.yaml
- change to networking mode awsvpc and launchtype FARGATE
- ensure env variables for metal and pop hosts match their service discovery names metal-service.ecs-course.local and pop-service.ecs-course.local
- delete environment variable AWS_XRAY_DAEMON_ADDRESS
- delete Links entry xray-daemon (this is no longer required in network mode awsvpc)
- enable AppMesh integration by clicking checkbox Enable App Mesh integration
- select jukebox as application container name
- select jukebox-mesh as Mesh name
- select jukebox-service-vn as Virtual node name
- click Apply !
- click Confirm
- in Container definitions, open the envoy container
- add environment variable ENABLE_ENVOY_XRAY_TRACING with value 1
- enable Cloudwatch logging
- click on Create to create the new task definition revision
- delete existing ECS service jukeboxsvc
- delete listener 9000 in ALB
- create new service
- add to loadbalancer, new listener port 9000, new target group jukeboxsvc
- click Enable service discovery integration
- select the existing namespace ecs-course.local
- create new service discovery service jukebox-service
- move to Fargate launchtype (to avoid the limitation of ENIs on our t2.small EC2 instance) by switching from EC2 to Fargate in Requires compatibilities
- set Task memory to 1GB
- set Task CPU to 0.5vCPU
- enable AppMesh integration by clicking checkbox Enable App Mesh integration
- select metalapp as application container name
- select jukebox-mesh as Mesh name
- select metal-service-vn as Virtual node name
- click Apply !
- click Confirm
- in Container definitions, open the envoy container
- add environment variable ENABLE_ENVOY_XRAY_TRACING with value 1
- enable Cloudwatch logging
- click on Create to create the new task definition revision
- recreate ECS service
- create new security group, open port 80 from everywhere
- click Enable service discovery integration
- select existing namespace
- select existing service discovery service
- select metal-service
- click Next step
- click Next step
- click Create service
- enable AppMesh integration by clicking checkbox Enable App Mesh integration
- select popapp as application container name
- select jukebox-mesh as Mesh name
- select pop-service-vn as Virtual node name
- click Apply !
- click Confirm
- in Container definitions, open the envoy container
- add environment variable ENABLE_ENVOY_XRAY_TRACING with value 1
- enable Cloudwatch logging
- click on Create to create the new task definition revision
cd 4-AppMesh
aws ecs register-task-definition --cli-input-json file://td-metalapp-appmesh.json --region eu-central-1
aws ecs register-task-definition --cli-input-json file://td-popapp-appmesh.json --region eu-central-1
aws ecs register-task-definition --cli-input-json file://td-jukebox-appmesh.json --region eu-central-1