DevOps(Day-73): Project - Deploying a nginx webapp through AWS Fargate, ECS & ECR - Part2

 

    • Pushing the image to ECR

    • Configuring AWS ECS

    • Using AWS Fargate

    • Open port in the security group.

    • Project live execution

Deploying an Nginx application image through AWS ECR to AWS Fargate and ECS to make our application live.

Pushing the image to ECR

  1. Navigate to the AWS ECR and view the push commands.

    Earlier, we had pushed the image to DockerHub in my previous blogs. The steps and concepts are similar but the platform differs. Generally in IT industry ECR is used as an image registry.

  2. Execute commands 1 and 2 in the EC2 instance.

    Command 1: This will take the ecr token and provide to docker for the connection to the repository.

    Command 2: This will build the image from the Dockerfile.

  3. Execute commands 3 and 4 in EC2 instance.

    Command 3: This tags the image that we have built using docker.

    Command 4: This command will push the image from EC2 instance to ECR.

  4. After the image push, you can check the ECR for the image.

  5. Navigate to the ECS repository in the AWS console.

  6. Create a cluster in ECS.

  7. Provide the Cluster name, VPC and subnet you want your application to be available on.

One of the major disadvantages of using AWS EC2 for an application is we have to create multiple instances in case of an application load increase that will have a cost impact.

To avoid this, we will use AWS Fargate which is a serverless technique of providing the specification of applications that will be automatically managed without spinning off any instance.

  1. Therefore, we will select AWS Fargate fo the cluster to run on.

  2. The cluster is now ready!!!

  3. We used to run docker run to create a container in the EC2 instance out of the docker image. That was nothing but a task. Therefore let's create a task definition for our cluster.

  4. Provide the task name, Container image details and ports for the application to be run on. We must have exposed a port in our Dockerfile.

  5. Select the CPU and memory configuration according to the application load.

  6. Let the rest be default and click on next.

  7. Review the details and create the task.

  8. Now, the task is finally created!!!!

  9. Click on deploy and then Run task to run the task on the cluster we had created.

  10. Choose the cluster. Select the launch type to be Fargate.

  11. Now click to create.

  12. The task is now deployed to the cluster.

  13. Navigate to the ENI ID in the task.

  14. Go to the security group URL.

  15. Navigate to the Inbound rule in the security group and open the Port 80 which is HTTP and select my IP to have access for myself.

  16. Navigate to the task that we created. Take the public IP.

  17. We can see our application is live!!!!!!!

Thanks for reading my article. Have a nice day.

Comments

Popular posts from this blog

DevOps (Day-1) Introduction

DevOps(Day-3) - File Management in Linux

DevOps(Day-2) Linux