DevOps (Day-85): Project-6 Utilizing AWS ECS Fargate and ECR with a Node JS app
Maninder Singh
AWS || Networking || Docker || Mentor & Tutor || System Engineer Antier Solution
Dear Learners In Today Article we will explain the Deploying a Node JS app with the help of AWS ECS Fargate and AWS ECR.
Table of Contents
Aim
Pre-requisite
Project Steps
Cloning the Source code from GitHub
Configuring image in AWS ECR
Configuring IAM
Pushing the image to ECR
Configuring AWS ECS
Using AWS Fargate
Open port in the Security Group.
Project Live Execution
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.
2 Create an EC2 instance in AWS Management console Navigate to the EC2 instance.
3 Clone the repository from GitHub to the EC2 instance.
4 Navigate to AWS ECR.
5 Create a repository, I have selected the Public repository and the repo name.
6 Select all the operating system versions according to the OS of Fargate you would select. Finally create the repository.
7 Now you can check the Public repository for the created repository.
Configuring IAM
8 Create an IAM user in the AWS Management console.
9 Attach the policies required for accessing the ECR.
10 Install the awscli in the AWS EC2 instance.
11 Connect the EC2 instance with AWS management console through awscli.
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.
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.
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.
15 After the image push, you can check the ECR for the image.
Configuring the AWS ECS
16 Navigate to the ECS repository in the AWS console.
17 Create a cluster in ECS.
18 Provide the cluster name,VPC and Subnet you want your application to be avaliable on.
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.
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 crated.
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.
Open Port in the security Group.
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.
Project Live Execution
16 Navigate to the task that we created. Take the Public IP.
17 We can see our application is live !!!!!!!!!!!
Hope I helped you in understanding the concept in a better way!!
Happy Learning
Next Topic
Day 86: Deploying a Portfolio app on AWS S3 Bucket using GitHub.
Digital Marketing Associate | Passionate About Digital Transformation & Audience Engagement
1 年Reserve your spot for our upcoming AWS Discovery Day workshop on securing your AWS cloud. Register today.? Registration Link: https://lnkd.in/g4Vwx-pn
DevOps Engineer @ IFS | AWS SAA Certified | AWS Community Builder | Enabling DevOps
1 年Good Job
kubernetes openstack docker linux
1 年Well done
Immediate Joiner | Searching for opportunities in Linux and AWS | RHCSA & RHCE Certified | Docker | Ansible | Shell Scripting | Preferred Location - Pune, Mumbai, Nashik, Ahemdabad, Indore, Surat, Vadodara
1 年Good job. Keep it up
AWS || Networking || Docker || Mentor & Tutor || System Engineer Antier Solution
1 年++