This section describes our test environment hosted in an AWS ECS Elastic Container Service
Amazon Elastic Container Service (Amazon ECS) is a highly scalable, high-performance container orchestration service that supports Docker containers and allows you to easily run and scale containerized applications on AWS. Amazon ECS eliminates the need for you to install and operate your own container orchestration software, manage and scale a cluster of virtual machines, or schedule containers on those virtual machines.
With simple API calls, you can launch and stop Docker-enabled applications, query the complete state of your application, and access many familiar features such as IAM roles, security groups, load balancers, Amazon CloudWatch Events, AWS CloudFormation templates, and AWS CloudTrail logs.
While it is quite possible to run the application directly in EC2 Instances we then become responsible for maintaining the images and some elements of the deployment will become AWS specific. By using Docker containers we are able to run the same builds both locally on dev machines and on different cloud hosts using the same configurations.
Architecture
For MVP testing we will use a simple architecture of 1 or more EC2 Instances in a ECS Cluster. Each running the docker image that has been stored in the ECR registry.
Build the cluster
We use the ecs-cli command line tool to create a cluster of the right sized instances.
ecs-cli up --keypair vly1 --capability-iam --size 1 --instance-type t2.small --cluster-config default -f
Build the docker image
# Get a docker login and run it $(aws ecr get-login --no-include-email --region ap-southeast-1) # build the docker image docker build -t vly1-main-repo . # tag the image docker tag vly1-main-repo:latest 585172581592.dkr.ecr.ap-southeast-1.amazonaws.com/vly1-main-repo:latest # push to the repository docker push 585172581592.dkr.ecr.ap-southeast-1.amazonaws.com/vly1-main-repo:latest
Start the Services
# aws/service up # aws/service down ecs-cli compose --verbose --file docker-compose-ecs-atlas.yml service $1
Find out what we have
# Lists all of the running containers in your ECS cluster ecs-cli ps [~/workspace/voluntarily/vly1] $ ecs-cli ps Name State Ports TaskDefinition Health 0c9c22ab-2019-4cde-8644-129343378bb7/web RUNNING 13.229.238.124:80->8000/tcp vly1:12 UNKNOWN
Scale the number of servers
# example scale to 3 servers. ecs-cli scale --capability-iam --size 3 # note that you can force reload of the image by scaling to zero and back up again without stopping the service.
0 Comments