In the previous post , we learned about the ECS basics, In this blog, we are going to implement the sample web application using the ECS. Cr...
In the previous post, we learned about the ECS basics, In this blog, we are going to implement the sample web application using the ECS.
Creating Elastic Container Service (ECS);
We are going to run our container(docker image) on top of the cluster, so we are going to create 4 main steps.
Container definition:
It is basically to choose an image for the containers, Already had three images available by default. If you want to customize the image, we can use the customized image. Here we are using the default image (Nginx webserver).
Task definition:
Task definition is the second step to implement the ECS.
Click edit and edit your preference
Task definition name --> Give the name of the task
Network mode ---> Always must to be an aws vpc
Task execution role --> The IAM role used by your task.
FARGATE --> Launch type
Task size: Task memory can give up to 30GB
Task Cpu can give up to 4vcpu then save and click the next option.
Define the service:
The service can use as a load balancer, If not using load balancer it will automatically create a security group. A security group is created to allow all public traffic to your service, only on the container port specified. You can further configure security groups and network access outside of this wizard, After this step click next to create a cluster.
Cluster:
Type any name for the cluster it must be unique, click next.
It will show the cluster details like services(what are the services now running like Nginx), Tasks(inside the task it have task details and task definition of ECS instance), Metrics( it had a graph of CPU, memory utilization, and reservation), scheduled task(if you want a scheduled task can create and schedule the task), Tags(tag the cluster name).
Now the cluster is fully configured and the status has gone to the active stage. Click the services It shows the currently running service details like load balancing, network access.
Click the load balancing target group name it will redirect to the load balancing page
Load balancing has the following items Basic configuration, security groups, and attributes inside the description.
it has a DNS A record that records will point out the cluster nginx service.
Now all the setup was completed, need to check the A RECORD DNS working for the nginx server,
Finding the A record:
Go to ECS AWS cluster, open the cluster, click the services, service name(nginx-service), and click the load balancing target group name (it redirects to Load balancing Target group). click again load balancer. it goes to the load balancer. The description had a DNS name, A record.
Open the browser and paste the A record of a load balancer, It shows the Nginx webserver welcome page.
booyah!! we have Successfully configured the ECS using the default Nginx docker image.