12 Weeks AWS Workshop Challenge
Week Seven: Containers
Containers
In real life, when you think of containers, you think of large, heavy, steel boxes on a ship, delivering your SHEIN merchandise from across the ocean. But, in computing, containers refer to portable, lightweight services packaged with the relevant libraries and dependencies so that they can be isolated and run independently and in parallel.
Sometimes (all the time) these containers need to be monitored, managed, and used for different workloads and environments, and this is where container orchestration comes in…
Container Orchestration
Container Orchestration is the process of managing your containers by configuring, provisioning and deploying them. Container Orchestration allocates the relevant resources for your containers, and ensures that they have observability enabled such as monitoring and logging the health of the containers.
Container Orchestration is also responsible for autoscaling and load balancing your containers to ensure that there is high availability and that the networking traffic is routed appropriately to healthy resources.
Container Orchestration manages the entire lifecycle of your resources, from initial deployment to consequential updates and upgrades.
Benefits of Container Orchestration
The benefits of Container Orchestration services are that they eliminate overhead for the developer as the orchestrators are easy to deploy and maintain, and they have tracing, logging and monitoring enabled.
Therefore, you should use Container Orchestrators if you want to easily manage your containers. Container Orchestration is even more beneficial in scenarios where there are numerous large and complex containers.
Amazon Elastic Container Service is an example of a Container Orchestration service.
AWS Elastic Container Service
AWS Elastic Container Service (ECS) is a high-performance container orchestration service, it abstracts the need for you to install and use your own container orchestration software. Amazon ECS is fully managed, scalable, and allows you to run your containerized applications on the cloud by using either AWS Elastic Compute Cloud (EC2) Instance or by using AWSs serverless offering AWS Fargate.
Benefits of Elastic Container Service
The Amazon Elastic Container Service is affordable and you get to take advantage of the AWS ecosystem of services for monitoring, logging, load balancing, and security. You also take advantage of the global, scalable, high available infrastructure of AWS.
You can run your Amazon ECS applications by either using AWS Elastic Compute Cloud (EC2) or the serverless AWS Fargate. AWS Fargate allows you to run your containers without managing servers or clusters.
Docker
Docker allows you to deploy applications quickly. Docker is responsible for running and managing containers on ECS.
Components of Elastic Container Service
Task Definition: A task definition is a template for running your tasks, which consists of configurations. A task definition is a JSON file that describes your containers. This text file can contain blueprints for your application that describe which launch type to use, and what data volumes should be used with the containers in your task.
Task: A task deploys containers onto your EC2 cluster. After you have configured your task definition, you can specify how many tasks you wish to launch.
Task Placement Strategies: With ECS you have various strategies on how you want your tasks to be configured.
Service: A service ensures that you have tasks running, as they manage tasks. If a task fails, the service will launch a healthy task.
Cluster: an ECS cluster is a logical grouping of EC2 instances that you can place your containers onto. A cluster can be comprised of a combination of EC2 launch types and Fargate launch types.
Elastic Container Registry: Amazon ECR is a fully managed Docker container registry where you can store your images and repositories in a AWS Elastic Container Registry (ECR).
Cost? You don’t pay for using AWS ECS, you will be charged for the running resources you provision.
Creating an AWS Elastic Container Cluster
Do you have a running instance of an AWS Elastic Container?
Yes? Well, that’s cool. See you in my next post then.
No? Ok, no big deal. Let’s provision some resources.
Prerequisites
To create an AWS Elastic Container Cluster you will need:
(1) an AWS account to configure the resources.
Step by Step Guide
How to Launch a WordPress Site using AWS Elastic Container Service: Fargate Launch Type
- Login to the AWS Management Console using your IAM user name.
- You will be using the US East (N. Virginia) (us-east-1) region. So, on the top right navigation bar, make sure N. Virginia is selected.
- On the top left corner, click on the Services button.
- Select Containers on the left side of the drop down menu.
- Select Elastic Container Service.
- Select Create cluster.
- Cluster name: myCluster.
- Infrastructure: AWS Fargate (Serverlss).
- Leave everything as default.
- Click Create.
- Click on myCluster.
- On Services, click Create.
- Existing cluster: myCluster.
- Compute options: Launch type.
- Launch type: FARGATE.
- Platform version: Latest.
- Deployment Configuration. Application Type: Service.
- Task Definition (create a new Task definition): click Task definitions.
- Click Create new task definition.
- Task definition configuration. Task definition family: my-task-definition.
- Infrastructure requirements. Launch types: check AWS Fargate.
- OS, Architecture, Network mode. Operating system/ Architecture: Linux/X86_64.
- CPU: 1 vCPU. Memory: 3 GB.
- Container -1. Container details. Name: my-app. Image URI: wordpress: 6.2. Essential container: Yes.
- Leave everything as default. Click Create.
- Task definition successfully created. Navigate back to your Create service page.
- Family: my-task-definition. Revision: 1 (Latest).
- Service name: my-service.
- Service type: Replica
- Desired tasks: 2.
- Leave everything as default. Click Create.
- Your service has been deployed successfully.
- Click on my-service.
- Navigate to Tasks.
- Click on the Task.
- Select Networking.
- Click on the default Security Group.
- Click Edit inbound rules.
- Click Add rule. Type: HTTP. Source: Anywhere-IPv4.
- Click Add rule. Type: HTTPS. Source: Anywhere-IPv4.
- Click Save rules.
- Navigate back to your tasks page. Open the Public IP address.
- You are redirected to the WordPress configuration page.
- Congratulations! You launched WordPress using Fargate.
- Clean Up.
Important: Clean Up Resources
Don’t get a Bill Shock by leaving unnecessary resources running.
- Navigate back to Amazon ECS.
- Click Clusters.
- Click myCluster.
- Click Delete cluster.
- Enter delete myCluster.
- Click Delete.
End of Step by Step Guide
Conclusion
Congratulations! In this Step by Step Guide, you launched WordPress Site using the Amazon Elastic Container Service — Fargate launch type.
…And theoretically, you touched upon the basic concepts of containers, container orchestration and Amazon ECS. The more you work with Amazon Elastic Container Service, you will eventually configure more powerful and purpose-built containers, and integrate more services within the AWS ecosystem.
Blog Post Summary
Theory
Introduction to Containers, Container Orchestration and Amazon Elastic Container Service.
Practical
Launching WordPress using an AWS Elastic Container Service — Fargate Launch Type.