From Manual Deployment to Managed Services
The most popular cloud providers have managed container services that can be used to deploy web application without the work overload of managing instances and containers. For instance, Amazon Web Services offers the AWS ECS (Elastic Container Services), which is a managed container service.
AWS ECS service takes care of:
Management
Creation
Updates
Monitoring
Scaling
This is the ideal service if we are looking only to deploy our web application
This solution requires us to use the specific tools the container service want us to use. In others words, we become more dependents to the providers tools and set up and less flexible.
Deploying with AWS ECS
AWS ECS is a paid service not available in the free tier.
AWS ECS works in term of
Cluster
Service
Task Definition
Container Definition
Creation of a custom container
The side pane allows the user to configure how the container should run. The options available are the same as what we have seen previously using the CLI commands docker run <options>
. In the configuration pane, we can specified the image the container should be built on, the container name, environment variables, create volumes, map ports, etc.
Task Definition
A task can be explained of how the server that run our container should be configured. A task can run one or multiple containers.
FARGATE: Corresponds to the serverless container launching mode. Does not involve the creation of an EC2 instance that is always up and running. The containers will be stored and will start only the time to handle the request, then it will stop again. We pay only for the time our container is executing.
Service Definition
Define how the Task should be executed. If needed, it is in this section that we can specify if a load load balancer should be implemented. 1 service = 1 task.
Cluster Configuration
Corresponds to the overall network where our services run.
Once the service is done with deployment, we can click on Show service to see our services configurations.
Then, click on the task ID
It is possible to bind a domain name to that public IP address
Then, check for the public IP address. Enter this public IP address into a browser to see the web application served by the Amazon ECS service.
If we have multiple request to handle, we can expand the task memory size and the CPU performance. However, this would be more expensive. We can also use the auto scalling option that will adjust automatically the memory size and the performance of the task according to the need.
Modification to the web application
To make our changes made to the source code reflected in our app hosted on AWS, we have to rebuild the image and re-push it on Docker Hub.
Now, we have to tell AWS to use our updated image. In the Clusters tab, we can click on Default.
Then, on Task Definition
Then, we can create a Revision for that specific task. AWS will automatically use the latest image found in Docker Hub when we create a new task revision.
When the new task get created, we can click on Actions > Update Service. By updating the service this will pull the latest image and run the services with the latest updates.
Instead of creating a new task revision, an alternative would be to just "Update the service" and check "Force a new Deployment".
Note that when we create a new task the public IP might change.
Last updated