<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhiraj Thakur on Medium]]></title>
        <description><![CDATA[Stories by Abhiraj Thakur on Medium]]></description>
        <link>https://medium.com/@abhiraj2001?source=rss-7117868d7c15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*D7v_LT7K_XM9HJh6etLsKQ.jpeg</url>
            <title>Stories by Abhiraj Thakur on Medium</title>
            <link>https://medium.com/@abhiraj2001?source=rss-7117868d7c15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:45:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhiraj2001/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GitLab CI/CD Pipeline for Application Deployment on AWS EC2]]></title>
            <link>https://abhiraj2001.medium.com/gitlab-ci-cd-pipeline-for-application-deployment-on-aws-ec2-fd5340720bb9?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd5340720bb9</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Mon, 03 Mar 2025 08:13:53 GMT</pubDate>
            <atom:updated>2025-03-03T08:13:53.097Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is GitLab?</h3><p>GitLab is an open-source, web-based DevOps platform that covers the entire software development lifecycle (SDLC). It combines source code management (SCM), continuous integration/continuous deployment (CI/CD), security, and collaboration features in one app. Unlike GitHub, which mainly focuses on hosting code, GitLab offers an all-in-one experience — from creating code to deploying it.</p><h3>Why GitLab?</h3><p>Many development teams use GitLab because it simplifies workflows and automates complex DevOps tasks. Key benefits include:</p><p>✅ <strong>Version Control with Git</strong> — GitLab provides a repository to manage source code with Git.<br>✅ <strong>Built-in CI/CD Pipelines</strong> — Automates testing, building, and deployment with .gitlab-ci.yml.<br>✅ <strong>Security &amp; Compliance</strong> – Includes security testing, dependency scanning, and policy management.<br>✅ <strong>Container &amp; Kubernetes Integration</strong> – Easily deploy applications using Docker and Kubernetes.<br>✅ <strong>Collaboration &amp; Issue Tracking</strong> – Features like merge requests, issues, and wikis enhance team collaboration.</p><h3>GitLab vs. GitHub: What’s the Difference?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*jNWbUFFn7HFGX8qraY9ALA.png" /></figure><p>While GitHub is widely used for open-source projects, <strong>GitLab is preferred for enterprises</strong> needing strong DevOps capabilities.</p><h3>How GitLab Works</h3><p>GitLab consists of <strong>three main areas</strong>:</p><ol><li><strong>GitLab Repository</strong> — Stores source code and tracks changes using Git.</li><li><strong>GitLab CI/CD</strong> — Automates testing, builds, and deployments with .gitlab-ci.yml.</li><li><strong>GitLab Runner</strong> — Executes CI/CD jobs in environments like Docker, Kubernetes, or VMs.</li></ol><h3>Getting Started with GitLab</h3><p>1️⃣ <strong>Sign up for GitLab</strong> at <a href="https://gitlab.com/">gitlab.com</a>.<br>2️⃣ <strong>Create a Repository</strong> and push code using:</p><pre>git clone https://gitlab.com/your-project.git<br>git add .<br>git commit -m &quot;Initial commit&quot;<br>git push origin main</pre><p>3️⃣ <strong>Configure CI/CD</strong> by adding a .gitlab-ci.yml file to automate pipelines.<br>4️⃣ <strong>Run Your First Pipeline</strong> in the <strong>CI/CD &gt; Pipelines</strong> section.</p><h3>Practical:</h3><p>Repository <a href="https://gitlab.com/twsdevops1/node-todo-cicd">Link</a></p><p>GitLab CI/CD pipeline for Node Application Deployment.</p><ul><li>Create a .gitlab-ci.yml file:</li></ul><pre>stages:<br>  - test<br>  - build<br>  - scan<br>  - deploy<br><br>test-job:<br>  stage: test<br>  image: node:latest<br>  tags:<br>    - dev-runner<br>  script:<br>    - npm install<br>    - npm test<br><br>build-job:<br>  stage: build<br>  image: docker:latest<br>  services:<br>    - docker:dind<br>  tags:<br>    - dev-runner<br>  before_script:<br>    - docker login -u &quot;$DOCKER_USERNAME&quot; -p &quot;$DOCKER_PASSWORD&quot;<br>  script:<br>    - docker build -t $DOCKER_USERNAME/node-todo-app:latest .<br>    - docker push $DOCKER_USERNAME/node-todo-app:latest<br><br>scan-job:<br>  stage: scan<br>  image: docker:latest<br>  services:<br>    - docker:dind<br>  tags:<br>    - dev-runner<br>  before_script:<br>    - apk add --no-cache curl<br>    - curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin<br>    - docker login -u &quot;$DOCKER_USERNAME&quot; -p &quot;$DOCKER_PASSWORD&quot;<br>  script:<br>    - docker pull $DOCKER_USERNAME/node-todo-app:latest<br>    - trivy image $DOCKER_USERNAME/node-todo-app:latest --exit-code 0 --format json -o trivy-report.json<br>  artifacts:<br>    paths:<br>      - trivy-report.json<br>    expire_in: 1 week<br>    reports:<br>      container_scanning: trivy-report.json<br><br>deploy-job:<br>  stage: deploy<br>  image: docker:latest<br>  services:<br>    - docker:dind<br>  tags:<br>    - dev-runner<br>  before_script:<br>    - echo &quot;$DOCKER_PASSWORD&quot; | docker login -u &quot;$DOCKER_USERNAME&quot; --password-stdin<br>  script:<br>    - ssh -o StrictHostKeyChecking=no ec2-user@your-ec2-public-ip &amp;&amp; docker-compose up -d</pre><h4><strong>About the script:</strong></h4><p><strong>Test Job (</strong><strong>test-job)</strong></p><ul><li>Installs project dependencies (npm install).</li><li>Runs the test suite (npm test).</li></ul><p><strong>Build Job (</strong><strong>build-job)</strong></p><ul><li>Builds a Docker image (docker build) and tags it.</li><li>Pushes the image to a Docker registry (docker push).</li></ul><p><strong>Security Scan Job (</strong><strong>scan-job)</strong></p><ul><li>Pulls the latest Docker image.</li><li>Scans the image using <strong>Trivy</strong> to check for vulnerabilities.</li><li>Outputs a JSON security report.</li></ul><p><strong>Deployment Job (</strong><strong>deploy-job)</strong></p><ul><li>Runs docker-compose up -d to start the application in detached mode.</li></ul><h4><strong>Now, register the EC2 as the runner:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6-L7sZj7VwiwsshVCsbuLg.png" /></figure><p>Click on New project runner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5X5_yaEgnXpyDO0SPYa-kg.png" /></figure><p>Name the tag. Click on Create runner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*29ulhI23avhm2KNvhSV0AA.png" /></figure><p>Choose Linux as a platform, as we select Linux as the EC2 OS.</p><p>Click on How do I install GitLab runner? Choose the suitable architecture, then copy the command to install the GitLab runner, in the EC2 instance.</p><p>Then register the GitLab runner in EC2, by running the command.</p><p>Verify that the runner is available to pick up jobs.:</p><pre>gitlab-runner run</pre><p>When any commit is done in the repository, it runs the test cases, builds the docker image, scans the image, pushes the run, and deploys the application in EC2.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd5340720bb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete Guide for Docker — For Beginners]]></title>
            <link>https://abhiraj2001.medium.com/complete-guide-for-docker-for-beginners-97e2308dfafe?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/97e2308dfafe</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Tue, 18 Feb 2025 11:21:43 GMT</pubDate>
            <atom:updated>2025-02-18T11:21:43.596Z</atom:updated>
            <content:encoded><![CDATA[<h3>Complete Guide for Docker — For Beginners</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*L9i1Nka8ZZBc0o2Jgfrbvw.png" /></figure><h3>Introduction</h3><p>If you’re just starting with Docker, there are tons of great tutorials online.</p><p>The agenda for this article is “Containerization of a Two-Tier Application using Docker, Docker Compose, and Image Scanning with Docker Scout.”</p><p>Let’s reversive the technical terms:</p><ul><li>Docker: Is an open-source containerization platform that allows developers to package applications and their dependencies into lightweight, portable containers that can run consistently across different environments.</li><li>Docker Compose: Is a tool that defines and runs multi-container Docker applications. It allows you to use a single YAML file to configure services, networks, and volumes, making it easier to manage multiple containers as a single stack.</li><li>Docker Scout: Is a solution for proactively enhancing software supply chain security by analyzing container images and compiling an inventory of components, known as a Software Bill of Materials (SBOM).</li><li>Docker Image: Is a read-only template that contains a set of instructions for creating a container, that can run on the Docker platform. It includes everything needed to run an application, such as the application code, libraries, dependencies, and the runtime environment.</li><li>Docker Container: Is a standardized, encapsulated environment that runs applications. It includes all the necessary components such as code, dependencies, and libraries needed to run the application code without using host-machine dependencies.</li><li>Dockerfile: Is a text file that contains a series of instructions for building a Docker image. These instructions are used by the Docker daemon to assemble the image layer by layer. Dockerfiles are essential for automating the process of creating Docker images, which can then be used to launch containers</li></ul><p>If you’re still not getting it, don’t worry! There are plenty of online resources you can check out to understand better.</p><h3>Let’s Start</h3><p>Refer to the <a href="https://github.com/LondheShubham153/two-tier-flask-app">GitHub</a> for two-tier application code.</p><h4>Dockerfile:</h4><p>To create the Docker image, let’s begin with creating the Dockerfile:</p><pre>FROM python:3.9-slim<br><br>WORKDIR /app<br><br>RUN apt-get update \<br>    &amp;&amp; apt-get upgrade -y \<br>    &amp;&amp; apt-get install -y gcc default-libmysqlclient-dev pkg-config \<br>    &amp;&amp; rm -rf /var/lib/apt/lists/*<br><br>COPY ./two-tier-flask-app/requirements.txt .<br><br>RUN pip install mysqlclient<br>RUN pip install --no-cache-dir -r requirements.txt<br><br>COPY ./two-tier-flask-app .<br><br>CMD [&quot;python&quot;, &quot;app.py&quot;]</pre><p><strong>About the </strong>Dockerfile:</p><p><strong>Base Image:</strong></p><ul><li>Uses python:3.9-slim.</li></ul><p><strong>Working Directory:</strong></p><ul><li>Sets /app as the working directory.</li></ul><p><strong>System Packages:</strong></p><ul><li>Installs gcc, default-libmysqlclient-dev, and pkg-config.</li></ul><p><strong>Application Dependencies:</strong></p><ul><li>Copies requirements.txt and installs dependencies including mysqlclient.</li></ul><p><strong>Application Code:</strong></p><ul><li>Copies the application code from ./two-tier-flask-app.</li></ul><p><strong>Command:</strong></p><ul><li>Runs the application using python app.py.</li></ul><p>Run the command docker buid -t two-tier-flask-app:v1 .</p><p>two-tier-flask-app : image name, . : location of the Dockerfile is the current working directory.</p><p>Let’s see the image, the run the command: docker images</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*wIi27kro4DKsXlm2aHpPgw.png" /></figure><p>You can see that the image has been created.</p><p>Congratulations!!! or Not. What is the problem? Notice the size of the image, 564MB half a GB, what is wrong?</p><p>In the production environment, you would not be running a single image, there would be more than a single image, and if every image is of half GB size then it would be costlier due to resource consumption, and affects the availability of the application.</p><p>What is the solution then? Use Multistage Docker to create the Docker images.</p><p>Multistage Docker: Allows you to create multiple stages in a single Dockerfile . In each stage, you can install the base dependencies, copy files to another stage, and install additional dependencies.</p><p>As a result, there is much reduction in the Docker image size, by 40% to 60%.</p><p>Here is the Multistage Dockerfile :</p><pre># ------------------- Stage 1: Build Stage --------<br>FROM python:3.9 AS builder<br><br>WORKDIR /app<br><br>RUN apt-get update &amp;&amp; \<br>    apt-get install -y --no-install-recommends gcc default-libmysqlclient-dev pkg-config &amp;&amp; \<br>    rm -rf /var/lib/apt/lists/* <br><br>COPY ./two-tier-flask-app/requirements.txt .<br>RUN pip install --no-cache-dir -r requirements.txt<br><br>#----------------- Stage 2: Final Stage ---------<br><br>From python:3.9-slim <br><br>WORKDIR /app<br><br>RUN apt-get update &amp;&amp; \<br>    apt-get install -y --no-install-recommends libmariadb3 &amp;&amp; \<br>    rm -rf /var/lib/apt/lists/* <br><br><br>COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages<br>COPY ./two-tier-flask-app .<br><br>CMD [&quot;python&quot;, &quot;app.py&quot;]</pre><p>Here I created two stages: Builder Stage and Final Stage</p><p>Builder Stage :</p><ul><li>Prepares the environment by installing dependencies.</li><li>Builds Python packages in an isolated environment.</li></ul><p>Final Stage :</p><ul><li>Uses a <strong>lightweight image</strong> (python:3.9-slim) for the final container.</li><li><strong>Excludes unnecessary build tools</strong> (e.g., gcc, pkg-config), keeping the image small and efficient.</li><li>Runs the Flask application.</li></ul><p><strong>Benefits of this Approach:</strong></p><p>✅ Reduces final image size.<br>✅ Improves security by removing unnecessary tools.<br>✅ Ensures a clean, minimal production image.</p><p>Build the image.</p><p>Let’s see what difference it makes, in size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*wTuyUPhL9izMmzWJIaXdvA.png" /></figure><p>The image size is now 223MB , reduction by approx60%.</p><p>What next? Push to DockerHub and then deployment. No, the next step after building your Docker image is to scan it for vulnerabilities using Docker Scout, and then push it to your DockerHub or other repository. This is a good practice to ensure that your images are secure before deploying them.</p><p>To scan for vulnerabilities I used the Docker Scout.</p><pre>docker scout cves two-tier-flask-app:v2 --format sarif --output report.json</pre><ul><li>docker scout cves: This is the base command to scan a Docker image for CVEs using Docker Scout.</li><li>two-tier-flask-app:v2: This specifies the Docker image to be scanned. It’s the image name and tag.</li><li>— format sarif: This option specifies the output format as SARIF (Static Analysis Results Interchange Format). SARIF is a standard JSON-based format for static analysis tool results.</li><li>— output report.json: This option directs the output of the scan to a file named report.json. The report, formatted as SARIF, will be saved in this file.</li></ul><p>View the official documentation <em>here</em>, to learn more about docker scout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*hNdPoq2KKfbZsqcq5Tv1Tg.png" /></figure><p>This is the sample image showing the output. It has prepared a detailed report in JSON format about the vulnerabilities. Read the report, fix the code, build the image, and scout it out, till you find no or low-level vulnerabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97e2308dfafe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[User Managment and Backup in Linux for Beginners]]></title>
            <link>https://abhiraj2001.medium.com/user-managment-and-backup-in-linux-for-beginners-0c451389c286?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c451389c286</guid>
            <category><![CDATA[user-management]]></category>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Mon, 17 Feb 2025 12:50:00 GMT</pubDate>
            <atom:updated>2025-02-17T12:50:00.333Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*t_JNfxSFzf0nSNPKTbhBxw.jpeg" /></figure><p>If you are working as a Linux Administrator, then creating users, adding them to groups, modifying users, and performing backups are your day-to-day tasks. Running individual commands for these tasks can be time-consuming, or, in short, BORING!</p><p>How would it be if you had a script to assist you in creating and managing users, and backing up files or folders?<br>This article provides the necessary information and a script to help you create your own.</p><h3>Script:</h3><pre>#!/bin/bash<br><br>#Add user function<br>add_user(){<br>  read -p &quot;Enter the username: &quot; username<br>  read -p &quot;Enter the password: &quot; password<br>  echo<br>  read -p &quot;Enter group (leave blank for default): &quot; group<br>  useradd -m -p &quot;$(openssl passwd -1 $password)&quot; &quot;$username&quot;<br>  [[ -n $group ]] &amp;&amp; usermod -aG &quot;$group&quot; &quot;$username&quot;<br>  echo &quot;User $username has been added successfully.&quot;<br>}<br><br># Delete user function<br>delete_user(){<br>  read -p &quot;Enter the username to delete: &quot; username<br>  userdel -r &quot;$username&quot;<br>  echo &quot;User $username has been deleted successfully.&quot;<br>}<br><br># Modify user function<br>modify_user(){<br>   read -p &quot;Enter the username to modify: &quot; username<br>   read -p &quot;What you want to modify? (password/group): &quot; modify<br><br>   if [ &quot;$modify&quot; == &quot;password&quot; ]; then<br>       read -p &quot;Enter the new password: &quot; password<br>       usermod -p &quot;$(openssl passwd -1 $password)&quot; &quot;$username&quot;<br>       echo &quot;Password has been updated successfully.&quot;<br>   elif [ &quot;$modify&quot; == &quot;group&quot; ]; then<br>       read -p &quot;Enter the new group: &quot; group<br>       usermod -aG &quot;$group&quot; &quot;$username&quot;<br>       echo &quot;Group has been updated successfully.&quot;<br>   else<br>       echo &quot;Invalid choice. Please try again.&quot;<br>   fi<br>}<br><br># Create group function<br>create_group(){<br>  read -p &quot;Enter the group name: &quot; group<br>  groupadd &quot;$group&quot;<br>  echo &quot;Group $group has been created successfully.&quot;<br>}<br><br>#Backup directory function<br>backup_directory(){<br>  read -p &quot;Enter the directory to backup: &quot; source_dir<br>  read -p &quot;Enter the destination directory: &quot; dest_dir<br>  timestamp=$( date +%Y-%m-%d_%H-%M-%S )<br>  archive_name=&quot;${dest_dir}_${timestamp}.tar.gz&quot;<br>  tar -czf &quot;$archive_name&quot; &quot;$source_dir&quot;<br>  echo &quot;Backup has been created successfully.&quot;<br>}<br><br># Main function<br>while true ; do<br>    echo &quot;<br>    User Management<br>    --------------------------<br>    This script will assist you in user management and backup the data.<br>    --------------------------<br>    Enter:<br>    1. Add user<br>    2. Delete user<br>    3. Modify user<br>    4. Create group<br>    5. Backup directory<br>    6. Exit<br>    --------------------------<br>    &quot;<br>    read -p &quot;Enter your choice: &quot; choice<br><br>    case $choice in<br>        1)<br>            add_user<br>            ;;<br>        2)<br>            delete_user<br>            ;;<br>        3)<br>            modify_user<br>            ;;<br>        4)<br>            create_group<br>            ;;<br>        5)<br>            backup_directory<br>            ;;<br>        6)<br>            echo &quot;Exiting...&quot;<br>            break<br>            ;;<br>        *)<br>            echo &quot;Invalid choice. Please try again.&quot;<br>      ;;<br>    esac<br>done</pre><p>This Bash script provides a simple command-line interface for managing users and creating backups on a Linux system. It offers the following functionalities:</p><p><strong>User Management:</strong></p><ul><li>Add new users with a specified password and group.</li><li>Delete existing users.</li><li>Modify user passwords or group memberships.</li></ul><p><strong>Group Management:</strong></p><ul><li>Create new groups.</li></ul><p><strong>Backup:</strong></p><ul><li>Create compressed backups of directories</li></ul><h3>Script Options</h3><p>The script presents a menu with the following options:</p><ol><li><strong>Add user:</strong></li></ol><ul><li>Prompts for a username, password, and optional group.</li><li>Creates a new user account with the provided details.</li></ul><p><strong>2. Delete user:</strong></p><ul><li>Prompts for a username.</li><li>Deletes the user account and their home directory.</li></ul><p><strong>3. Modify user:</strong></p><ul><li>Prompts for a username and whether to modify the password or group.</li><li>Updates the user’s password or group accordingly.</li></ul><p><strong>4. Create group:</strong></p><ul><li>Prompts for a group name.</li><li>Creates a new group.</li></ul><p><strong>5. Backup directory:</strong></p><ul><li>Prompts for the source directory to back up and the destination directory.</li><li>Creates a compressedtar.gz archive of the source directory in the destination.</li></ul><h3>Usage</h3><p>1. Save the script to a file (e.g., user_management.sh).<br>2. Make the script executable: chmod +x user_management.sh.<br>3. Run the script:./user_management.sh</p><h3>Notes</h3><ul><li><strong>Security:</strong> The script uses openssl passwd -1 for password hashing. While this is a common method, consider using more secure hashing algorithms (like bcrypt or SHA-512) for production environments.</li><li><strong>Error Handling:</strong> The script has limited error handling. It’s recommended to implement more robust error checking and handling for production use.</li><li><strong>Input Validation:</strong> Always validate user input to prevent unexpected behavior or security issues.</li><li><strong>Permissions:</strong> Make sure the script is run with appropriate permissions (sudo) if you need to perform user and group management.</li><li><strong>Backups:</strong> Store backups in a safe and separate location.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c451389c286" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mounting of AWS S3 Bucket on Amazon EC2 Linux Using S3FS]]></title>
            <link>https://abhiraj2001.medium.com/mounting-of-aws-s3-bucket-on-amazon-ec2-linux-using-s3fs-c4e5ec7e8d3f?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4e5ec7e8d3f</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 15:47:08 GMT</pubDate>
            <atom:updated>2024-01-15T15:59:39.950Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TNACa3r_QjW-f7AgESrTeQ.png" /></figure><p>This project demonstrates how you can create S3 bucket, upload files in S3 bucket and download files from S3 bucket using AWS CLI.</p><h4>Step 1: Create IAM User:</h4><p>Begin by accessing your AWS account and navigating to the Identity and Access Management (IAM) service. Once in IAM, locate the ‘Users’ section. Here, take the following steps to create a new IAM User:</p><ul><li>Click on ‘Users’ in the IAM dashboard.</li><li>Look for the ‘Create user’ button and click on it to initiate the process of setting up a new IAM User.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*emZ_nluBa74hvPc2p6O63A.png" /></figure><ul><li>Provide the IAM username:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*y3mefMVzqZA_Ld71TszkVw.png" /></figure><p>Click on next.</p><ul><li>Choose Attach policies directly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*MHrvjn8JEMYTk6AadAUN7w.png" /></figure><ul><li>Permission policies: Attach the AmazonS3FullAccess.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42VBq74D0FlR8ehq2K5c-Q.png" /></figure><p>Click on next.</p><ul><li>Review and create:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*neAhUNS0jktFp1WEbTkZmw.png" /></figure><p>Click on Create user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*OS-imzyOE0igeU1OYxvQwA.png" /></figure><p>User, day89 has been created.</p><h4>Step 2: Creating IAM User Credentials:</h4><ul><li>Click on the User, which you just now created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*8U25ub5nmwrHvO2nPcPLAQ.png" /></figure><ul><li>Click on Security Credentials, where you would see the Access keys, click on Create access key.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*qBu4tGgbsZDa6r08v3HQTw.png" /></figure><ul><li>Choose Command Line Interface (CLI).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*ZWm8bJ6pfIeQZ6ZCsE1uUg.png" /></figure><p>Click on the confirmation bar.</p><ul><li>Tag your credentials.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*v3_HSLG4Onn1_2xlR1h-hw.png" /></figure><p>Click on Create access key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*ssjoYY-Cct33LSYWm_VRpQ.png" /></figure><p>Access Key and Secret key would be generated, scroll down, download them to save it.</p><h4>Step 3: Create and Lauch EC2 instance.</h4><p>Now create t2.micro EC2 instance, and ssh into it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*XYBoHbfkWWDfUvcwTW-LQQ.png" /></figure><p>Install the AWS CLI:</p><pre>sudo apt-get update #updating the package list<br>sudo apt-get install awscli #installing aws cli<br>aws --version # verifying the installing</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*Ubm7c_0GYz8jwb1isQKqOA.png" /></figure><p><strong>Configuring the AWS Account:</strong></p><p>Run the below command to your aws cli:</p><pre>aws configure</pre><p>Then enter your Aws Access Key ID, AWS Secret Access Key, Default region name and Default output format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*XFkgKq0-O3bZdb1JnrStFw.png" /></figure><p>You have successfully configured your AWS CLI.</p><p>In order to check your configuration, run the below command:</p><pre>aws s3 ls</pre><p>It will list all the s3 buckets created in your AWS account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*PgM5xaSrTpr2bcxNxMpOrQ.png" /></figure><h4>Step 4: Creating S3 Bucket through AWS CLI:</h4><p>Run the below command to create the s3 bucket using aws cli:</p><pre>aws s3api create-bucket --bucket your-unique-bucket-name --region your-preferred-region</pre><p>Replace the following values with your desired values:</p><ul><li>your-unique-bucket-name</li><li>your-preferred-region</li></ul><p>Just for example lets create a bucket with name day8901152024, run the below command:</p><pre>aws s3api create-bucket --bucket day8901152024 --region us-east-1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7T3Aq-HipGnq_vCU5X1wlw.png" /></figure><p>You can verify by opening your AWS account, S3 Buckets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UeKuJQR8f5wbJXGnEbIrkg.png" /></figure><h4>Step 5: Create and Upload:</h4><p>Create a folder and inside folder create files:</p><pre>mkdir day89<br>cd day89<br>touch 1.txt<br>touch 2.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*xsxpGMPYfotn0OchY4LFVA.png" /></figure><p><strong>Upload:</strong></p><p>Run the command to upload:</p><pre>aws s3 sync your-local-folder s3://your-s3-bucket-name</pre><ul><li>Replace your-local-folder with the path to the local folder you want to upload, get the path by running the pwd command.</li><li>Replace your-s3-bucket-name with the name of your S3 bucket.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*xJG5lzndQdExIeIi5R--Wg.png" /></figure><p>In order to verify the contents has been uploaded you either visit your AWS account or run the below command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJRuZrc4rFSNpqzZ-Ne1JQ.png" /></figure><pre>aws s3 ls s3://your-unique-bucket-name</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*qF3jB48qwkdVchRgOMkGPg.png" /></figure><h4>Step 6: Downloading the file contents from AWS S3 bucket.</h4><p>Run the below command:</p><pre>aws s3 cp s3://your-s3-bucket-name/your-object-key /path/to/local/directory</pre><ul><li>Replace your-s3-bucket-name with the name of your S3 bucket.</li><li>Replace your-object-key with the key of the object (file) you want to download from the bucket.</li><li>Replace /path/to/local/directory with the local directory where you want to save the downloaded file.</li></ul><p>Create a new directory and get a path to that directory then run the below command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*hTtNFiQM_RprDvYykYDUmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*fguKbW8Skzn-eZ_-KQtjpg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4e5ec7e8d3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Django Todo App on AWS EC2 with Kubeadm Kubernetes Cluster]]></title>
            <link>https://abhiraj2001.medium.com/deploying-a-django-todo-app-on-aws-ec2-with-kubeadm-kubernetes-cluster-593e96a387a7?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/593e96a387a7</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Sun, 14 Jan 2024 16:53:41 GMT</pubDate>
            <atom:updated>2024-01-14T16:53:41.770Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*RCh4IeC7T4yoGFGWYvZluQ.png" /></figure><h4>Step 1: Creating Kubernetes Cluster:</h4><p>Create 2 EC2 instances i.e. Master Node and Worker Node.</p><p>Make sure that you pass the User Data in Advance setting at the time of creating the EC2 instance.</p><p><strong>User Data for Master Node:</strong></p><pre>#!/bin/bash<br># Check if script is running with root privileges<br>if [ &quot;$EUID&quot; -ne 0 ]; then<br>  echo &quot;Please run this script as root&quot;<br>  exit 1<br>fi<br># Update and install Docker<br>apt update -y<br>apt install docker.io -y<br># Start and enable Docker service<br>systemctl start docker<br>systemctl enable docker<br># Add Kubernetes repository and install Kubernetes components<br>curl -fsSL &quot;https://packages.cloud.google.com/apt/doc/apt-key.gpg&quot; | gpg --dearmor -o /etc/apt/trusted.gpg.d/kubernetes-archive-keyring.gpg<br>echo &#39;deb https://packages.cloud.google.com/apt kubernetes-xenial main&#39; &gt; /etc/apt/sources.list.d/kubernetes.list<br>apt update -y<br>apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y<br># Initialize Kubernetes cluster<br>kubeadm init<br># Configure kubectl for the regular user<br>mkdir -p $HOME/.kube<br>sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config<br>sudo chown $(id -u):$(id -g) $HOME/.kube/config<br># Alternatively, if you are the root user, you can run:<br># export KUBECONFIG=/etc/kubernetes/admin.conf<br># Apply Weave CNI<br>kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml</pre><p><strong>User Data for Worker Node:</strong></p><pre>#!/bin/bash<br># Check if script is running with root privileges<br>if [ &quot;$EUID&quot; -ne 0 ]; then<br>  echo &quot;Please run this script as root&quot;<br>  exit 1<br>fi<br># Update and install Docker<br>apt update -y<br>apt install docker.io -y<br># Start and enable Docker service<br>systemctl start docker<br>systemctl enable docker<br># Add Kubernetes repository and install Kubernetes components<br>curl -fsSL &quot;https://packages.cloud.google.com/apt/doc/apt-key.gpg&quot; | gpg --dearmor -o /etc/apt/trusted.gpg.d/kubernetes-archive-keyring.gpg<br>echo &#39;deb https://packages.cloud.google.com/apt kubernetes-xenial main&#39; &gt; /etc/apt/sources.list.d/kubernetes.list<br>apt update -y<br>apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y<br># Reset Kubernetes pre-flight checks<br>kubeadm reset --force<br># Optionally, if you want to remove the associated files and directories as well, uncomment the following lines:<br># rm -rf /etc/kubernetes/<br># rm -rf /var/lib/kubernetes/<br>echo &quot;Kubernetes pre-flight checks reset.&quot;</pre><p>Once the EC2 instance is created run the below commands:</p><ul><li>Master Node:</li></ul><pre>kubeadm token create --print-join-command</pre><ul><li>Worker Node:</li></ul><p>To edit the inbound rule for port 6443 in the security group associated with your master node.</p><pre>kubeadm join token --v=5</pre><h4>Step 2: Create Namespace:</h4><p>Create a namespace:</p><pre>kubectl create namespace day88</pre><h4>Step 3: Create Deployment Manifest file:</h4><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: todo-deployment<br>  namespace: day88<br>  labels:<br>    app: todo-app<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: todo-app<br>  template:<br>    metadata:<br>      name: todo-deployment<br>      labels:<br>        app: todo-app<br>    spec:<br>      containers:<br>        - name: todo-app<br>          image: trainwithshubham/django-todo:latest<br>          ports:<br>            - containerPort: 8000<br>          imagePullPolicy: IfNotPresent<br>      restartPolicy: Always</pre><p>Since this application uses the MySql databse, so there is the need to create new deployemnet file. Create a new folder, inside it creates a new deployment.yaml:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: mysql<br>  namespace: day88<br>  labels:<br>    app: todo<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: todo<br>  template:<br>    metadata:<br>      labels:<br>        app: todo<br>    spec:<br>      containers:<br>        - name: mysql<br>          image: mysql:8<br>          ports:<br>            - containerPort: 3306<br>          env:<br>            - name: MYSQL_DATABASE<br>              valueFrom:<br>                configMapKeyRef:<br>                  name: mysql-configmap<br>                  key: MYSQL_DB<br>            - name: MYSQL_ROOT_PASSWORD<br>              valueFrom:<br>                secretKeyRef:<br>                  name: mysql-secret<br>                  key: MYSQL_PASSWORD</pre><p>To apply those configurations run the below command:</p><pre>kubectl apply -f deployment.yaml</pre><h4>Step 3: Create Service Manifest:</h4><p>Create a service.yaml:</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: todo-service<br>  namespace: day88<br>spec:<br>  selector:<br>    app: todo-app<br>  ports:<br>    - protocol: TCP<br>      port: 80<br>      targetPort: 8000<br>      nodePort: 30001<br>  type: NodePort</pre><p>Run the command to apply the configuration:</p><pre>kubectl apply -f service.yaml</pre><h4>Step 4: Create ConfigMap and Secrets:</h4><p>For secure MySQL deployment, use ConfigMaps and Secrets. Store passwords in secrets.yaml and non-sensitive data in configMap.yaml. This ensures a clean and secure MySQL configuration in Kubernetes, adhering to best practices for sensitive information management.</p><ul><li><strong>configMap.yaml:</strong></li></ul><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: mysql-configmap<br>  namespace: day88<br>  labels:<br>    app: todo<br>data:<br>  MYSQL_DB: &quot;todo-db&quot;</pre><p>Explanation:</p><ul><li>apiVersion: v1: Specifies the API version of the Kubernetes object. In this case, it&#39;s using the core/v1 API version, which is commonly used for basic resources.</li><li>kind: ConfigMap: Specifies the type of Kubernetes resource being defined, which is a ConfigMap. ConfigMaps are used to store non-confidential data in key-value pairs.</li><li>metadata: Contains metadata about the ConfigMap, such as its name, namespace, and labels.</li><li>name: mysql-configmap: Specifies the name of the ConfigMap as &quot;mysql-configmap&quot;.</li><li>namespace: day88: Specifies the namespace in which the ConfigMap is created, in this case, &quot;day88&quot;.</li><li>labels: Assigns labels to the ConfigMap. In this example, it has an &quot;app: todo&quot; label.</li><li>data: Contains the actual key-value pairs representing the configuration data stored in the ConfigMap.</li><li>MYSQL_DB: &quot;todo-db&quot;: Defines a key-value pair where the key is &quot;MYSQL_DB&quot; and the corresponding value is &quot;todo-db&quot;. This is an example of a configuration parameter, likely representing the name of a MySQL database.</li><li><strong>secret.yaml:</strong></li></ul><pre>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: mysql-secret<br>  namespace: day88<br><br>  labels:<br>    app: todo<br>type: Opaque<br>data:<br>  MYSQL_PASSWORD: dHJhaW53aXRoc2h1YmhhbQ==</pre><p>Explanation:</p><ul><li>apiVersion: v1: Specifies the API version of the Kubernetes object. In this case, it&#39;s using the core/v1 API version.</li><li>kind: Secret: Specifies the type of Kubernetes resource being defined, which is a Secret. Secrets are used to store and manage sensitive information, such as passwords or API keys.</li><li>metadata: Contains metadata about the Secret, such as its name, namespace, and labels.</li><li>name: mysql-secret: Specifies the name of the Secret as &quot;mysql-secret&quot;.</li><li>namespace: day88: Specifies the namespace in which the Secret is created, in this case, &quot;day88&quot;.</li><li>labels: Assigns labels to the Secret. In this example, it has an &quot;app: todo&quot; label.</li><li>type: Opaque: Indicates the type of secret. &quot;Opaque&quot; is a generic type used for arbitrary data.</li><li>data: Contains the actual sensitive data stored in the Secret.</li><li>MYSQL_PASSWORD: dHJhaW53aXRoc2h1YmhhbQ==: Defines a key-value pair where the key is &quot;MYSQL_PASSWORD&quot; and the corresponding value is the base64-encoded representation of the actual MySQL password. The password, in this case, is &quot;test@123&quot;.</li></ul><p>To apply these configurations run the below command:</p><pre>kubectl apply -f configMap.yaml<br>kubectl apply -f secret.yaml</pre><h4>Step 5: Accessing the application:</h4><p>o enable access to the application running on the worker node at port number 30001, update the security group inbound rules for the worker node to allow incoming traffic from any source. Follow these steps:</p><ol><li>Open the AWS Management Console.</li><li>Navigate to EC2.</li><li>In the EC2 Dashboard select the Worker Node, and in which select “Security Groups” under the “Network &amp; Security” section.</li><li>Find and select the security group associated with your worker node.</li><li>In the bottom panel, choose the “Inbound Rules” tab.</li><li>Click “Edit Inbound Rules.”</li><li>Add a new rule to allow incoming traffic on port 30001. Set the source to “Anywhere” (0.0.0.0/0) to allow traffic from any source.</li><li>Save the rules.</li></ol><p>To access your application, open a web browser and navigate to the public IP address of your worker node at port 30001. The application should be running at:</p><pre>http://&lt;worker-node-public-ip&gt;:30001</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Czj7xCZ7Y4qSDyZIoIfPSA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=593e96a387a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automated Deployment of React Application on AWS Elastic Beanstalk with GitHub Actions: A CI/CD…]]></title>
            <link>https://abhiraj2001.medium.com/automated-deployment-of-react-application-on-aws-elastic-beanstalk-with-github-actions-a-ci-cd-4da851b05868?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/4da851b05868</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Sat, 13 Jan 2024 18:13:24 GMT</pubDate>
            <atom:updated>2024-01-13T18:16:57.983Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automated Deployment of React Application on AWS Elastic Beanstalk with GitHub Actions: A CI/CD Pipeline Setup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*XvgOteHTWppDMqeDU9gzqQ.png" /></figure><p>This project is carried out in the Ubuntu 22.04 version machine, so the commands used may vary for your operating system.</p><h4>Step 1: Clone the project:</h4><p>Clone the GitHub repository in your local system.</p><pre>git clone https://github.com/sitchatt/AWS_Elastic_BeanStalk_On_EC2.git<br>cd AWS_Elastic_BeanStalk_On_EC2/</pre><h4>Step 2: Install the Docker and Docker-compose:</h4><p>Run the following commands to install the docker and docker-compose.</p><pre>#Update the system<br>sudo apt-get update<br><br>#Install Docker<br>sudo apt install docker.io<br>#adding the current user in docker group<br>sudo usermod -aG docker $USER<br>#verify the installation<br>docker --version<br>#Install Docker compose<br>sudo apt install docker-compose<br>#verify the installation<br>docker-compose --version</pre><h4>Step 3: Create a multi-stage DockerFile:</h4><p>A multi-stage Dockerfile allows you to create a more efficient and smaller final Docker image by using multiple build stages. This feature is particularly useful when you have complex build requirements or dependencies during the development process but want to produce a minimalistic production image.</p><p><strong>DockerFile for our application:</strong></p><pre>FROM node:14-alpine as builder<br>WORKDIR /app <br>COPY package.json . <br>RUN npm install <br>COPY . . <br>RUN npm run build<br>FROM nginx <br>EXPOSE 80 <br>COPY --from=builder /app/build /usr/share/nginx/html</pre><p><strong>Explanation:</strong></p><ol><li>Build Stage (node:14-alpine):</li></ol><ul><li>FROM node:14-alpine as builder: Sets the base image for the build stage.</li><li>WORKDIR /app: Sets the working directory inside the container to /app.</li><li>COPY package.json .: Copies the package.json file to the working directory.</li><li>RUN npm install: Installs dependencies based on the package.json.</li><li>COPY . .: Copies the rest of the application code into the container.</li><li>RUN npm run build: Builds the application.</li></ul><p>2. Final Stage (nginx):</p><ul><li>FROM nginx: Sets the base image for the final stage.</li><li>EXPOSE 80: Exposes port 80 (standard HTTP port).</li><li>COPY --from=builder /app/build /usr/share/nginx/html: Copies the built artifacts from the build stage into the Nginx image.</li><li>The final stage doesn’t need additional steps since Nginx will serve the static content from /usr/share/nginx/html.</li></ul><p>To build the Docker image run the below command:</p><pre>docker build . -t &lt;tag_your_image&gt;</pre><h4>Step 4: Configure the AWS Elastic Beanstalk:</h4><p>Amazon Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.</p><p>Go to AWS Elastic Beanstalk</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gnXF65xr7PGxTC4mgW0K9Q.png" /></figure><p>Click on Create application.</p><ul><li><strong>Step 1</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YoSYsNPeNEUharpiL7PejA.png" /></figure><p>Choose the Web Environment and Application name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*PGk4HdMxaxprDQUdrQOfkg.png" /></figure><p>Choose the Docker as the platform to run your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CYEvAuOGiqcnZDpelPS1QQ.png" /></figure><p>Select the sample application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sF2cH2NErm2f9sGUuCGlMQ.png" /></figure><p>Choose Single instance, free tier for Presents.</p><ul><li><strong>Step 2</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*jnCaykPluoExRuEVRJXKxQ.png" /></figure><p>Configure the service access. Create a new service role, new service role name, and EC2 pair key.</p><p>Make sure that your IAM role has the following permissions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*7w2kJ8k1pJRcgQu0nmeu9g.png" /></figure><ul><li><strong>Step 3:</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*2rosMp7a2ez7IpHu5z3QOQ.png" /></figure><p>Choose the default vpc i.e. 172.31.0.0/16.</p><p>Instance setting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*V3HQrTPXiEslwdrZqPNbiw.png" /></figure><p>Activate your public ip address and check all the instance subnets.</p><ul><li><strong>Step 4:</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*OlUQbo7V7L8fqMs8cVfUAA.png" /></figure><p>Select the default security group.</p><ul><li><strong>Step 5:</strong></li></ul><p>Click on next or modify the configuration according to you.</p><ul><li><strong>Step 6</strong></li></ul><p>Click on review and submit. It will take 5–15 minutes to create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Sat65g3Miujgr8vFIAKog.png" /></figure><p>After your application has been created it will provide your application domain link from where you can access your application, which would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTtvo1yD3NHLSgwhOfQCFQ.png" /></figure><h4>Step 5: Configure CI/CD pipeline with GitHub Actions</h4><p>Create a new repository in GitHub and upload your web application code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWFVwWFfxNmESl4-DR5KGA.png" /></figure><p>To create CI/CD pipeline in GitHub, click on Actions -&gt; set up a workflow yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PY9aFf69o1bJwUHEj0srQ.png" /></figure><p>Your Main.yml:</p><pre>name: CI/CD for day87<br>on:<br>  push:<br>    branches:<br>      - main<br>jobs:<br>  build-and-deploy:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout Repository<br>        uses: actions/checkout@v1<br>      - name: Configure AWS Credentials<br>        uses: aws-actions/configure-aws-credentials@v1<br>        with:<br>          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>          aws-region: us-east-1<br>      - name: Deploy Static Site to S3 Bucket<br>        run: aws s3 sync . s3://elasticbeanstalk-us-east-1-543991822877 --delete</pre><p>The Elastic Beanstalk will create the S3 Bucket for you, where you can upload your source code and Elastic Beanstalk will deploy your application.</p><p>Now, to create the secrets in GitHub click on Settings of the repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mhWlEM_q7CFYvPYyaYurtg.png" /></figure><p>In Security -&gt; Secrets -&gt; Actions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*BtDMNd2lnrSaDQeKedMhDA.png" /></figure><p>Click on New repository secret to create new secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*vj48fRdjileNAZFT_W_bcQ.png" /></figure><p>Here you will paste your AWS Login credentials i.e. Access Key and Secret, which you can obtain by creating new AWS IAM User.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MzDbN_nJeGTNNrQU84SxOQ.png" /></figure><p>Enter you AWS Access key and Secret key.</p><p>If you have configured the configuration successfully then GitHub actions will deploy your application.</p><p>Your application has been deployed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XSqKkxSB2P3wdpbV7sQeLg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4da851b05868" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD with GitHub Actions: Deploying a Web Application on AWS S3]]></title>
            <link>https://abhiraj2001.medium.com/ci-cd-with-github-actions-deploying-a-web-application-on-aws-s3-dd79d017ade4?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd79d017ade4</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Tue, 09 Jan 2024 17:33:33 GMT</pubDate>
            <atom:updated>2024-01-09T17:46:48.908Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DTfGmYX8NezKgLTVxY5syQ.png" /></figure><h3>GitHub Actions:</h3><p>GitHub Actions serves as a versatile CI/CD tool developed by GitHub, enabling developers to seamlessly perform continuous integration and continuous deployment for their applications. It offers integration capabilities with various third-party platforms such as AWS, Azure, or any cloud infrastructure, facilitating smooth deployment processes on remote servers.</p><h3>Steps to Deploying Web App to AWS S3 using GitHub Actions:</h3><h4>Step 1: Create a GitHub repository.</h4><p>Create a new GitHub public repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9GkcKRos2jNcxj6dE699yQ.png" /></figure><p>Push your code in this repository.</p><h4>Step 2: Create an S3 Bucket:</h4><p>Choose the region and assign the bucket name:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*WUt-5b0y8LKxQXtNPMTr1A.png" /></figure><p>Object ownership: Enabled the ACLs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*laS1J8zxSMutSG9GLrqV1w.png" /></figure><p>Uncheck the blocked public access setting for this bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*ZPmJHvaZ6UKsOYV2mLNUyQ.png" /></figure><p>And click on Create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*_FbhPkhDQb4cyss6NoxpWA.png" /></figure><p>An S3 bucket has been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*INmebQcfoTqaukzWJeuaEQ.png" /></figure><p>Now open that S3 bucket, and open the properties section:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*oS8x0jxqD18LgOdg3bBYQg.png" /></figure><p>Scroll down till you see Static website hoisting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*faoeGwLfanMNBxcxPgVrFg.png" /></figure><p>To enable it click on Edit, which is on the right corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*_FbhPkhDQb4cyss6NoxpWA.png" /></figure><ul><li>Enable the static hosting</li><li>Choose the static host.</li><li>Specify the default home page file, i.e your index.hmtl.</li></ul><p>Click on save changes.</p><p>Configure the bucket policy for public access by navigating to the bucket’s properties, select Permissions, click on Bucket Policy, and add the following policy:</p><pre>{<br> &quot;Version&quot;: &quot;2024–01–08&quot;,<br> &quot;Statement&quot;: [<br> {<br> &quot;Sid&quot;: &quot;PublicReadForGetBucketObjects&quot;,<br> &quot;Effect&quot;: &quot;Allow&quot;,<br> &quot;Principal&quot;: &quot;*&quot;,<br> &quot;Action&quot;: &quot;s3:GetObject&quot;,<br> &quot;Resource&quot;: &quot;arn:aws:s3:::day86/*&quot;<br> }<br> ]<br>}</pre><h4>Step 3: Open GitHub actions:</h4><p>Now open your Git repository, and there open the Actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RnKBLF2O5lMC2Bx9KphmyQ.png" /></figure><p>Now, click on set up a workflow yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WXOaWMjBOjit2Q0EUbH3CQ.png" /></figure><h4>Step 4: Create main.yml:</h4><p>There create a file main.yml, which would be responsible for carrying out CI/CD operations using GitHub Actions.</p><p>Main.yml:</p><pre>name: CI/CD for day86<br><br>on:<br>  push:<br>    branches:<br>      - main<br><br>jobs:<br>  build-and-deploy:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout Repository<br>        uses: actions/checkout@v1<br><br>      - name: Configure AWS Credentials<br>        uses: aws-actions/configure-aws-credentials@v1<br>        with:<br>          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>          aws-region: us-east-1<br><br>      - name: Deploy Static Site to S3 Bucket<br>        run: aws s3 sync . s3://day86 --delete</pre><p><strong>Explanation:</strong></p><ul><li>name: day86: This sets the name of the GitHub Actions workflow to &quot;day86&quot;.</li><li>on: push: branches: - main: This specifies that the workflow should be triggered on every push to the main branch.</li><li>jobs: This section defines one or more jobs that will be executed as part of the workflow.</li><li>build-and-deploy: This is the name of the job, and it is set to run on the latest version of Ubuntu (ubuntu-latest).</li><li>- name: Checkout: This step checks out the source code from the repository using the actions/checkout action. It fetches the code at the commit or branch specified in the triggering push event.</li><li>- name: Configure AWS Credentials: This step uses the aws-actions/configure-aws-credentials action to configure AWS credentials. The AWS access key ID and secret access key are retrieved from GitHub repository secrets (${{ secrets.AWS_ACCESS_KEY_ID }} and ${{ secrets.AWS_SECRET_ACCESS_KEY }}), and the AWS region is set to &quot;us-east-1&quot;.</li><li>- name: Deploy static site to S3 bucket: This step is a custom run step that deploys the static site to the specified S3 bucket. It uses the AWS CLI (aws s3 sync) to synchronize the contents of the current directory (.) with the specified S3 bucket (s3://day86). The --delete flag ensures that any files in the bucket not present in the current directory will be deleted.</li></ul><p>Commit your changes.</p><h4>Step 5: Setting up the AWS Credentials:</h4><p>To use the S3 bucket GitHub actions need AWS credentials, for that create a new IAM User and create Access Key and Secret Key for it.</p><p>We are using credentials through environment variables, for that open the Settings of your GitHub repository, there go to Security -&gt; Secrets and variables -&gt; Actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*n1RjSbGpPe4kY-MTZ74zeg.png" /></figure><p>Click on New repository secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*471TChuJEm8BY45c2yM34g.png" /></figure><p>Create the Access Key, paste the Access Key, and click on Add secret.</p><p>Do the similar for Access Secret.</p><h4>Step 6: Deploying your application:</h4><p>If your configuration is correctly configured then your application has been deployed, marked by a green tick.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6g98lcJaAUqp7g3u-TARdw.png" /></figure><p>Accessing the application:</p><p>Open your S3 bucket -&gt;Permission-&gt;<strong>Static website hosting, copy the URL, and run it in your browser.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*zXQAoBhdT2ynkdY-_hEnOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLWMjrCR5DQzfx_Jgfbddw.png" /></figure><p>Your application has been deployed.</p><p>To experience the CI/CD, go to the GitHub repository commit some changes and refresh your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L0zgFjxm3yUEZLQ4_a3DAg.png" /></figure><p>The moment you commit the changes in the main branch the CI/CD pipeline starts, and your application with changes will be deployed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hqCDbBW3C4Nm74dRBShzQw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd79d017ade4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deployment of Node.js App on AWS ECS Fargate: Leveraging Docker and ECR Integration]]></title>
            <link>https://abhiraj2001.medium.com/deployment-of-node-js-app-on-aws-ecs-fargate-leveraging-docker-and-ecr-integration-c03851f5abc9?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/c03851f5abc9</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Sun, 07 Jan 2024 14:30:42 GMT</pubDate>
            <atom:updated>2024-01-07T17:19:28.544Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*SeP4nfBwltyahJ_GmU44vA.png" /></figure><p>In this hands-on, I created a Docker Image, pushed it to AWS ECR, and using AWS ECS Fargate deployed the application.</p><p>You can clone the application, <a href="https://github.com/LondheShubham153/node-todo-cicd"><em>here</em></a>.</p><h4>Step 1: Clone the application:</h4><p>Clone your application in your local enviournment or AWS EC2 instance.</p><pre>git clone https://github.com/LondheShubham153/node-todo-cicd.git</pre><h4>Step 2: Build the Docker Image:</h4><p>Run the below command to create the Docker Image from Dockerfile:</p><pre>docker build -t day85 .</pre><h4>Step 3: Create an AWS ECR :</h4><p>Open your AWS account and create a public ECR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*eoFNXEz5RqKzMLukcPdwNw.png" /></figure><h4>Step 4: Pushing the Docker Image in ECR:</h4><p>Open the ECR, click on view push commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*SIbjEfwAxhEpWs8KntwOQQ.png" /></figure><p>Copy those commands and run them one by one in your environment terminal, before that make sure that you have installed and configured the AWS CLI.</p><p>As you can see your image has been created and uploaded in your ECR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*CIiPo9O7OJjcnsNcPgBJ7A.png" /></figure><h4>Step 5: Create a Cluster in AWS ECS:</h4><p>Fill the details like: Cluster name, in Infrastructure choose AWS Fargate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*B2eQyHQGSRzGCkUyzBredg.png" /></figure><p>Cluster Day85 has been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*feLZoqDarQjEopwJTSeyyQ.png" /></figure><h4>Step 6: Create a Task Definition:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sii_Q_4cDBZ9pgLCuHD84A.png" /></figure><p>Fill in the Task definition family.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*_cc_4erDzNBOpdVSPmb_EQ.png" /></figure><p>Fill in the Infrastructure Details like Lauch Type, OS architecture, Task size, and Task role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*kjigZLcCcfMxfaxwloXmog.png" /></figure><p>Now fill in the details of the Container like port number, Image URI; ECR link, container name, port name, and resource allocation limits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-Jaq0on94N2z-zp1bMtKQ.png" /></figure><p>Click on Create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*evAL-0Oseu35oLGeVHCEyw.png" /></figure><p>A task definition has been created.</p><h4>Step 7: Run the task, Deploy:</h4><p>Click on Deploy -&gt; Run Task</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IbiMT8DHB4O9fA11Yv5kbQ.png" /></figure><p>Choose the existing cluster, according to which the configuration would be applied. Review those configurations, and change them, if you wish to change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*bpdVH4V_mWXse13-C1UM_Q.png" /></figure><p>Click on Create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vc1N16v0pEHBvXAiKwKWiA.png" /></figure><p>Your task has been launched and it is provising the infrastructure required to run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bg9-CuLhlxV5zK9y5cSqwQ.png" /></figure><p>Here you can see that your task has been provisioned and is running.</p><p>Now open that task copy ip_address, and open it in the browser at port number 5000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5CqkMP634L0PTjdVy_aYw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c03851f5abc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Containerized Cinema: Orchestrating a Netflix Clone with Kubernetes for Scalability and Reliability]]></title>
            <link>https://abhiraj2001.medium.com/containerized-cinema-orchestrating-a-netflix-clone-with-kubernetes-for-scalability-and-reliability-f28a37bf2cfa?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/f28a37bf2cfa</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 13:57:50 GMT</pubDate>
            <atom:updated>2024-01-04T14:07:38.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_A4ug_JFJZBAr5bC8YYcg.png" /></figure><p>In this project, I would be discussing how you can deploy your web application using Kubernetes, showcasing the platform’s capabilities in enhancing the scalability and reliability of your application.</p><p>Here is the GitHub link to the project, <a href="https://github.com/devandres-tech/Netflix-Clone.git"><em>here</em></a>.</p><p>Follow the below steps to deploy this application on Kubernetes.</p><h4>Step 1: Cloning the code:</h4><p>Clone the project in your enviournment:</p><pre>git clone https://github.com/devandres-tech/Netflix-Clone.git</pre><h4>Step 2: Creating DockerFile:</h4><p>DockerFile is used to create a Docker image of your application, which is further used to create a Docker container.</p><p><strong>Dockerfile:</strong></p><pre>FROM node:14-alpine<br><br>WORKDIR /app<br><br>COPY package*.json ./<br><br>RUN npm install<br><br>COPY . .<br><br>RUN npm run dev<br><br>EXPOSE 5000<br><br>CMD [&quot;npm&quot;, &quot;run&quot;, &quot;dev&quot;]</pre><p>To create a Docker image run the below command:</p><pre> docker build -t image_name_you_want_to_keep:version_of_the_image location_of_Dockerfile.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*m1aztEe0i3YkG-MMbEi65g.png" /></figure><p>This command would create a docker image and to view all the docker images in your system use the below command:</p><pre>docker images</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*0jt7NQO0ieNrg-oW2YzSHw.png" /></figure><p>Push this docker image in your Docker Hub account:</p><pre>docker login -u your-username -p your-password<br>docker push image_name</pre><h4>Step 3: Setting up Kubernetes on AWS EC2 instance:</h4><p>To deploy our application on Kubernetes we need to set up a cluster with a minimum of 2 nodes. One node would act as the master node and the other would act as the worker node. Make sure you use minimumt2.medium as the instance type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9XMEyPNEja9AmwiT_Rof-g.png" /></figure><p>Open the terminal and run the following commands:</p><ul><li>Both Master and Worker Node:</li></ul><pre># using &#39;sudo su&#39; is not a good practice.<br>sudo apt update<br>sudo apt-get install -y apt-transport-https ca-certificates curl<br>sudo apt install docker.io -y<br><br>sudo systemctl enable --now docker # enable and start in single command.<br><br># Adding GPG keys.<br>curl -fsSL &quot;https://packages.cloud.google.com/apt/doc/apt-key.gpg&quot; | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/kubernetes-archive-keyring.gpg<br><br># Add the repository to the sourcelist.<br>echo &#39;deb https://packages.cloud.google.com/apt kubernetes-xenial main&#39; | sudo tee /etc/apt/sources.list.d/kubernetes.list<br><br>sudo apt update <br>sudo apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y</pre><ul><li>Initialize the Kubernetes master node, in the master node:</li></ul><pre># Become the root user to initialize the master node<br>kubeadm init</pre><ul><li>Edit the inbound rules of the Master Node, and add port 6443 :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z7Y0_jHawbPG36CbLumKWQ.png" /></figure><ul><li>Set up local kubeconfig (both for root user and normal user), In Master Node:</li></ul><pre>mkdir -p $HOME/.kube<br>sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config<br>sudo chown $(id -u):$(id -g) $HOME/.kube/config</pre><ul><li>Apply Weave network, In Master Node:</li></ul><pre>kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml</pre><ul><li>Generate a token for worker nodes to join, In Master Node:</li></ul><pre>sudo kubeadm token create --print-join-command</pre><p><strong>Run the following commands on the worker node:</strong></p><pre>sudo kubeadm reset pre-flight checks</pre><p>Paste the join command you got from the master node and append --v=5 at the end. <em>Make sure either you are working as a sudo user or use </em><em>sudo before the command</em></p><pre>sudo kubeadm join 172.31.59.178:6443 --token atr1bb.elr5xlvdfbh7iugw     --discovery-token-ca-cert-hash sha256:583b24d4a81453b38f61ed399c2765f7614d782a91d4addc591e7c65a5cbc5c --v=58</pre><h4>Verify Cluster Connection</h4><p><strong>On master node:</strong></p><pre>kubectl get nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*JHETJ10LM9k_PJNjr-doEw.png" /></figure><h4>Step 4: Creating namespace in K8s:</h4><p>First, create a namespace in the K8s cluster by running the below command on the master node:</p><pre>kubectl create namespace day84</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*KhhwG1AIRgAon61nTATEqA.png" /></figure><p>Use the command to view all the namespace in your cluster:</p><pre>kubectl get namspaces</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*9cklTfhqX1npEh8LPgjJVw.png" /></figure><h4>Step 5: Creating Manifest files:</h4><p>In K8s, we have to write the manifest or the configuration file in YAML format to deploy the application.</p><ul><li><strong>Create Deployment manifest:</strong></li></ul><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: day84-deployment<br>  namespace: day84<br>  labels:<br>    app: day84<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: day84<br>  template:<br>    metadata:<br>      labels:<br>        app: day84<br>    spec:<br>      containers:<br>      - name: day84-container<br>        image: 2001abhiraj/devops_2023:latest<br>        ports:<br>        - containerPort: 8080</pre><p>Command to apply:</p><pre>kubectl apply -f deployment.yaml </pre><p>Command to see the deployments in a particular namespace:</p><pre>kubectl get deployment -n &lt;namespace&gt;</pre><ul><li>Create Service manifest:</li></ul><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: day84-service<br>  namespace: day84<br>spec:<br>  selector:<br>    app: day84<br>  ports:<br>  - protocol: TCP<br>    port: 8080<br>    targetPort: 8080<br>    nodePort: 30001<br>  type: NodePort</pre><p>Command to apply:</p><pre>kubectl apply -f service.yaml</pre><p>Command to see the services in a particular namespace:</p><pre>kubectl get svc-n &lt;namespace&gt;</pre><h4>Step 6: Execessing your application:</h4><p>Your application is running at port number 30001, at your worker node, so you need to change inbound rules and add port number 30001.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JOz9viR41zReRnNigbW_mg.png" /></figure><p>Run the curl command to check whether the application is running or not:</p><pre>curl -L http://&lt;ip_of_instance:30001&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*IUEdY2W47Bz3kaCHbwiDBg.png" /></figure><p>Now open your browser and run this link</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qexaAjcd6_yTVV3KXtk0Gw.png" /></figure><p>As you can see, your application is running.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f28a37bf2cfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Container Orchestration: Deploying a Web Application with Docker Swarm]]></title>
            <link>https://abhiraj2001.medium.com/container-orchestration-deploying-a-web-application-with-docker-swarm-a364af438ebb?source=rss-7117868d7c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/a364af438ebb</guid>
            <dc:creator><![CDATA[Abhiraj Thakur]]></dc:creator>
            <pubDate>Mon, 01 Jan 2024 09:25:43 GMT</pubDate>
            <atom:updated>2024-01-01T10:14:18.172Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DPkkHyoBRxybxJGkweAcbw.png" /></figure><p>In this blog post, I will delve into the concept of Docker Swarm, guiding you through its definition, the installation process, and the steps to deploy your applications seamlessly using Docker Swarm.</p><h3>What is Docker Swarm?</h3><p>Docker Swarm serves as the orchestration tool for efficiently managing Docker applications. It enables the seamless deployment of applications within Docker and facilitates easy scaling of your application infrastructure.<br>For more details refer to this blog <a href="https://www.simplilearn.com/tutorials/docker-tutorial/docker-swarm#:~:text=Docker%20Swarm%20is%20an%20orchestration,interact%20using%20the%20Docker%20API."><em>here</em></a>.</p><h3>Installation of Docker Swarm:</h3><ol><li>Create the 3 AWS instances with the following name:<br>Swarm master<br>Swarm worker-1<br>Swarm worker-2</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJB1R_hXZrQIS-YQakZ92w.png" /></figure><p>2. In all three instances, inside the inbound rules, allow</p><p>· Custom TCP — 2377 — Anywhere IPv4</p><p>· Custom TCP — 8001 — Anywhere IPv4</p><p>3. Install the Docker in all the 3 instances:</p><pre>sudo apt-get update<br>sudo apt-get install docker.io</pre><p>4. Open your Swarm master node’s terminal and run the command:</p><pre>sudo docker swarm init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eNlMjJ8wyx2Be67P8UH9XA.png" /></figure><p>Copy the Docker command the run this command in your worker nodes to connect with the master node.</p><p>5. Run this command in your Worker instances:</p><pre>sudo docker swarm join --token &lt;SWARM_TOKEN&gt; &lt;MASTER_IP&gt;:2377</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*grg9fMP2PX3XpHfVU3nlxg.png" /><figcaption>Swarm worker 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IUnXKDGHnD8O9g-nJFnbAg.png" /><figcaption>Swarm worker 2</figcaption></figure><p>6. To check about all the nodes in the manager, run:</p><pre>docker swarm node ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kzR5XALl4ms_O_fhkSkIw.png" /></figure><h3>Running Mern-Django Application using Docker Swarm:</h3><p>1. Here is the docker image of the react-django-based application, which you want to run using Docker swarm. To do that there is the need to create a docker service:</p><pre>sudo docker service create --name django-app-service --replicas 3 --publish 8001:8001 trainwithshubham/react-django-app:latest</pre><ul><li>--name django-app-service: This specifies the name of the Docker service, in this case, &quot;django-app-service&quot;.</li><li>--replicas 3: This sets the number of replicas for the service to 3. It means that Docker Swarm will create and maintain three instances of the specified container.</li><li>--publish 8001:8001: This maps port 8001 on the host to port 8001 in the service container. It allows external access to the service on the host machine.</li><li>trainwithshubham/react-django-app:latest: This is the Docker image used to create the service. It&#39;s a containerized application based on the &quot;trainwithshubham/react-django-app&quot; image with the &quot;latest&quot; tag.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_oNRjkaWun8HP5mMbBHcA.png" /></figure><p>2. To see the docker services, run the below command:</p><pre>sudo docker service ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vE8TqMizb1yEHSEK9Af7HQ.png" /></figure><p>3. Now, this service will create a container in the Manager node. To check, run the command:</p><pre>sudo docker ps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JgIZ0BYOVEhlQuZsx8aKFg.png" /></figure><p>4. Now, this service will be running on all three nodes. To check this, just grab the Ip Address of any of the nodes followed by port 8001. As &lt;Any_ip_of_3_vms&gt;:8001</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lFjOLHIkPgBuzsmKvhq8BA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5iKUgpvE0PlvsgPnoLCaQ.png" /></figure><h3>Removing the worker node:</h3><ol><li>If you want to remove any node from the environment, just run:</li></ol><pre>sudo docker swarm leave</pre><p>From specific worker nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*ABNsQ7FdIMxQIJ8D5r4bRg.png" /></figure><p>As we removed, one of the workers and inside the status, we can see it’s down.</p><pre>sudo docker nodes ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nEDCHOvX93mjc6MTvF9_5g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a364af438ebb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>