DevOps (Day-85): Project-6 Utilizing AWS ECS Fargate and ECR with a Node JS app
Day 85: #90DaysOfDevOpsChallenge
Dear Learners In Today Article we will explain the Deploying a Node JS app with the help of AWS ECS Fargate and AWS ECR.
Aim:-
The Project involves deploying a Node JS app on AWS ECS Fargate and AWS ECR.
Pre-requisite:-
Cloning the Source code form GitHub.
1 Let's go to the GitHub repository and copy the source code URL.
Cloning the Source code form GitHub Diagram
2 Create an EC2 instance in AWS Management console Navigate to the EC2 instance.
Create an EC2 instance in AWS Management console Navigate to the EC2 instance Diagram.
3 Clone the repository from GitHub to the EC2 instance.
Clone the repository from GitHub to the EC2 instance Diagram.
4 Navigate to AWS ECR.
Navigate to AWS ECR Diagra.
5 Create a repository, I have selected the Public repository and the repo name.
Create a repository, I have selected the Public repository and the repo name Diagram.
6 Select all the operating system versions according to the OS of Fargate you would select. Finally create the repository.
Select all the operating system versions according to the OS of Fargate you would select. Finally create the repository Diagram
Select all the operating system versions according to the OS of Fargate you would select. Finally create the repository Diagram
7 Now you can check the Public repository for the created repository.
Now you can check the Public repository for the created repository Diagram.
Configuring IAM
8 Create an IAM user in the AWS Management console.
Create an IAM user in the AWS Management console Diagram.
9 Attach the policies required for accessing the ECR.
Attach the policies required for accessing the ECR Diagram.
10 Install the awscli in the AWS EC2 instance.
Install the awscli in the AWS EC2 instance Diagram.
11 Connect the EC2 instance with AWS management console through awscli.
Connect the EC2 instance with AWS management console through awscli Diagram.
Push the image to ECR
12 Navigating 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.
Push the image to ECR Diagram.
Execute commands 1 and 2 in the EC2 instance.
Command1 : This will take the ecr token and provide to docker for the connection to the repository.
Command2: This will build the image from the Docker file.
Command1 : This will take the ecr token and provide to docker for the connection to the repository Diagram.
Command1 : This will take the ecr token and provide to docker for the connection to the repository Diagram.
14 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 form EC2 instance to ECR.
Execute commands 3 and 4 in EC2 instance Diagram.
15 After the image push, you can check the ECR for the image.
After the image push, you can check the ECR for the image Diagram.
Configuring the AWS ECS
16 Navigate to the ECS repository in the AWS console.
Navigate to the ECS repository in the AWS console Diagram.
17 Create a cluster in ECS.
Create a cluster in ECS
18 Provide the cluster name,VPC and Subnet you want your application to be avaliable on.
Provide the cluster name,VPC and Subnet you want your application to be avaliable on Diagram.
Using AWS Fargate
One of the Major disadvantage of using AWS EC2 for an application is we have to create multiple instance 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 for the cluster to run on.
Therefore, we will select AWS Fargate for the cluster to run on Diagram.
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.
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 Di
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.
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 Diagram.
5 Select the CPU and memory configuration according to the application load.
Select the CPU and memory configuration according to the application load Diagram.
6 Let the rest be default and click on next.
Let the rest be default and click on next Diagram.
7 Review the details and create the task.
Review the details and create the task Diagram.
8 Now, the task is finally created !!!!
9 Click on deploy and then Run task to run the task on the cluster we had crated.
Click on deploy and then Run task to run the task on the cluster we had crated Diagram.
10 Choose the cluster, Select the launch type to be Fargate.
Choose the cluster, Select the launch type to be Fargate Diagram.
11 Now Click to create.
Now Click to create Diagram.
12 The task is now deployed to the cluster.
The task is now deployed to the cluster Diagram.
Open Port in the security Group.
13 Navigate to the ENI ID in the task.
Navigate to the ENI ID in the task Diagram.
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.
Project Live Execution
16 Navigate to the task that we created. Take the Public IP.
17 We can see our application is live !!!!!!!!!!!
Thank you for reading!! Hope you find this helpful.
#day85challenge#90daysofdevops
Always open to suggestions..!!
~ Manoj Bhamidipati ๐
Next Topic
Day 86: Deploying a Portfolio app on AWS S3 Bucket using GitHub.