<?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 Aakash Deep on Medium]]></title>
        <description><![CDATA[Stories by Aakash Deep on Medium]]></description>
        <link>https://medium.com/@akashdeep960?source=rss-dc6a9d3b40f8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nVyrr4rLQne01cbPI3NCvg.png</url>
            <title>Stories by Aakash Deep on Medium</title>
            <link>https://medium.com/@akashdeep960?source=rss-dc6a9d3b40f8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 15:26:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akashdeep960/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[Designing a Serverless Support Workflow with AWS Step Functions]]></title>
            <link>https://medium.com/@akashdeep960/designing-a-serverless-support-workflow-with-aws-step-functions-5864590c2539?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5864590c2539</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[workflow]]></category>
            <category><![CDATA[call-center]]></category>
            <category><![CDATA[aws-step-functions]]></category>
            <category><![CDATA[iam-roles]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 17:08:50 GMT</pubDate>
            <atom:updated>2026-01-29T17:08:50.656Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In real-world systems, the hardest part is not writing code — <br>The real challenge is managing the workflow.</p><p>When I first started designing a call center–style application, I believed that writing a few AWS Lambda functions would be enough. Each function worked correctly on its own, but when I tried to connect them into a complete process, several problems started to appear.</p><p>That is when I realized the importance of <strong>workflow orchestration</strong>.</p><h4>The Problem: Life Without Step Functions</h4><p>A typical call center workflow looks like this:</p><ul><li>A customer raises a case</li><li>An agent works on the case</li><li>The system checks whether the issue is resolved</li><li>If not resolved, the case is escalated</li><li>The agent works on the case again</li></ul><p>Without AWS Step Functions, handling this flow became difficult.</p><h4>Real-Time Call Center Scenario (Before Step Functions)</h4><p>In a real call center environment, multiple teams are involved.<br>Without proper orchestration:</p><ul><li>Each step depended on manual triggers or custom logic</li><li>Escalation rules were scattered across different services</li><li>A failure in one step could break the entire workflow</li></ul><p>This was similar to running a call center <strong>without a supervisor</strong> — <br>Everyone was working, but there was no clear coordination.</p><h4>The Solution: Introducing AWS Step Functions</h4><p>To solve these issues, I introduced <strong>AWS Step Functions</strong> to orchestrate the entire process.</p><p>Step Functions allowed me to define the workflow visually and logically, making the system easier to understand and maintain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*PEQHhNswZcbzU1b-SK7v-w.png" /></figure><h4>What Step Functions solved:</h4><ul><li>Clear visualization of the entire workflow</li><li>Centralized state management using JSON</li><li>Built-in error handling and retry mechanisms</li><li>Clean and controlled looping logic</li><li>A single source of truth for the business process</li></ul><h4>Project Implementation: Building the Workflow Using AWS Console</h4><p>After understanding the problem and deciding to use AWS Step Functions, I started implementing the solution directly from the <strong>AWS Management Console</strong>. I focused on keeping the design simple and closely aligned with a real-world call center workflow.</p><h3>STEP 1: Creating the Lambda Functions</h3><p>I started by creating individual AWS Lambda functions, each representing a single responsibility in the call center workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1oRbECyGmbDCgZTbOq-U5A.png" /></figure><p><strong>Using the AWS Console:</strong></p><ul><li>Navigated to <strong>AWS Lambda → Create function</strong></li><li>Selected <strong>Author from scratch</strong></li><li>Choose <strong>Node.js 24.x</strong> as the runtime</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*2inf0oTf_OGoLrgOcLmoTA.png" /></figure><p>Each Lambda returns a simple JSON response so that AWS Step Functions can easily pass state between steps.</p><p><strong>1.1 Case Intake Lambda (OpenCaseFunction)</strong><br>It opens a new support case and initializes the case details.</p><pre>export const handler = async (event) =&gt; {<br>  return {<br>    caseId: event?.caseId || &quot;CASE-001&quot;,<br>    status: &quot;OPEN&quot;,<br>    message: &quot;Support case opened&quot;<br>  };<br>};</pre><p>After writing the code, I clicked <strong>Deploy</strong> in the AWS Lambda console to save and activate the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*CTXEIWqeycvNXcCdclhdZA.jpeg" /></figure><p>Once deployed, I moved to the <strong>Test</strong> tab in the Lambda console to verify the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*YYXGL8eRaKO-0Y-lUiPuGA.jpeg" /></figure><p><strong>1.2 Assign Case Lambda (AssignCaseFunction)</strong><br>It updates the case status to <strong>ASSIGNED</strong>.</p><pre>export const handler = async (event) =&gt; {<br>  return {<br>    caseId: event.caseId,<br>    status: &quot;ASSIGNED&quot;,<br>    assignedTo: &quot;SupportAgent-1&quot;,<br>    message: &quot;Case assigned to support agent&quot;<br>  };<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*iRl1P9We-nbf9dehqsje4A.jpeg" /></figure><p><strong>1.3 Work On Case Lambda (WorkOnCaseFunction)</strong></p><p>In this implementation, the case resolution is determined using a random condition to simulate real-world uncertainty.</p><p>In a real-time system, this value would be based on actual resolution checks, such as customer confirmation or system validation.</p><pre>export const handler = async (event) =&gt; {<br>  const isResolved = Math.random() &gt; 0.6;<br><br>  return {<br>    caseId: event.caseId,<br>    status: isResolved ? &quot;RESOLVED&quot; : &quot;ESCALATED&quot;,<br>    resolved: isResolved,<br>    message: isResolved<br>      ? &quot;Case resolved successfully&quot;<br>      : &quot;Case escalated to higher support&quot;<br>  };<br>};</pre><ul><li>If resolved = true → <strong>Close Case</strong></li><li>If resolved = false → <strong>Escalate Case</strong></li></ul><p><strong>1.4 Close Case Lambda (CloseCaseFunction)</strong></p><p>This Lambda function closes the support case once it has been resolved. It marks the case status as <strong>CLOSED</strong>.</p><pre>export const handler = async (event) =&gt; {<br>  return {<br>    caseId: event.caseId,<br>    status: &quot;CLOSED&quot;,<br>    message: &quot;Support case closed successfully&quot;<br>  };<br>};</pre><p><strong>1.5 Escalate Case Lambda (EscalateCaseFunction)</strong></p><p>This function escalates the unresolved case to a higher support tier.<br>After escalation, the workflow loops back to <strong>Work On Case</strong>.</p><pre>export const handler = async (event) =&gt; {<br>  return {<br>    caseId: event.caseId,<br>    status: &quot;ESCALATED&quot;,<br>    escalatedTo: &quot;Tier-2 Support&quot;,<br>    message: &quot;Case escalated to higher support tier&quot;<br>  };<br>};</pre><p>➡ Enables controlled looping until the case is resolved</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*ImBSXpN63gJn2eWIh2UaDg.jpeg" /></figure><h3><strong>STEP 2: Creating an IAM Role</strong></h3><p>Before creating the Step Functions state machine, I needed an IAM role that allows Step Functions to invoke the Lambda functions securely.<br>In AWS, Step Functions cannot call Lambda functions directly unless the required permissions are explicitly granted through an IAM role.</p><h4>Steps followed:</h4><p><strong>Navigated to IAM → Roles → Create role</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*kbWUxkmYnT9yaL7YawUfgQ.jpeg" /></figure><p>Choose Step Functions as the service</p><ul><li><strong>Role name:</strong> basic_functions_execution <em>(customized the permission policies based on the project requirements)</em></li><li>Reviewed the permissions and trust policy. Created the role successfully</li></ul><p>This IAM role is later attached to the Step Functions state machine during creation.</p><h3>STEP 3: Creating the Step Functions State Machine in the AWS Console</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*V7CbEe4PyzSmdqYM7NBrlQ.jpeg" /></figure><p>Before building the state machine, it’s important to understand what AWS Step Functions actually solves in this project.<br>In a real-world call center system, the challenge is not executing individual tasks — It is coordinating them in the correct order, handling failures, and managing retries and loops.<br>AWS Step Functions help by:</p><ul><li>Orchestrating multiple Lambda functions into a single workflow</li><li>Maintaining execution state between steps</li><li>Handling conditional logic using Choice states</li><li>Supporting loops for escalation scenarios</li><li>Providing a visual execution graph for debugging and monitoring</li></ul><p>In this project, Step Functions act as the supervisor of the call center, deciding what happens next based on the outcome of each step.</p><h4>Steps followed:</h4><p>Navigated to AWS Step Functions → State machines → Create state machine<br>Create from blank</p><ul><li><strong>State machine name</strong>: CallCenterDeptMachine</li><li><strong>State machine type: </strong>Standard</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*_WRK8OkUc9EUE56yUFuF_Q.jpeg" /></figure><p>AWS Step Functions allows workflows to be created either using the <strong>visual drag-and-drop editor</strong> (as shown in the image below)or by defining the workflow using <strong>code (ASL)</strong>.<br>In this project, both options were available, with the code-based approach providing greater flexibility and maintainability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*91RaIsRSDTLmzDRCB7NmiQ.png" /></figure><blockquote>Switch to the <strong>Code</strong> tab and paste the definition below. Replace each <strong>ARN</strong> value with the corresponding ARN of your Lambda functions. This will automatically create the complete workflow without requiring any manual configuration.</blockquote><pre>{<br>  &quot;Comment&quot;: &quot;Call Center Workflow with Loop and Retry&quot;,<br>  &quot;StartAt&quot;: &quot;Open Case&quot;,<br>  &quot;States&quot;: {<br>    &quot;Open Case&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;OpenCaseFunction ARN&quot;,<br>      &quot;Next&quot;: &quot;Assign Case&quot;,<br>      &quot;Retry&quot;: [<br>        {<br>          &quot;ErrorEquals&quot;: [&quot;States.ALL&quot;],<br>          &quot;IntervalSeconds&quot;: 2,<br>          &quot;MaxAttempts&quot;: 2,<br>          &quot;BackoffRate&quot;: 2<br>        }<br>      ]<br>    },<br>    &quot;Assign Case&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;AssignCaseFunction ARN&quot;,<br>      &quot;Next&quot;: &quot;Work On Case&quot;<br>    },<br>    &quot;Work On Case&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;WorkOnCaseFunction ARN&quot;,<br>      &quot;Next&quot;: &quot;IsResolved&quot;<br>    },<br>    &quot;IsResolved&quot;: {<br>      &quot;Type&quot;: &quot;Choice&quot;,<br>      &quot;Choices&quot;: [<br>        {<br>          &quot;Variable&quot;: &quot;$.resolved&quot;,<br>          &quot;BooleanEquals&quot;: true,<br>          &quot;Next&quot;: &quot;Close Case&quot;<br>        }<br>      ],<br>      &quot;Default&quot;: &quot;Escalate Case&quot;<br>    },<br>    &quot;Escalate Case&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;EscalateCaseFunction ARN&quot;,<br>      &quot;Next&quot;: &quot;Work On Case&quot;<br>    },<br>    &quot;Close Case&quot;: {<br>      &quot;Type&quot;: &quot;Task&quot;,<br>      &quot;Resource&quot;: &quot;CloseCaseFunction ARN&quot;,<br>      &quot;End&quot;: true<br>    }<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*mnSoRfIrotAm5jaRLqYA8w.jpeg" /></figure><p><strong>Attach the IAM Role</strong><br>Select the IAM role created in <strong>Step 2</strong> and attach it to the state machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*kNDgeCrdZhpGovBVnpTdig.jpeg" /></figure><p><strong>Click on Create.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*ee3O5accKMTCcDNfiIXKxg.png" /></figure><h3>STEP 4: Executing and Verifying the Workflow (Final Validation)</h3><p>At this stage, we expect the workflow to follow the complete call-center lifecycle — opening a case, assigning it, working on it, escalating when unresolved, and finally closing it once resolved.<br>To verify this, we start a new execution and observe the state transitions and execution graph to ensure the loop and decision logic behave as intended.</p><h4>Steps followed:</h4><p>Click on <strong>New execution</strong><br>Provide the input, for example:</p><pre>{<br>  &quot;caseId&quot;: &quot;12345&quot;<br>}</pre><p>Click <strong>Start.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*7kiMsOxrGbVL3iR9TtiNcQ.png" /></figure><h4>Execution Path 1: Case Resolved Without Escalation</h4><p>When the workflow is executed, it first triggers the <strong>OpenCaseFunction</strong>, which creates a new support case and initializes the case details.<br>Next, the <strong>AssignCaseFunction</strong> assigns the case to a support agent and prepares it for processing.</p><p>The workflow then moves to the <strong>WorkOnCaseFunction</strong>, where the case is evaluated.<br>If the case is resolved (resolved = true), the state machine directly transitions to the <strong>CloseCaseFunction</strong>, marking the case as closed and ending the workflow successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*Sk3fWGJwbRd2tKUMsjyZlw.png" /></figure><h4>Execution Path 2: Case Escalation with Controlled Loop</h4><p>If the case is <strong>not resolved</strong> in the <strong>WorkOnCaseFunction</strong> (resolved = false) The workflow does not terminate.<br>Instead, the <strong>IsResolved</strong> choice state routes the execution to the <strong>EscalateCaseFunction</strong>, where the case is escalated to a higher support tier.</p><p>After escalation, the workflow loops back to the <strong>WorkOnCaseFunction</strong>, allowing the case to be re-evaluated.<br>This loop continues until the case is eventually resolved, after which the workflow transitions to <strong>CloseCaseFunction</strong> and ends successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*AsHVJNq1-yvbwMkOszJIJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*K4UD-IUe7Q3R2AamRW8W3g.jpeg" /></figure><p>If all functions show <strong>successful execution</strong> and produce the expected outputs, congratulations — you have successfully implemented a <strong>real-time call center workflow</strong> using AWS Step Functions.</p><h3>STEP 5: Cleaning Up Resources</h3><p>After completing the workflow and verifying its execution, it’s a good practice to <strong>clean up resources</strong> to avoid unnecessary costs.</p><ul><li><strong>Delete the State Machine</strong></li><li><strong>Remove Lambda Functions</strong></li><li><strong>Delete IAM Role (Optional)</strong></li></ul><p>Cleaning up ensures your AWS account stays tidy and avoids ongoing charges for idle resources.</p><h3>Project Links &amp; Connect With Me</h3><ul><li><strong>GitHub Repository:</strong><br>👉 <a href="https://github.com/AAKASHDEEP786/step-functions-workflow.git">https://github.com/AAKASHDEEP786/step-functions-workflow.git</a></li><li><strong>LinkedIn Profile:</strong><br>👉 <a href="https://www.linkedin.com/in/aakash-deep-v16">https://www.linkedin.com/in/aakash-deep-v16</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5864590c2539" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project: Refactoring Java Web Application Stack on AWS]]></title>
            <link>https://medium.com/@akashdeep960/project-refactoring-java-web-application-stack-on-aws-01d78949bb40?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/01d78949bb40</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[java-applications]]></category>
            <category><![CDATA[elastic-beanstalk]]></category>
            <category><![CDATA[memcached]]></category>
            <category><![CDATA[rabbitmq]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 08:54:07 GMT</pubDate>
            <atom:updated>2026-01-21T11:48:50.354Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Modern applications need to be <strong>scalable, reliable, and easy to manage</strong>.<br>Traditional deployment methods work, but they require heavy manual effort and constant maintenance.</p><p>In this project, I refactored a Java web application by leveraging <strong>AWS managed services</strong> and <strong>DevOps practices</strong>.<br>The goal is to reduce operational complexity and build a setup where the infrastructure supports the application automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*khnndouDG2XUFRAM20I-_A.png" /><figcaption>On Premises Web Application</figcaption></figure><h4>The Problem: High Operational Overhead</h4><p>Traditional application deployments create multiple challenges:</p><ul><li>Manual server and software management</li><li>Separate effort for scaling, monitoring, and patching</li><li>Difficult automation as the system grows</li><li>Teams spend more time on operations than development</li></ul><p>This approach slows down delivery and increases the chance of errors.</p><h4>The Solution: Using AWS Managed Services</h4><p>To solve these problems, this project moves away from manual infrastructure management and adopts <strong>AWS managed services</strong>.</p><h4>Key benefits of this approach:</h4><ul><li><strong>Less Manual Work</strong> — AWS manages servers, patching, and backups</li><li><strong>Easy Scalability</strong> — Services scale automatically based on demand</li><li><strong>Cost Efficiency</strong> — Pay only for what is used</li><li><strong>Improved Reliability</strong> — Built-in monitoring and health checks</li></ul><p>This allows teams to focus more on the application rather than infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6j_m9xLcytolfPwAMfJbA.jpeg" /><figcaption>Cloud Architecture</figcaption></figure><h4>Strategy: What Was Refactored</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p_yenxxBKuZUdGpACNILog.png" /></figure><h3>Execution Overview</h3><p>The project is executed in a structured manner using the following phases:</p><ol><li><strong>Security Setup</strong><br>Create key pairs and security groups to define secure access and communication rules.</li><li><strong>Database Layer Setup (Amazon RDS)</strong><br>Provision a managed MySQL database and configure networking and security.</li><li><strong>Caching Layer Setup (Amazon ElastiCache)</strong><br>Set up an in-memory caching service to improve application performance.</li><li><strong>Message Broker Setup (Amazon MQ)</strong><br>Configure a managed message broker for asynchronous communication.</li><li><strong>Database Initialization</strong><br>Populate the database schema using a temporary EC2 instance.</li><li><strong>Application Environment Setup (AWS Elastic Beanstalk)</strong><br>Create a managed application environment with auto scaling and load balancing.</li><li><strong>Connectivity &amp; Configuration</strong><br>Establish secure communication between the application and backend services.</li><li><strong>Build &amp; Application Deployment</strong><br>Build the application artifact and deploy it to Elastic Beanstalk.</li><li><strong>Global Content Delivery (Amazon CloudFront)</strong><br>Configure CloudFront to improve performance and deliver content globally.</li></ol><h3>Phase 1: Laying the Security Foundation</h3><p>Before deploying any application or backend services, it is important to build a <strong>secure foundation</strong>.<br>In this phase, the focus is on defining <strong>access rules</strong> and <strong>secure communication</strong> between services.</p><h4>What is done in this phase</h4><ul><li>Create a <strong>Backend Security Group</strong> to control traffic between backend services.</li><li>Configure rules so backend components can communicate <strong>internally</strong>, but remain <strong>protected from public access</strong>.</li><li>Create a <strong>Key Pair</strong> to allow secure SSH access for troubleshooting, if required later.</li></ul><h4>Step 1: Login to AWS Console</h4><ul><li>Login to AWS Management Console</li><li>Select region <strong>us-east-1 (N. Virginia)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GShSDxfJcgNEwVoXoId6lA.jpeg" /></figure><h4>Step 2: Create Backend Security Group</h4><ul><li>Go to <strong>EC2 → Security Groups</strong></li><li>Click <strong>Create security group</strong></li><li><strong>Name</strong>: vprofile-rearch-backend-sg</li><li><strong>Description</strong>: Backend services security group</li><li><strong>VPC</strong>: Default VPC</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*7uxtNvjqWR5Z4epSSSpsSA.jpeg" /></figure><h4>Step 3: Configure Inbound Rules</h4><ul><li>Open the newly created security group (vprofile-rearch-backend-sg)</li><li>Go to <strong>Inbound rules → Edit inbound rules</strong></li></ul><p><strong>Add rule:</strong></p><ul><li><strong>Type</strong>: All Traffic</li><li><strong>Source</strong>: Self (same security group)</li><li><strong>Description: </strong>All all traffic internally</li></ul><p><strong>Note</strong>: We do this “self-referencing” so that any service (like RDS or ElastiCache) assigned to this group can communicate freely with any other service in the same group securely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHqHNP4tJHr9dFfzdA1Jlw.jpeg" /></figure><h4>Step 4: Create Login Key Pair</h4><ul><li>Go to <strong>EC2 → Key Pairs</strong></li><li>Click <strong>Create key pair</strong></li><li><strong>Name:</strong> vprofile-rearch-key</li><li><strong>Key pair type:</strong> RSA</li><li><strong>File format</strong>: .pem</li><li>Download and store securely</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*58m5eT1acsUZ3e54P4BdpA.png" /></figure><h4>Phase 1 Outcome</h4><p>By the end of this phase, the security foundation is fully in place.<br>The backend environment is isolated from public access, with clearly defined boundaries inside the VPC.<br>All backend services are now able to communicate securely within the same security group.</p><p>A login key pair is also created, which allows secure access to the instances only when troubleshooting is required.<br>This ensures that access remains controlled and is used only when necessary.</p><h3>Phase 2: Database Layer Setup (Amazon RDS)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TD5RNSphgqVzGeGzUhOIDQ.png" /></figure><h4>Why Amazon RDS is Used</h4><p>In a traditional setup, databases are installed and managed manually on EC2 instances. This requires handling backups, patching, monitoring, and availability by ourselves.</p><p>To avoid this operational burden, I use <strong>Amazon RDS</strong>. It is a managed database service where AWS takes care of:</p><ul><li>Database backups</li><li>Software patching</li><li>Health monitoring</li><li>Infrastructure maintenance</li></ul><p>This allows the team to focus on application development instead of database administration.</p><h4>Step 1: Creating a Parameter Group</h4><p>Before creating the database, I first configure a <strong>parameter group</strong>.</p><p><strong>Why this is needed:</strong><br>In RDS, we do not get direct access to the database server. Any database-level configuration changes must be applied through a parameter group.<br>Creating a custom parameter group gives flexibility to adjust database settings later without rebuilding the database.</p><p><strong>What I do:</strong></p><ul><li>Go to <strong>RDS → Parameter groups</strong></li><li><strong>Group name</strong>: vprofile-rds-rearch-paragrp</li><li><strong>Description</strong>: Custom MySQL parameter group</li><li><strong>Engine type: </strong>MySQL Community</li><li><strong>Parameter group family: </strong>mysql8.0</li><li><strong>Type: </strong>DB Parameter Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqbQLoAentqnaOjP6dpcSw.jpeg" /></figure><h4><strong>Step 2: Creating a DB Subnet Group</strong></h4><p>Next, I set up a <strong>DB subnet group</strong>.</p><p><strong>Why this is needed:</strong><br>A subnet group defines <strong>where the database will live inside the VPC</strong>.<br>It ensures that the database runs in private subnets and supports availability across multiple zones if needed in the future.</p><p><strong>What I do:</strong></p><ul><li>Go to <strong>RDS → Subnet groups</strong></li><li>Click <strong>Create DB subnet group</strong></li><li><strong>Name</strong>: vprofile-rds-rearch-subgrp</li><li><strong>Description</strong>: Subnet group for vprofile RDS</li><li><strong>VPC</strong>: Default VPC</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LClGtO2Mk8kzDN4LoqHaiQ.png" /></figure><ul><li><strong>Add Subnets</strong>:<br><strong> </strong>Select <strong>ALL Private subnet</strong> available in <strong>3 different AZ</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QN893oXX8YeLpIPq9DdEIQ.jpeg" /></figure><h4>Step 3: Creating the RDS Database Instance</h4><p>Once the supporting components are ready, I create the actual database.</p><p><strong>Why this order matters:</strong><br>Parameter group and subnet group must exist before launching the database so they can be attached during creation.</p><p><strong>Key settings configured:</strong></p><p><strong>AWS Console → RDS</strong></p><ol><li><strong>Database creation method</strong>: Full configuration</li></ol><ul><li><strong>Engine type:</strong> MySQL</li><li><strong>Edition:</strong> MySQL Community</li><li><strong>Engine version:</strong> MySQL 8.0.43</li><li>Disable<strong> RDS Extended Support</strong> → <strong>UNSELECT</strong> (paid)</li></ul><p>Extended Support is unchecked to keep the setup cost-effective and within the free/learning scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o-0WPccpJRrUBJABp6HB2Q.png" /></figure><p>2. <strong>Templates</strong>: Free tier</p><p>3. <strong>Availability &amp; durability (MOST IMPORTANT)</strong></p><ul><li>Single-AZ DB instance deployment (1 instance)</li></ul><p>Single-AZ deployment is chosen to reduce cost and complexity, since this is a non-production setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zyxNWVO1Zm1Vg9YNReDN8Q.png" /></figure><p>4. Settings</p><ul><li><strong>DB instance identifier:</strong> vprofile-rds-rearch</li><li><strong>Master username:</strong> admin</li><li><strong>Credentials: </strong><em>Self managed</em> (Auto generate password)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m2XKF13eMhlYOnev6zsZYQ.jpeg" /></figure><p>5. Instance configuration</p><ul><li><strong>DB instance class:</strong> db.t4g.micro</li></ul><p>6. Storage</p><ul><li><strong>Storage type:</strong> General Purpose SSD (gp2)</li><li><strong>Allocated storage:</strong> 20 GiB</li><li><strong>Storage autoscaling: </strong>Off</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ild9NArmD-CmRBdwt16m5Q.jpeg" /></figure><p>7. Connectivity (IMPORTANT FOR PROJECT)</p><ul><li><strong>Compute resource</strong>: Don’t connect to an EC2 compute resource</li><li><strong>VPC:</strong> project-vpc</li><li><strong>DB subnet group:</strong> vprofile-rds-rearch-subgrp</li><li><strong>Public access:</strong> No</li><li><strong>Security Group: </strong>Choose existing (vprofile-rearch-backend-sg)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CpJUAfprpW0q3oERxOs1Bw.jpeg" /></figure><p>8. Database options:</p><ul><li><strong>Initial database name: </strong>accounts (Note: The VProfile app specifically looks for a database named “accounts”).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rmw8TkwSnnPs-Z7ZETyeA.jpeg" /></figure><p>⚠️<strong>Crucial Action: Save Your Credentials! </strong><br>Once you click Create Database, a banner will appear with your generated <br>password. <br>Important: Copy this password and the username (admin) <br>immediately and save them in a safe place (like a sticky note or <br>password manager). You will need these later to connect the <br>application to the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gcxa3t7PyFHkWSgdLik0Fg.png" /></figure><h4>Phase 2 Outcome</h4><p>By the end of this phase, the database layer is successfully set up using <strong>Amazon RDS</strong>.<br>The database is securely deployed within the VPC and is accessible only to backend services through defined security groups.</p><p>Database operations such as backups, patching, and monitoring are now handled by AWS, significantly reducing manual maintenance effort.<br>This creates a reliable and scalable database foundation, ready to support the application in the upcoming phases.</p><h3>Phase 3: Setting Up the Caching Layer (Amazon ElastiCache)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lt8heTMtMRwz_js99ru6Gg.png" /></figure><h4>Why We Are Using ElastiCache</h4><p>In a traditional setup, application caching is handled by installing <strong>Memcached manually on EC2</strong>.<br>This increases operational effort because scaling, monitoring, patching, and failures must be managed manually.</p><p>To avoid this, I use <strong>Amazon ElastiCache</strong>, a managed in-memory caching service.<br>It helps improve application performance by reducing direct database calls and handling session data efficiently.</p><h4>What This Achieves</h4><ul><li>Faster application response time</li><li>Reduced load on the database</li><li>Managed cache layer with minimal operational effort</li><li>Easy scalability without manual intervention</li></ul><p>This makes the application more responsive and stable under load.</p><h4>Step 3.1: Creating a Parameter Group</h4><p>Before launching the cache cluster, I first create a <strong>Parameter Group</strong>.</p><p><strong>Why this is needed:</strong><br> The parameter group acts as a configuration blueprint for the Memcached engine.<br>Even if default settings are sufficient now, having a custom group allows future tuning without recreating the cluster.</p><p><strong>What I do in the console:</strong></p><ul><li>Go to <strong>ElastiCache → Parameter Groups</strong></li><li><strong>Engine</strong>: <strong>Memcached</strong></li><li><strong>Name</strong>: vprofile-rearch-cache-paragrp</li><li><strong>Description</strong>: Parameter group for vprofile Memcache</li><li><strong>Family</strong>: <strong>memcached1.6</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ODJudS1LAVsuplcBLQCDtQ.jpeg" /></figure><h4>Step 3.2: Creating an ElastiCache Subnet Group</h4><p>Next, I configure a <strong>Subnet Group</strong>.<br>A subnet group defines where the cache cluster will run inside the VPC.<br>This ensures the cache remains private and accessible only within our internal network.</p><p><strong>What I do in the console:</strong></p><ul><li>Go to <strong>ElastiCache → Subnet Groups</strong></li><li><strong>Name</strong>: vprofile-rearch-cache-subgrp</li><li><strong>Description : </strong>Subnet group for vprofile Memcache</li><li><strong>VPC</strong>: Default VPC</li><li><strong>Selected subnets</strong> (3): us-east-1a, us-east-1b, us-east-1c</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HBfE42mb8aP0e4O9J9F4SQ.jpeg" /></figure><h4>Step 3.3 Launching the Memcached Cluster</h4><p>Once the required supporting components are in place, the cache cluster is created.<br>In this project, <strong>Memcached</strong> is used as an in-memory caching layer to store frequently accessed data and reduce repeated database queries.</p><p>Considering the current workload and access patterns of the application, a <strong>single-node Memcached setup</strong> is sufficient to improve response time while keeping the architecture simple and cost-effective. This approach provides the required performance benefits without adding unnecessary infrastructure complexity.</p><p><strong>Key configurations:</strong></p><ul><li><strong>Engine</strong>: <strong>Memcached</strong></li><li><strong>Name</strong>: vprofile-reach-cache</li><li><strong>Version</strong>: <strong>1.6.x</strong></li><li><strong>Port</strong>: <strong>11211</strong> (default Memcached port)</li><li><strong>Node type</strong>: <strong>cache.t2.micro / cache.t3.micro</strong></li><li><strong>Number of nodes</strong>: <strong>1</strong></li><li><strong>Parameter group</strong>: vprofile-rearch-cache-paragrp</li><li>Subnet group: vprofile-rearch-cache-subgrp</li><li>Security group: vprofile-rearch-backend-sg</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3QQpjQQg_xosUN9w9Q51PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRr3BoBfKH5ppe6KB9dckQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRq6f_Byw8rgeLaC8Bgp5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WtAw2Iob93s3HPidpgIqqQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8wehFqzY5qL8kdbgyo2ELg.png" /></figure><h4>Phase 3 Outcome</h4><p>The caching layer is now fully operational with:</p><ul><li>Managed Memcached service</li><li>Secure placement inside the VPC</li><li>Backend-only access through security groups</li></ul><p>This significantly improves application performance while eliminating the need to manage cache servers manually.</p><h3>Phase 4: Setting Up the Message Broker (Amazon MQ)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMbn93cXyanIEYxcnlOc7A.png" /></figure><h4><strong>Why We Need a Message Broker</strong></h4><p>In distributed applications, different components often need to communicate with each other asynchronously.<br>Direct communication between services can create tight coupling and performance bottlenecks.</p><p>To solve this, the project uses a <strong>message broker</strong> that acts as an intermediate layer for communication.<br>This ensures that services can exchange messages reliably without depending on each other’s availability.</p><p>For this purpose, I use <strong>Amazon MQ</strong>, a fully managed message broker service provided by AWS.</p><h4>What This Achieves</h4><ul><li>Decouples application components</li><li>Improves reliability during peak load</li><li>Handles message delivery even if a service is temporarily unavailable</li><li>Removes the need to manually manage and maintain RabbitMQ servers</li></ul><p>Amazon MQ allows us to focus on application logic while AWS manages broker availability and maintenance.</p><h4>Step 4.1: Open Amazon MQ Dashboard</h4><ul><li>From AWS Console, go to <strong>Services → Amazon MQ</strong></li><li>Click <strong>Create broker</strong></li></ul><h4>Step 4.2: Choose Broker Engine</h4><ul><li>Select <strong>RabbitMQ</strong></li><li>Deployment mode: <strong>Single-instance broker</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZBsUaOla6QhztwWUn-OdQ.png" /></figure><p><strong>Why this choice?</strong><br>RabbitMQ is widely used and compatible with the application. A single-instance broker is sufficient for this learning project and keeps costs low.</p><h4>Step 4.3: Configure Broker Details</h4><ul><li><strong>Broker name</strong>: vprofile-rearch-rmq</li><li><strong>Instance type</strong>: <strong>mq.t3.micro</strong></li></ul><p><strong>RabbitMQ access:</strong></p><ul><li><strong>Username: </strong>rabbit</li><li><strong>Password: </strong>rabbit1234567</li></ul><p>⚠️<strong> Action Required</strong>: Save these credentials! You will need to hardcode them into your application.properties file later so the Java app can authenticate with the broker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_0E402JJNgOFmHvFyPAhQ.jpeg" /></figure><ul><li><strong>Broker engine version: 3.13</strong></li><li><strong>Access Type</strong>: Private Access</li></ul><p><strong>Why?</strong> Broker should not be exposed to the public internet.<br> Application and broker run inside the same VPC.</p><ul><li><strong>Security group: </strong>vprofile-rearch-backend-sg</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yatNlXYe513fmbKc_cUKJQ.jpeg" /></figure><ul><li>Wait until broker status becomes <strong>Running.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3oAqvjhf_eMMGkj2grYuQ.png" /></figure><h4>Phase 4 Outcome</h4><p>By the end of this phase, the messaging layer is successfully configured using <strong>Amazon MQ (RabbitMQ)</strong>.<br>The broker is securely deployed within the VPC and is accessible only to backend services through the defined security group.</p><p>Authentication credentials are created and stored securely, enabling the application to communicate with the message broker reliably.<br>With AWS managing broker maintenance, upgrades, and monitoring, the operational effort is minimized while ensuring stable asynchronous communication.</p><h3>Phase 5: Initializing the Database (Schema Deployment)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X0mcvqwy8V_SxEW6iKdyVw.png" /></figure><p>At this stage, the application environment is ready, but the database is still empty.<br>Since the RDS instance is private, it cannot be accessed directly from the public internet.<br>To initialize the database schema, we need a temporary bridge inside the VPC.</p><p>For this purpose, I use a temporary EC2 instance that will act as a MySQL client.</p><h4>Why a Temporary EC2 Instance Is Required</h4><ul><li>RDS is deployed in a private network for security reasons</li><li>Direct access from a local machine is not allowed</li><li>A temporary EC2 instance inside the same VPC can securely connect to RDS</li><li>Once the schema is deployed, this instance is no longer needed</li></ul><p>This approach keeps the database secure while allowing controlled access for setup tasks.</p><h4>Step 5.1: Create a new security group</h4><ul><li><strong>Security Group</strong>: Create a new one (vpro-mysql-client-sg) that allows <br>SSH (Port 22) from Your IP.</li></ul><p><strong>Why this setup:</strong></p><ul><li>SSH access is restricted only to your IP</li><li>No unnecessary ports are exposed</li><li>Access is limited and controlled</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HC5zsvIJFEVG3vWlGZMnJw.png" /></figure><h4>Step 5.2: Launching a Temporary MySQL Client</h4><p>I launch a small Ubuntu EC2 instance that will be used only to run database commands.<br>This instance is <strong>disposable</strong> and will be terminated after the database setup is complete.</p><h4>EC2 Configuration</h4><ul><li><strong>Name:</strong> mysql-client</li><li><strong>AMI:</strong> Ubuntu Server 24.04</li><li><strong>Instance type:</strong> t2.micro</li><li><strong>Key pair:</strong> Use existing project key pair</li><li><strong>Security Group</strong>: vpro-mysql-client-sg (created earlier)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mixym9PNnaQmBSTqT0Cy3A.png" /></figure><h4>Step 5.3: Networking — Allowing the Client to Talk to RDS</h4><p>At this point, the MySQL client EC2 instance is running inside the VPC, but it still cannot connect to the RDS database.<br>This is because <strong>RDS access is controlled by security group rules</strong>.</p><p>To enable communication, we must explicitly allow the MySQL client security group to access the RDS security group.</p><p>This step ensures <strong>secure and controlled access</strong> without exposing the database publicly.</p><h4>What I Do in the AWS Console</h4><ol><li>Go to <strong>EC2 → Security Groups</strong></li><li>Copy the Security Group ID of your new vpro-mysql-client-sg</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFn-KBtOOprBkRV-Fr6rWw.jpeg" /></figure><p>3. Open the <strong>RDS backend security group</strong> (vprofile-rearch-backend-sg)</p><p>4. Edit <strong>Inbound rules</strong></p><p>5. Add a new rule:</p><ul><li><strong>Type:</strong> MySQL / Aurora (Port 3306)</li><li><strong>Source:</strong> vpro-mysql-client-sg</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t7djg63Bj0DQ4wwsf7vg0Q.png" /></figure><p>With the security group configuration in place, we can now move forward to test the RDS connectivity.</p><h4>Step 5.4: Installing Required Tools &amp; Cloning the Application Code</h4><p>SSH:</p><pre>ssh -i vprofile-rearch-key.pem ubuntu@&lt;EC2-Public-IP&gt;</pre><p>Once you SSH into the Ubuntu instance, run the following to prepare the environment:</p><pre>sudo apt update &amp;&amp; sudo apt install mysql-client git -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYOlXlnjv8rfjr9130x57Q.jpeg" /></figure><p>Check:</p><pre>mysql --version</pre><h4>STEP-5.5: Clone the Application Repository and Switch Branch</h4><p>Next, I clone the VProfile project repository, which contains the SQL schema required to initialize the database.<br>After cloning, I switch to the refactored branch to ensure the correct schema and configurations are used for the AWS-based architecture.</p><pre>git clone https://github.com/AAKASHDEEP786/vprofile-project.git<br>cd vprofile-project<br>git checkout aws-Refactor</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00h0YlcZGSSh16vuyL8u9A.jpeg" /></figure><h4>Step 5.6: Injecting the Database Schema into Amazon RDS</h4><p>Using the MySQL client installed on the temporary EC2 instance, I connect to the RDS endpoint and load the SQL schema provided in the project repository.</p><pre>mysql -h &lt;your-rds-endpoint&gt; -u admin -p accounts &lt; src/main/resources/db_backup.sql</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbBracPSuXqsXG9Bma_i4A.png" /></figure><p>After running the command, I enter the database password when prompted.</p><blockquote>Password: Saved during creation of RDS database</blockquote><p>To confirm that the schema is applied successfully, I log in to the database and list the tables:</p><pre>mysql -h &lt;RDS-ENDPOINT&gt; -u admin -p<br>USE accounts;<br>SHOW TABLES;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ITClAzA88tommgnYB7_TSQ.png" /></figure><h4>Cleanup</h4><p>Once the schema deployment is verified, the temporary EC2 instance used as the MySQL client can be safely terminated to avoid unnecessary cost and exposure.</p><h4>Phase 5 Outcome</h4><p>By the end of this phase, the application environment is fully prepared and operational.<br>The database schema is successfully deployed into the private Amazon RDS instance using a secure, temporary EC2 bridge.</p><p>The application now has a ready backend data structure, and all connectivity between the application environment and the database is verified.<br>With the temporary setup cleaned up, the environment remains secure, cost-efficient, and ready for application runtime integration in the next phase.</p><h3>Phase 6: Deploying the Application Layer using AWS Elastic Beanstalk</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DQI4sQ0bxp6BwyOY1qEAMw.png" /></figure><p>With all backend services in place — <strong>Amazon RDS (Database), ElastiCache (Caching), and Amazon MQ (Messaging)</strong> — the system is now ready for application deployment.<br> In this phase, the goal is to deploy the Java web application in a way that minimizes manual effort while ensuring scalability, reliability, and ease of management.</p><p>Instead of manually provisioning EC2 instances, configuring Tomcat, load balancers, and auto scaling, I use <strong>AWS Elastic Beanstalk</strong>, which abstracts all these operational tasks into a single managed environment.</p><h4>Step 6.1: Preparing IAM Roles for Elastic Beanstalk</h4><p>Before creating the Beanstalk environment, proper IAM permissions are required so that Elastic Beanstalk can manage AWS resources on our behalf.</p><h4>What is done</h4><p>I create an IAM role that will be attached to the EC2 instances launched by Elastic Beanstalk.</p><h4>Role Configuration</h4><ul><li><strong>Role Name:</strong> vprofile-rearch-bean-role</li><li><strong>Attached Policies:</strong></li><li>AdministratorAccess-AWSElasticBeanstalk</li><li>AWSElasticBeanstalkWebTier</li><li>AWSElasticBeanstalkWorkerTier</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a0bOPG4L8vxds-hVXWQ4MA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nzrfTCMrOVZvyuyHQFascw.jpeg" /></figure><h4>Step 6.2: Creating the Elastic Beanstalk Environment</h4><p>Once the IAM role is ready, I proceed to create the Elastic Beanstalk application environment.</p><h4>Environment Setup</h4><p><strong>AWS Console → Search → Elastic Beanstalk</strong></p><ol><li>Click <strong>Create Application</strong></li></ol><ul><li><strong>Application Name:</strong> vprofile-app</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbJvugG8yAq8YaVJSPnKpA.png" /></figure><p>2. Click <strong>Create Environments</strong></p><ul><li><strong>Environment Name:</strong> vprofile-rearch-bean-app-env</li><li><strong>Environment Type:</strong> Web Server Environment</li><li><strong>Platform:</strong> Tomcat 9 with Corretto 8</li><li><strong>Configuration Preset:</strong> Select Custom Configuration (Crucial so we can choose our own VPC and instance types).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avaZIBh2st8kteiZ9LJFVg.png" /></figure><h4>Step 6.3: Configuring Service Access and Networking</h4><p>In this step, I define how the Beanstalk environment interacts with AWS services and the network.</p><h4>Key Settings</h4><ul><li><strong>Service Role:</strong> aws-elasticbeanstalk-service-role</li><li><strong>EC2 Instance Profile:</strong> vprofile-rearch-bean-role</li><li><strong>Key Pair:</strong> vprofile-rearch-key</li><li><strong>VPC:</strong> Default VPC</li><li><strong>Public IP:</strong> Enabled</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQEa8SjQCLxc9cRR6YiabA.jpeg" /></figure><h4><strong>Step 6.4: Instance Configuration and Auto Scaling</strong></h4><p>To ensure availability while keeping costs under control, Auto Scaling settings are carefully configured.</p><h4>Instance Settings</h4><ul><li><strong>Environment Type:</strong> Load balanced</li><li><strong>Instance Type:</strong> t3.micro</li><li><strong>Root Volume:</strong> GP3(SSD)</li></ul><h4>Auto Scaling Capacity</h4><ul><li><strong>Minimum Instances:</strong> 2</li><li><strong>Maximum Instances:</strong> 4</li></ul><h4>Scaling Policy</h4><ul><li><strong>Metric:</strong> Network Out</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwSGQkLtfpHFiNS-QG_PKQ.jpeg" /></figure><h4>Step 6.5: Load Balancer and Session Management</h4><p>Elastic Beanstalk provisions an <strong>Application Load Balancer (ALB)</strong> automatically.</p><h4>Load Balancer Settings</h4><ul><li><strong>Type:</strong> Application Load Balancer</li><li><strong>Listener Port:</strong> 80 (HTTP)</li></ul><h4>Session Stickiness (Critical Setting)</h4><ul><li>Session stickiness is enabled on the default process</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1VtfuzgCzzWCdbainLBX5w.jpeg" /></figure><h4>Reason for enabling stickiness</h4><p>The Java application maintains user sessions in memory.<br>Without stickiness, a user request could be routed to a different instance, leading to session loss or unexpected logouts.</p><ul><li><strong>Health check path</strong>: /login</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dC_d6eYGdpST1GAWRVZHKw.png" /></figure><h4>Step 6.6: Deployment Strategy</h4><ul><li><strong>Deployment Policy:</strong> Rolling Update</li><li><strong>Batch Size</strong>: 50% (With 2 instances, it will update 1 at a time)</li></ul><h4>Why Rolling Updates</h4><p>This ensures that instances are updated gradually, allowing the application to remain available during deployments with zero downtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mHRUYducGHk535sVl83n5Q.jpeg" /></figure><p>After configuring all required settings, I review the environment configuration one last time to ensure everything is correctly set.</p><p>Once confirmed:</p><ul><li>Click on <strong>Create Environment</strong></li><li>Elastic Beanstalk starts provisioning resources such as EC2 instances, Load Balancer, and Auto Scaling group</li><li>This process takes a few minutes to complete</li></ul><p>I wait until the environment status changes to <strong>Healthy</strong>, which confirms that the application has been deployed successfully and is running as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OCDJVJmXrFxXNkipUuSSdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nmMacydna6nFfipkIrk40A.png" /></figure><ul><li>Once the environment reaches a Healthy state, I copy the Elastic Beanstalk <strong>domain URL</strong> and open it in a web browser to verify application access.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*izThxKATehUOwS8isHYdBw.jpeg" /></figure><h3>Phase 6 Outcome</h3><p>The application is successfully deployed on <strong>AWS Elastic Beanstalk</strong> in a fully managed and scalable environment.<br>Elastic Beanstalk handles infrastructure provisioning, load balancing, auto scaling, and health monitoring, eliminating the need for manual server management.</p><p>The application is now publicly accessible through the Elastic Beanstalk domain and is fully integrated with all backend services, including <strong>Amazon RDS, ElastiCache, and Amazon MQ</strong>.<br>This phase completes the end-to-end application deployment, demonstrating how DevOps practices simplify application delivery and reduce operational overhead.</p><h3>Phase 7: Bridging the Gap (Connectivity &amp; Credentials)</h3><p>At this stage, the Elastic Beanstalk environment is live and running, but the application still cannot communicate with the backend services.<br>Even though everything exists inside the same VPC, the backend services are protected by strict security group rules.</p><p>In this step, the goal is to <strong>create a secure bridge</strong> between the application layer (Elastic Beanstalk) and the backend layer (RDS, ElastiCache, Amazon MQ)</p><h4>Step 7.1: Open <strong>EC2 Console</strong></h4><ol><li>Navigate to <strong>Instances</strong></li><li>Select one of the instances launched by Elastic Beanstalk</li><li>Under the <strong>Security</strong> tab, identify the security group that starts with something like:awseb-e-xxx</li><li>Copy the <strong>Security Group ID</strong></li></ol><p><strong>📌 IMPORTANT:</strong><br> Do not copy the load balancer’s security group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mW7snUexXE9wQdamiWKvzA.jpeg" /></figure><h4>Step 7.2: Updating the Backend Security Group</h4><p>Now that we know which security group the application instances use, we allow backend services to accept traffic from it.</p><h4>What this achieves</h4><p>It tells RDS, ElastiCache, and Amazon MQ:</p><p><strong><em>“Traffic coming from Elastic Beanstalk instances is trusted.”</em></strong></p><h4>Steps performed</h4><ol><li>Go to <strong>EC2 → Security Groups</strong></li><li>Select vprofile-rearch-backend-sg</li><li>Edit <strong>Inbound Rules</strong></li><li>Add a new rule:</li></ol><ul><li><strong>Type:</strong> All Traffic<br> <em>(or specific ports like 3306, 11211, 5672 for tighter security)</em></li><li><strong>Source:</strong> Elastic Beanstalk <strong>Instance Security Group ID</strong></li><li><strong>Description:</strong> Allow traffic from Beanstalk application instances</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uz9OPnIh6IudifD-9GEg_Q.png" /></figure><h4>Step 7.3: Preparing the Connection Cheat Sheet</h4><p>Before building and deploying the final application artifact, I collect all backend connection details in one place.<br>This acts as a <strong>single source of truth</strong> while updating application configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xrUbyOX3Uhe3zwrMk6N0A.png" /></figure><p>⚠️ For Amazon MQ, the <strong>wire-level AMQP endpoint</strong> is used, not the web console URL (starting with amqp://).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6TnPaO8i_QhZerAE2iMWEA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qP06o3ZAL6THo4Ymr2_qCw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m-xOfj7a3EzZ5GnwlyUoHQ.jpeg" /></figure><h4>Step 7 Outcome</h4><p>The application layer is now securely connected to all backend services.<br>Security groups are correctly nested, allowing controlled communication without exposing internal services to the public internet.</p><p>With connectivity and credentials ready, the infrastructure is fully wired and prepared for final application configuration and deployment.</p><p>➡<strong>Next Step:</strong><br> Now it’s time to inject these details into the code, build the artifact, and deploy it.</p><h3>Phase 8: Build and Deployment (The Final Integration)</h3><p>At this stage, all infrastructure components are ready and properly connected.<br>The final task is to <strong>integrate everything together</strong> by updating application configuration, building the artifact, and deploying it to Elastic Beanstalk.</p><p>This step represents the point where <strong>infrastructure and application finally meet</strong>.</p><h4>Step 8.1: Updating Application Configuration</h4><p>Before building the application, backend connection details must be injected into the configuration file so the application knows how to reach each service.</p><p>Open the source code in an editor (such as VS Code), switch to the aws-Refactor branch, and update the required values in src/main/resources/application.properties.</p><p>Clone the repository (if not already)</p><pre><br>git clone https://github.com/AAKASHDEEP786/vprofile-project.git<br>cd vprofile-project/src/main/resources/</pre><p>Update the following properties in application.properties:</p><ul><li><strong>jdbc.url</strong>: Use the Amazon RDS endpoint</li><li><strong>memcached.active.host</strong>: Use the ElastiCache endpoint</li><li><strong>rabbitmq.address</strong>: Use the Amazon MQ endpoint and update the port to <strong>5671</strong></li><li><strong>Credentials</strong>: Update all relevant usernames and passwords accordingly</li></ul><p>These values are taken from the endpoints and credentials collected in the previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1zFsxwREveEQU25X1Am6Sw.png" /></figure><h4>Step 8.2: Build the Application (WAR file)</h4><pre>mvn clean install</pre><p>Success check:</p><pre>ls target/</pre><p>You must see: <strong>vprofile-v2.war</strong></p><p>If build fails → <strong>STOP</strong> and fix errors before moving ahead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5MqjLOaLhNBsw-dg-YKxRA.jpeg" /></figure><h4>Step 8.3: Deploying the WAR file to Elastic Beanstal</h4><p>With the artifact ready, the next step was deployment.</p><ol><li>I navigated to the <strong>Elastic Beanstalk console</strong>.</li><li>Opened the application and selected the running environment.</li><li>Clicked <strong>Upload and Deploy</strong>.</li><li>Uploaded the vprofile-v2.war file.</li><li><strong>Version label: </strong>vprofile-app-version-1</li><li>Started the deployment.</li></ol><p>Since the environment was configured with a <strong>Rolling Update deployment policy</strong>, Elastic Beanstalk updated instances gradually. This ensured the application remained available during deployment without downtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pK7pyL5H_ZcKfieFVZlx-g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ikG733AaEzfxqxABqJleBA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjKW3DH-DJs2ExEi5MQq9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2RkTtAnecxiZSFiVr38O2w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qbev5fZzKCW8Kiyii9SasA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yH3nLcBDMfyZNO8EcDUQrA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-67G_LBp7GNY_BmYNAAvg.jpeg" /></figure><h4>Step 8.4: Configuring Custom Domain &amp; SSL (HTTPS) on Elastic Beanstalk</h4><p>By default, Elastic Beanstalk exposes our application using an AWS-generated URL like: <a href="http://vprofile-rearch-bean-app-env.us-east-1.elasticbeanstalk.com/">http://vprofile-rearch-bean-app-env.us-east-1.elasticbeanstalk.com</a>.</p><p>While this works, it is:</p><ul><li>Not professional</li><li>Not secure (HTTP)</li><li>Not suitable for production</li></ul><p>In this step, we will:</p><ol><li>Attach a <strong>custom domain</strong> (e.g., vpro.devopshackarena.xyz)</li><li>Enable <strong>HTTPS using SSL/TLS</strong></li><li>Secure traffic using <strong>AWS Certificate Manager (ACM)</strong></li></ol><h4>Step 8.4.1: Request an SSL Certificate (ACM)</h4><p>Elastic Beanstalk uses <strong>Application Load Balancer</strong>, so we must create an SSL certificate in <strong>the same region as Beanstalk</strong>.</p><h4>Steps:</h4><ol><li>Go to <strong>AWS Console → Certificate Manager (ACM)</strong></li><li>Click <strong>Request a certificate</strong></li><li>Choose <strong>Public certificate</strong></li><li>Enter your domain: vpro.devopshackarena.xyz</li></ol><p>5. Choose <strong>DNS validation</strong> (recommended)</p><p>6. Click <strong>Request</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j87wrpGYRjDg9Qr5UrbIAw.png" /></figure><p><strong>DNS Validation</strong></p><p>ACM will give you a <strong>CNAME record</strong>.</p><p>If your domain is:</p><ul><li><strong>Route 53</strong> → ACM can auto-create it</li><li><strong>GoDaddy / Hostinger</strong> → Manually add the CNAME</li></ul><p>⏳ Wait 2–5 minutes until certificate status becomes <strong>Issued</strong></p><h4>Step 8.4.2: Add HTTPS Listener to Elastic Beanstalk</h4><p>Now we tell Elastic Beanstalk to accept HTTPS traffic.</p><h4>Steps:</h4><ol><li>Go to <strong>Elastic Beanstalk</strong></li><li>Select your environment: vprofile-rearch-bean-app-env</li><li>Click <strong>Configuration</strong></li><li>Edit <strong>Load Balancer</strong></li></ol><p><strong>Add HTTPS Listener</strong></p><p>Under <strong>Listeners</strong>:</p><ul><li>Click <strong>Add listener</strong></li><li>Listener Port: 443<br>Listener Protocol: HTTPS<br>SSL Certificate: Select ACM certificate</li></ul><p>5. Click <strong>Apply</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MkI-HQBdZrdH36MiqM7CNw.png" /></figure><p>Elastic Beanstalk will now:</p><ul><li>Update ALB</li><li>Attach the SSL certificate</li><li>Restart configuration safely</li></ul><h4>Step 8.4.3: Configure Custom Domain (DNS Mapping)</h4><p>Now we map our domain to the Elastic Beanstalk Load Balancer.</p><ul><li>Get Beanstalk Endpoint</li></ul><p><strong>Create CNAME Record</strong></p><p>Go to your domain provider (GoDaddy / Route 53):</p><ul><li><strong>Record Type</strong>: CNAME</li><li><strong>Name</strong>: vpro</li><li><strong>Value:</strong> Beanstalk Endpoint (eg. vprofile-rearch-bean-app-env.us-east-1.elasticbeanstalk.com)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYi31caKnHuZJLsz3iP8cg.png" /></figure><p>⏳ DNS propagation usually takes 2–10 minutes.</p><h4>Step 8.4.4: Redirect HTTP → HTTPS</h4><p>This ensures <strong>all traffic is encrypted</strong>.</p><ol><li>Go to <strong>Configuration → Load Balancer</strong></li><li>Edit <strong>Listener Rules</strong></li></ol><ul><li>Add rule: IF protocol = HTTP</li><li>THEN redirect to HTTPS (443)</li></ul><h4>Step 8.4.5: Final Verification</h4><p><strong>Open browser and test: </strong><a href="https://vpro.devopshackarena.xyz/">https://vpro.devopshackarena.xyz</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sVobUe5Kyk-jPn6H2NgVWA.jpeg" /></figure><h4>Verify:</h4><ul><li>Website loads</li><li>Lock icon visible</li><li>Certificate issued by <strong>Amazon</strong></li><li>Login works (admin_vp / admin)</li></ul><p>This confirms:</p><ul><li>SSL is working</li><li>Load balancer is healthy</li><li>Application can talk to RDS, ElastiCache, and MQ</li></ul><h4>Phase 8 Outcome</h4><p>At the end of phase 8, we have:</p><p>✔ A fully functional Java application<br> ✔ Running on AWS managed services<br> ✔ Securely accessible over HTTPS<br> ✔ Highly available and scalable<br> ✔ Ready for real users</p><p>This officially completes the <strong>core refactoring and deployment phase</strong> of the project.</p><h4><strong>➡Next Step:</strong></h4><p><strong>Global Acceleration with Amazon CloudFront. </strong>Although our application is now live and secure, it is still hosted in <strong>a single AWS region (us-east-1)</strong>. Users accessing it from distant locations may experience higher latency.</p><h3>Phase 9: Global Acceleration with Amazon CloudFront (CDN)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L50XfTcD0dRRKk_W5fpkxg.png" /></figure><p>At the end of phase 8, our application is <strong>secure, scalable, and production-ready</strong>.<br> However, there is still one limitation.</p><h4>The Problem: Regional Latency</h4><p>Our Elastic Beanstalk application is deployed in <strong>us-east-1 (North Virginia)</strong>.</p><p>This means:</p><ul><li>Users in the <strong>US</strong> get fast responses</li><li>Users from <strong>India, Europe, or other regions</strong> experience higher latency</li><li>Every request must travel long physical distances to reach the origin server</li></ul><p>As traffic grows globally, this results in:</p><ul><li>Slower page loads</li><li>Poor user experience</li><li>Increased load on the origin (Elastic Beanstalk)</li></ul><h4>The Solution: Amazon CloudFront (Content Delivery Network)</h4><p>To solve this, we introduce <strong>Amazon CloudFront</strong>, AWS’s global Content Delivery Network (CDN).</p><h4>What CloudFront Does:</h4><ul><li>Caches application content at <strong>600+ edge locations worldwide</strong></li><li>Serves users from the <strong>nearest edge location</strong></li><li>Reduces latency and improves performance</li><li>Acts as a <strong>global front door</strong> for our application</li></ul><p>Instead of hitting Elastic Beanstalk directly, all traffic now flows through CloudFront.</p><h4>Step 9.1: Open CloudFront Console</h4><ol><li>Login to <strong>AWS Console</strong></li><li>Search <strong>CloudFront</strong></li><li>Click <strong>Create a CloudFront distribution</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IKC6mW8m2ax5FsIpFWNFiw.png" /></figure><p><strong>4. Distribution Setup</strong></p><ul><li><strong>Distribution name:</strong> vprofile-global-cdn</li><li><strong>Distribution type</strong>: Single website or app</li></ul><h4>Step 9.2: Origin Configuration</h4><p><strong>Origin type</strong>: Elastic Beanstalk Load Balancer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jr6bFGnDH-UtwVdbOB2_Sw.png" /></figure><h4>Step 9.3: Custom Domain + SSL (CNAME)</h4><p>Add Alternate Domain Name (CNAME)</p><ol><li>Scroll → <strong>Settings / General</strong></li><li>Alternate domain name: Your_domain</li></ol><p>⚠️<strong> SSL Certificate</strong>: Select your ACM Certificate (Must be in <br>US-East-1/North Virginia for CloudFront to use it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dulm9lewpNQ8-APFddQVnQ.png" /></figure><h4>Step 9.4: Update DNS (GoDaddy / Route53)</h4><p>Previously, our CNAME pointed to Beanstalk. Now, we want it to point to the CloudFront Distribution Domain Name. <br>1. Go to your Domain Registrar (GoDaddy/Route 53). <br>2. Find the CNAME record for vpro. <br>3. Update the Value: Delete the Beanstalk URL and paste the <br>CloudFront Domain Name (e.g., d1k939vwkv7q9m.cloudfront.net). <br>4. Save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K5oWJhfY0I8IeKi6A5Ostw.png" /></figure><h4>Verification</h4><p>Wait about 10–15 minutes for the status to change from “Deploying” to <br>“Enabled.”</p><p><strong>Final Test:</strong></p><ul><li>Open browser:https://vpro.devopshackarena.xyz</li></ul><p><strong>Check:</strong></p><ul><li>🔒 Lock icon (HTTPS)</li><li>Login works</li><li>Page load faster</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sVobUe5Kyk-jPn6H2NgVWA.jpeg" /></figure><h3>Project Conclusion</h3><p>We have successfully Refactored a traditional EC2-based Java application into a <strong>modern AWS-managed architecture.</strong></p><h4>What we achieved:</h4><ol><li>Replaced self-managed services with <strong>AWS PaaS &amp; SaaS</strong>:</li></ol><ul><li>EC2 Tomcat → <strong>Elastic Beanstalk</strong></li><li>MySQL on EC2 → <strong>Amazon RDS</strong></li><li>Memcached → <strong>Amazon ElastiCache</strong></li><li>RabbitMQ → <strong>Amazon MQ</strong></li></ul><p>2. Designed <strong>secure networking</strong> using VPC and Security Groups to keep backend services private</p><p>3. Implemented <strong>IAM roles and instance profiles</strong> for secure, credential-free service communication</p><p>4. Initialized and managed the database using a <strong>temporary EC2 jump host</strong>, then cleaned it up to reduce cost</p><p>5. Built and deployed the application using <strong>Maven + Elastic Beanstalk rolling deployments</strong> (zero downtime)</p><p>6. Configured <strong>custom domain and HTTPS</strong> using ACM and Load Balancer listeners</p><p>7. Integrated <strong>Amazon CloudFront</strong> to enable global content delivery and low-latency access</p><p>8. Achieved a <strong>scalable, secure, cost-optimized, and production-ready architecture</strong></p><p>9. Shifted focus from <strong>server management to application and reliability engineering</strong></p><h4>Project Links &amp; Connect With Me</h4><ul><li><strong>GitHub Repository:</strong><br> 👉 <a href="https://github.com/AAKASHDEEP786/vprofile-project.git">https://github.com/AAKASHDEEP786/vprofile-project.git</a></li><li><strong>LinkedIn Profile:</strong><br> 👉 <a href="https://www.linkedin.com/in/aakash-deep-v16">https://www.linkedin.com/in/aakash-deep-v16</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01d78949bb40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Bare-Metal Kubernetes Cluster on Hyper-V]]></title>
            <link>https://medium.com/@akashdeep960/building-a-bare-metal-kubernetes-cluster-on-hyper-v-da6e04fddd89?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/da6e04fddd89</guid>
            <category><![CDATA[horizontal-pod-autoscaler]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[baremetal]]></category>
            <category><![CDATA[3-tier-architecture]]></category>
            <category><![CDATA[kubernetes-loadbalancer]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Sun, 28 Dec 2025 15:13:47 GMT</pubDate>
            <atom:updated>2025-12-30T16:36:38.316Z</atom:updated>
            <content:encoded><![CDATA[<p>A complete step-by-step guide: from Windows + Hyper-V to Kubernetes, MetalLB, Ingress NGINX, and domain-based access without cloud.</p><h3>1️⃣ Why I Built This</h3><p>Most Kubernetes tutorials assume <strong>cloud providers</strong> (EKS, GKE, AKS).<br>But in real learning and understanding <strong>bare-metal Kubernetes</strong> is extremely valuable.</p><p>So my goal was:</p><ul><li>Build Kubernetes <strong>from scratch</strong></li><li>Run it on <strong>my own machine</strong></li><li>Understand <strong>networking, ingress, load balancing</strong></li><li>Simulate <strong>real production behaviour</strong> without using cloud</li></ul><p>This post documents <strong>everything I did</strong>, step by step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2wOmyDpK2ZK6u2qP5Jffg.png" /><figcaption>Kubernetes on Bare-Metal</figcaption></figure><h3>2️⃣ Base Setup: Windows + Hyper-V (Bare Metal)</h3><h4>Host System (Bare-Metal Layer)</h4><p>I have a <strong>Windows 11 host machine</strong> with <strong>Hyper-V enabled</strong>, and I am using it as my <strong>bare-metal layer</strong>. All Kubernetes nodes in this POC are running as virtual machines on top of this Windows host.</p><ul><li><strong>Host OS:</strong> Windows 11</li><li><strong>Virtualization:</strong> Hyper-V (Type-1 Hypervisor)</li><li><strong>Purpose:</strong><br>I used this setup to simulate a <strong>bare-metal Kubernetes environment</strong>, similar to what we see in on-premise data centers, while still working from a single physical machine.</li></ul><h4>Why I Chose Hyper-V</h4><p>I specifically chose <strong>Hyper-V</strong> for this lab because:</p><ul><li>It is <strong>native to Windows</strong>, so no third-party tools were required</li><li>It provides <strong>stable and predictable networking</strong>, which is critical for Kubernetes</li><li>Being a <strong>Type-1 hypervisor</strong>, it offers better performance</li><li>It works very well for <strong>multi-node Kubernetes labs</strong></li><li>It allows me to test <strong>LoadBalancer, Ingress, and persistent storage</strong> scenarios realistically</li></ul><p>For learning Kubernetes internals and DevOps workflows, Hyper-V turned out to be a very solid choice.</p><h4>Virtual Machine Specifications (Per Kubernetes Node)</h4><p>For each Kubernetes node (both master and worker), I created a dedicated virtual machine with the following configuration:</p><pre>| Resource         | Specification                   |<br>| ---------------- | ------------------------------- |<br>| **vCPU**         | 4 vCPUs per node                |<br>| **Memory (RAM)** | 8 GB per node                   |<br>| **Disk Size**    | 50 GB per node                  |<br>| **Disk Type**    | Dynamic VHDX                    |<br>| **Network**      | Hyper-V External Virtual Switch |<br>| **Guest OS**     | Ubuntu Server (24.04 LTS)       |</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*u98h8kZcGDsMivfx0dIBvw.png" /><figcaption>Base Infrastructure</figcaption></figure><p>I assigned <strong>4 CPUs per node</strong> to ensure smooth performance of core Kubernetes components like:</p><ul><li>kube-apiserver</li><li>etcd</li><li>controller-manager</li><li>scheduler</li></ul><p>The <strong>50 GB disk size</strong> gave me enough space for:</p><ul><li>Container images</li><li>Kubernetes logs</li><li>MySQL data</li><li>Longhorn persistent volumes</li></ul><h3>3️⃣ Virtual Machines Architecture</h3><p>I created <strong>4 Ubuntu VMs</strong> inside Hyper-V:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*pbk_WzBwiiv4_rQKOpa6AA.png" /><figcaption>4-node Ubuntu Kubernetes cluster running on Hyper-V</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*CUXpGvSiUhtMaNnW-BsMRA.jpeg" /></figure><ul><li>Same LAN subnet (192.168.0.0/24)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*vipuN7ZXiE3jsHn_sXNBXg.png" /></figure><h4>Kubernetes Cluster Layout</h4><p>In my setup, I created:</p><ul><li><strong>1 Master Node</strong></li><li><strong>Multiple Worker Nodes</strong></li></ul><p>This cluster size was enough for me to test:</p><ul><li>Stateless and Stateful workloads</li><li>MySQL with <strong>Longhorn PVC</strong></li><li>Horizontal Pod Autoscaling (HPA)</li><li>NGINX Ingress Controller</li><li>Monitoring tools like <strong>Prometheus and Grafana</strong></li></ul><h4>🧩 Why Static IPs Are Important in a Kubernetes Homelab</h4><p>In a bare-metal Kubernetes setup:</p><ul><li>Nodes <strong>must not change IPs</strong></li><li>kubelet, API server, etcd, MetalLB — all depend on <strong>stable IPs</strong></li><li>If IP changes → <strong>cluster breaks</strong></li></ul><p>Since I was running Kubernetes on <strong>Windows 11 + Hyper-V</strong>, DHCP IPs were <strong>not reliable</strong>.</p><p>So I fixed <strong>static IPs for all VMs</strong>.</p><h4>🔧 Edit Netplan Configuration</h4><p>Ubuntu uses <strong>netplan</strong> for network config.</p><pre>sudo nano /etc/netplan/01-network-manager-all.yaml</pre><p>🧾 Example Static IP Configuration (Master Node)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*R4ho_-eJF2zJ6Q63lakITg.jpeg" /></figure><p>🧾 worker-node-1 example</p><p>Change <strong>only the IP</strong>:</p><pre>addresses:<br>  - 192.168.0.12/24</pre><p>Same steps for:</p><ul><li>worker-node-2 → 192.168.0.13</li><li>worker-node-3 → 192.168.0.14</li></ul><p>Apply Netplan Changes</p><pre>sudo netplan apply</pre><p>⚠️ If SSH disconnects, <strong>wait 10 seconds</strong> — IP will come back.</p><p>Verify Static IP</p><pre>ip a<br>ip route<br>ping 192.168.0.1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*Y6BfdyLt573LZYDDpiHXPA.png" /></figure><h4>🔧 Update /etc/hosts (Optional but Recommended)</h4><p>On <strong>all nodes</strong>:</p><pre>sudo nano /etc/hosts</pre><p>Add:</p><pre>192.168.0.11   master-node<br>192.168.0.12   worker-node-1<br>192.168.0.13   worker-node-2<br>192.168.0.14   worker-node-3</pre><p>Why?</p><ul><li>Easier node communication</li><li>Readable logs</li><li>SSH by hostname</li></ul><h4>🔧 Hyper-V Side (Important)</h4><p>In <strong>Hyper-V Manager</strong>:</p><ul><li>All VMs connected to <strong>same Virtual Switch</strong></li><li>Switch type: <strong>External</strong></li><li>Bridged to your Wi-Fi / Ethernet</li></ul><p>⚠️ Do <strong>not</strong> use:</p><ul><li>Default Switch (dynamic NAT IPs)</li><li>Internal switch</li></ul><h3>4️⃣ Common Node Configuration (ALL Nodes)</h3><p>Before installing Kubernetes, <strong>every node must be prepared</strong>.</p><h4><strong>🔹 1. Disable Swap (Mandatory)</strong></h4><p>The Kubernetes scheduler expects full control over memory usage. If swap is enabled, pods can behave unpredictably, and kubelet may fail to start.</p><pre>sudo swapoff -a<br># To disable swap permanently (so it doesn’t re-enable after reboot):<br>sudo sed -i &#39;/ swap / s/^/#/&#39; /etc/fstab</pre><p>✔️ After this step, I verified that swap was completely disabled.</p><pre>swapon --show</pre><h4><strong>🔹 2. Enable Kernel Modules</strong></h4><p>Kubernetes networking relies on specific Linux kernel modules, especially for <strong>container networking and bridge traffic</strong>.</p><p>I manually loaded the required modules:</p><pre>sudo modprobe overlay<br>sudo modprobe br_netfilter</pre><p>To make sure these modules are loaded <strong>automatically after reboot</strong>, I persisted them:</p><pre>cat &lt;&lt;EOF | sudo tee /etc/modules-load.d/k8s.conf<br>overlay<br>br_netfilter<br>EOF</pre><h4><strong>🔹 3. sysctl Networking Config</strong></h4><p>Kubernetes requires certain <strong>network-level kernel parameters</strong> to be enabled so that:</p><ul><li>Pods can communicate with each other</li><li>Services and Ingress routing work correctly</li><li>Packet forwarding functions as expected</li></ul><p>I configured the required sysctl values:</p><pre>cat &lt;&lt;EOF | sudo tee /etc/sysctl.d/k8s.conf<br>net.bridge.bridge-nf-call-iptables = 1<br>net.ipv4.ip_forward = 1<br>net.bridge.bridge-nf-call-ip6tables = 1<br>EOF<br><br># Then applied the configuration:<br>sudo sysctl --system</pre><h4>🔹 4. Install containerd (Container Runtime)</h4><p>Kubernetes requires a <strong>CRI-compatible container runtime</strong>.<br>I chose <strong>containerd</strong>, which is lightweight, stable, and recommended by Kubernetes.<br>On <strong>all nodes</strong>:</p><pre>sudo apt update<br>sudo apt install -y containerd</pre><p>Next, I generated the default configuration file:</p><pre>sudo containerd config default | sudo tee /etc/containerd/config.toml</pre><p>Then I updated the configuration to use <strong>systemd as the cgroup driver</strong>, which is the recommended setup for Kubernetes:</p><pre>sudo sed -i &#39;s/SystemdCgroup = false/SystemdCgroup = true/&#39; /etc/containerd/config.toml</pre><p>Finally, I restarted containerd:</p><pre>sudo systemctl restart containerd</pre><p>✔️ Using systemd cgroups avoids resource-management issues and ensures better compatibility with kubelet.</p><h4>🔹 5. Install Kubernetes Components</h4><p>Once the system was prepared, I installed the core Kubernetes tools on <strong>all nodes</strong>:</p><pre>sudo apt install -y kubeadm kubelet kubectl<br># To prevent accidental upgrades (which can break cluster compatibility), I held their versions:<br>sudo apt-mark hold kubeadm kubelet kubectl</pre><p>At the end of this section:</p><ul><li>All nodes were <strong>properly prepared</strong></li><li>Networking prerequisites were satisfied</li><li>Container runtime was configured correctly</li><li>Nodes were ready for <strong>kubeadm init</strong> and <strong>kubeadm join</strong></li></ul><p>This common node configuration is a <strong>critical foundation</strong> for a stable Kubernetes cluster.</p><h3>5️⃣ Kubernetes Cluster Initialization</h3><h4>🔹 Master Node Initialization</h4><p>On the master node, I initialized the Kubernetes control plane using kubeadm.</p><pre>sudo kubeadm init</pre><p>This command performs several critical tasks:</p><ul><li>Initializes the Kubernetes <strong>control plane</strong></li><li>Sets up <strong>etcd</strong>, API server, controller manager, and scheduler</li><li>Generates certificates and kubeconfig files</li></ul><h4>🔹 Configure kubectl for the Current User</h4><p>By default, the Kubernetes admin configuration file is created under /etc/kubernetes/admin.conf.<br> To interact with the cluster as a normal user, I copied this file to my home directory:</p><pre>mkdir -p $HOME/.kube<br>sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config<br>sudo chown $(id -u):$(id -g) $HOME/.kube/config</pre><h4>🔹 Generate Worker Node Join Command</h4><p>To allow worker nodes to join the cluster, I generated a join token using:</p><pre>kubeadm token create --print-join-command</pre><p>Output example:</p><pre>kubeadm join 192.168.0.10:6443 \<br>  --token abcdef.1234567890abcdef \<br>  --discovery-token-ca-cert-hash sha256:xxxxxxxx</pre><h4>🔹 Worker Node Setup</h4><p>On <strong>each worker node</strong>, I ran the join command that I generated earlier:</p><pre>sudo kubeadm join 192.168.0.10:6443 \<br>  --token abcdef.1234567890abcdef \<br>  --discovery-token-ca-cert-hash sha256:xxxxxxxx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*qanKhgAllqZAYpSVPy2UeQ.png" /><figcaption>Cluster Formation</figcaption></figure><h3>6️⃣ Networking: Calico CNI</h3><p>Without a CNI, pods cannot communicate.</p><p>I installed <strong>Calico</strong> <strong>CNI</strong> once from the master node:</p><pre>kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*7u-5dnT4_qYiNDJSaDuBNQ.jpeg" /></figure><p>Calico runs calico-node as a DaemonSet on every node to handle pod networking and enforces network policies, while calico-kube-controllers runs as a Deployment to manage control-plane related networking tasks.</p><p>After this:</p><pre>kubectl get nodes -o wide</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T4cVxKaxFOn9mWrmN-e42Q.png" /></figure><p>The cluster consists of 1 <strong>control-plane (master) node</strong> and <strong>3 worker nodes </strong>each node is configured with a static internal IP address.</p><p>🔹All nodes are in <strong>Ready</strong> state, which means:</p><ul><li>kubelet is running</li><li>networking (CNI — Calico) is working</li><li>nodes are able to run workloads</li></ul><h3>7️⃣ Application Deployment (3-Tier App)</h3><p>After setting up the Kubernetes cluster, I deployed a <strong>simple three-tier application</strong> to validate networking, service discovery, and persistent storage.</p><p>The application consists of:</p><ul><li><strong>Frontend (UI)</strong> — React-based web application</li><li><strong>Backend (API)</strong> — Node.js REST API</li><li><strong>MySQL (Database)</strong> — Stateful database with persistent storage</li></ul><p>The application follows a standard <strong>3-tier architecture</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*EGNtnbkQf7TJVUTr7DY4_Q.png" /><figcaption>Application Architecture</figcaption></figure><p>Each tier runs in its <strong>own Kubernetes workload</strong> and communicates using <strong>ClusterIP services</strong>.</p><h3>🔹 Kubernetes Objects Used</h3><p>To deploy this application, I used the following Kubernetes resources:</p><h4><strong>Deployments</strong></h4><ul><li>Frontend</li><li>Backend</li></ul><h4><strong>StatefulSet</strong></h4><ul><li>MySQL (database)</li></ul><h4><strong>Services (ClusterIP)</strong></h4><ul><li>Frontend service</li><li>Backend service</li><li>MySQL service</li></ul><h4><strong>PersistentVolumeClaim</strong></h4><ul><li>MySQL data persistence (backed by Longhorn)</li></ul><h3>🔹 Frontend Deployment (UI Layer)</h3><p>The frontend is a <strong>React application</strong> running inside a Docker container.<br> I deployed it using a <strong>Deployment</strong>, because it is <strong>stateless</strong> and can be scaled easily.</p><h4>How Frontend Connects to Backend</h4><ul><li>The frontend does <strong>not use hardcoded IPs</strong></li><li>It communicates with the backend using the <strong>backend service name</strong></li><li>Kubernetes DNS automatically resolves the service name to the correct pod IP</li></ul><p>Example:</p><pre>http://backend-service:5000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*ZJXQ9GVEFGJ6ZknT5bkQDg.png" /></figure><p>This ensures:</p><ul><li>No dependency on pod IPs</li><li>Seamless scaling and pod restarts</li></ul><h4>Frontend Manifest (Deployment + Service)</h4><p>In the frontend manifest:</p><ul><li>I defined a <strong>Deployment</strong> with required replicas</li><li>Exposed it using a <strong>ClusterIP service</strong></li><li>Passed the backend API URL as an <strong>environment variable</strong></li></ul><p>Key concepts used:</p><ul><li>env variables for configuration</li><li>labels and selectors for service-to-pod mapping</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*_U87g8myM0yQQqo7jAcKOg.png" /></figure><h3>🔹 Backend Deployment (API Layer)</h3><p>The backend is a <strong>Node.js API</strong> responsible for:</p><ul><li>Handling requests from the frontend</li><li>Communicating with the MySQL database</li><li>Business logic and authentication</li></ul><p>Since the backend is also <strong>stateless</strong>, I deployed it using a <strong>Deployment</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*pkupIb2isHzf1K3FkuT6CA.png" /></figure><h4>How Backend Connects to MySQL</h4><p>The backend connects to MySQL using:</p><ul><li><strong>MySQL service name</strong> (DNS-based service discovery)</li><li>Credentials provided via environment variables</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*4nim7ZeQW9xqJoeWQ_wpKA.png" /></figure><p>Example connection details used inside backend:</p><pre>DB_HOST=mysql<br>DB_USER=root<br>DB_NAME=crud_app</pre><p>Kubernetes automatically resolves mysql to the MySQL service IP.</p><h4>Backend Manifest Design</h4><p>In the backend manifest:</p><ul><li>I defined database connection details as <strong>environment variables</strong></li><li>Used a <strong>ClusterIP service</strong> to expose the backend internally</li><li>Ensured backend pods could restart without losing state</li></ul><p>This separation allowed me to:</p><ul><li>Change database or credentials without rebuilding the image</li><li>Scale backend pods independently</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*qeAWB2F1HDLxjjFNv04EOw.png" /></figure><h3>🔹 MySQL Deployment (Database Layer)</h3><p>The database is a <strong>stateful component</strong>, so I deployed MySQL using a <strong>StatefulSet</strong> instead of a Deployment.</p><h4>Why StatefulSet for MySQL?</h4><p>I chose a StatefulSet because</p><ul><li>MySQL requires <strong>stable network identity</strong></li><li>Data must persist even if the pod restarts</li><li>Each pod needs a <strong>dedicated persistent volume</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*_eF1OpkbxBiVN3GBf-LYaQ.png" /></figure><h4>Persistent Storage with PVC</h4><p><strong>For MySQL storage:</strong></p><ul><li>I created a <strong>PersistentVolumeClaim</strong></li><li>The PVC is dynamically provisioned by <strong>Longhorn</strong></li><li>Data remains intact even if the MySQL pod is deleted or rescheduled</li></ul><p><strong>Key benefits:</strong></p><ul><li>Safe database restarts</li><li>No data loss</li><li>Real production-like behavior</li></ul><h4>MySQL Service</h4><ul><li>I used a <strong>ClusterIP service</strong> for MySQL</li><li>Backend pods access MySQL internally using:</li></ul><pre>mysql:3306</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*ZHTcDIC8iGg1MoYJN72VRw.png" /></figure><p>This keeps the database:</p><ul><li>Private to the cluster</li><li>Secure from external access</li></ul><h4>🔹 Why I Used Deployment vs StatefulSet</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*235riVyI7EITkJpKWYBdoA.png" /></figure><p>This clear separation helped me understand <strong>when to use which Kubernetes object</strong>.</p><h4>🔹 Service Discovery &amp; Internal Networking</h4><p>Kubernetes DNS plays a key role in this setup:</p><ul><li>Services provide <strong>stable endpoints</strong></li><li>Pods can be replaced without breaking connectivity</li><li>No manual IP management required</li></ul><p>This allowed the entire application to communicate <strong>reliably and dynamically</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*2oH-r_n-sacDcRDtQwTo5g.png" /></figure><h3>8️⃣ Persistent Storage with Longhorn</h3><p>Because this is bare metal, I installed <strong>Longhorn</strong> for storage.</p><p>Why Longhorn?</p><ul><li>Cloud-agnostic</li><li>Distributed block storage</li><li>Perfect for on-prem labs</li></ul><h4>Installing Longhorn with kubectl</h4><ol><li>Install Longhorn on Kubernetes cluster using this command:</li></ol><pre>kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.10.1/deploy/longhorn.yaml</pre><p>One way to monitor the progress of the installation is to watch pods being created in the longhorn-system namespace:</p><pre>kubectl get pods --namespace longhorn-system --watch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*IkVORB2gTVSaGhZ4FYfp0A.png" /><figcaption>Longhorn Pods</figcaption></figure><p>2. To enable access to the Longhorn UI, we will need to set up an Ingress controller. Authentication to the Longhorn UI is not enabled by default.</p><p>🔹(Quick &amp; Safe): Port-Forward (Recommended for learning)</p><p><strong>Check NodePort</strong></p><pre>kubectl get svc longhorn-frontend -n longhorn-system</pre><h4>Command:</h4><pre>kubectl -n longhorn-system port-forward svc/longhorn-frontend 8080:80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*it1wxjZID0aa2DvghBhgrA.png" /></figure><h4>Access in browser:</h4><pre>http://localhost:8080</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*pLB0GmjH5lOq-LeXZv3QLQ.jpeg" /></figure><p>MySQL used a <strong>PVC backed by Longhorn</strong>.</p><h3>🔹 <strong>How MySQL Data Is Stored in Longhorn</strong></h3><h4>1️. Longhorn StorageClass</h4><p>When Longhorn is installed, it automatically creates a default StorageClass.</p><pre>kubectl get sc</pre><p>Output like:</p><pre>longhorn   (default)</pre><p>👉 This StorageClass means:</p><blockquote><em>“Whenever a PersistentVolumeClaim (PVC) is created, the volume will be provisioned by Longhorn.”</em></blockquote><p>This is how MySQL data gets stored persistently in Longhorn instead of the node’s local disk.</p><h4>2️. MySQL PersistentVolumeClaim (PVC)</h4><p>In the MySQL StatefulSet, we defined a PersistentVolumeClaim (PVC):</p><p>Example:</p><pre>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: mysql-pvc<br>spec:<br>  accessModes:<br>    - ReadWriteOnce<br>  storageClassName: longhorn<br>  resources:<br>    requests:<br>      storage: 15Gi</pre><p>This means:</p><ul><li><strong>15 GB of storage</strong> is requested</li><li><strong>Storage provider = Longhorn</strong></li></ul><h4>3️. PVC → PV → Longhorn Volume</h4><p>When the PVC is created:</p><ul><li>Kubernetes notifies the <strong>Longhorn CSI driver</strong></li><li>Longhorn dynamically creates a <strong>PersistentVolume (PV)</strong></li><li>The volume is created with <strong>replicas distributed across nodes</strong></li></ul><p>I can verify this using:</p><pre>kubectl get pvc<br>kubectl get pv</pre><p>Status:</p><pre>STATUS: Bound</pre><p>👉 This means the PVC has been successfully bound to a Longhorn-backed PersistentVolume.</p><h4>4️. MySQL Pod Volume Mount</h4><p>Inside the MySQL Pod, the volume is mounted as follows:</p><pre>volumeMounts:<br>- name: mysql-storage<br>  mountPath: /var/lib/mysql</pre><p>Volume definition:</p><pre>volumes:<br>- name: mysql-storage<br>  persistentVolumeClaim:<br>    claimName: mysql-pvc</pre><p>👉 This means the actual MySQL data path:</p><p><strong>/var/lib/mysql → Longhorn Volume</strong></p><h4>🔹 Result:</h4><p>What happens now?</p><ul><li>Pod restart → <strong>Data remains safe</strong></li><li>Node reboot → <strong>Volume automatically re-attaches</strong></li><li>MySQL Pod deletion → <strong>Data remains safe</strong></li><li>Volume is visible in the <strong>Longhorn UI</strong></li></ul><blockquote><em>“MySQL uses a PVC backed by Longhorn StorageClass, which dynamically provisions volumes and ensures data persistence even during pod or node failures.”</em></blockquote><h3>9️⃣ LoadBalancer for Bare Metal: MetalLB</h3><p>Cloud provides LoadBalancers automatically — bare metal doesn’t.</p><p>So I installed <strong>MetalLB</strong>.</p><h4>What MetalLB does</h4><ul><li>Assigns <strong>LAN IPs</strong> to Services</li><li>Mimics cloud LoadBalancer behavior</li></ul><h4>Installation by manifest</h4><p>To install MetalLB, apply the manifest:</p><pre>kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.15.3/config/manifests/metallb-native.yaml</pre><p>check:</p><pre>kubectl get pods -n metallb-system</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*S91HwcZEmKTL_AhQ9OkUuA.png" /></figure><h4>Layer 2 configuration</h4><p>Bare-metal Kubernetes does not have a cloud LoadBalancer, so MetalLB Layer-2 is used to announce an IP on the local network and allow external access to the cluster.</p><p>For example, the following configuration gives MetalLB control over IPs from 192.168.0.240 to 192.168.0.250, and configures Layer 2 mode:</p><pre>apiVersion: metallb.io/v1beta1<br>kind: IPAddressPool<br>metadata:<br>  name: first-pool<br>  namespace: metallb-system<br>spec:<br>  addresses:<br>  - 192.168.0.240-192.168.0.250</pre><pre>kubectl apply -f metallb-layer2.yaml</pre><h4>Purpose</h4><p>This file tells MetalLB:</p><blockquote><em>“These are the IP addresses I am allowed to use for LoadBalancer services.”</em></blockquote><h4>Explanation</h4><ul><li>192.168.0.240-192.168.0.250<br> → Must be <strong>free IPs in my VM / LAN network</strong></li><li>MetalLB will <strong>pick one IP</strong> from this range</li><li>That IP becomes the <strong>EXTERNAL-IP</strong> of my service</li></ul><p>Example IP:</p><pre>192.168.0.241</pre><h4><strong>Create L2Advertisement</strong></h4><pre>apiVersion: metallb.io/v1beta1<br>kind: L2Advertisement<br>metadata:<br>  name: default-l2<br>  namespace: metallb-system<br>spec:<br>  ipAddressPools:<br>  - default-pool</pre><pre>kubectl apply -f metallb-12.yaml</pre><h4>Purpose</h4><p>This file tells MetalLB:</p><blockquote><em>“Advertise (announce) these IPs on the network using Layer-2 (ARP).”</em></blockquote><h4>Explanation</h4><ul><li>MetalLB uses <strong>ARP (Address Resolution Protocol)</strong></li><li>One Kubernetes node says:</li></ul><p><em>-“Hey network, this IP belongs to me”</em></p><ul><li>Traffic sent to that IP reaches the node</li><li>Node forwards traffic → Service → Pod</li></ul><p>With this:<br> Network knows <strong>which node owns the LoadBalancer IP</strong></p><h3>🔟 Ingress NGINX (Traffic Entry Point)</h3><p>In a real production Kubernetes setup, we <strong>do not expose every service using LoadBalancer or NodePort</strong>.</p><p>Instead, we use <strong>Ingress</strong> as a <strong>single entry point</strong> to the cluster.</p><h4>🔹 Problem Before Ingress</h4><p>Initially:</p><ul><li>Frontend service was exposed using <strong>LoadBalancer</strong></li><li>MetalLB assigned an IP (e.g. 192.168.0.241)</li><li>Every service would need:</li></ul><p>— Its own LoadBalancer IP <strong>OR</strong></p><p>— Different ports</p><p>❌ This does <strong>not scale</strong><br> ❌ Not production-like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*nnjb9EmeDPxReaASJCHDLg.jpeg" /></figure><h4>Why Ingress NGINX?</h4><p>Ingress solves this by acting like a <strong>smart reverse proxy</strong>.</p><h4>Benefits:</h4><ul><li>✅<strong>Single entry IP</strong></li><li>✅ <strong>Path-based routing:</strong></li></ul><p>/ → frontend</p><p>/api → backend</p><ul><li>✅ <strong>Host-based routing:</strong></li></ul><p>app.likeminds.cloud</p><ul><li>✅ Same architecture used in <strong>cloud setups (EKS, GKE, AKS)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*W1hd1U3i-rsmL6z2-n7Qsw.jpeg" /><figcaption>Ingress Flow</figcaption></figure><p>👉 <strong>Ingress NGINX becomes the single traffic entry point</strong></p><p><strong>🔹 Step 1: Installing Ingress NGINX Controller</strong></p><p>I installed Ingress NGINX using the <strong>official Kubernetes manifest</strong>:</p><pre>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/baremetal/deploy.yaml</pre><p>🔹<strong> Step 2: Exposing Ingress Controller via MetalLB</strong></p><p>Configured an IP pool:</p><pre>192.168.0.240 – 192.168.0.250</pre><p>Then I <strong>changed the Ingress Controller Service</strong> to LoadBalancer.</p><pre>kubectl patch svc ingress-nginx-controller \<br>-n ingress-nginx \<br>-p &#39;{&quot;spec&quot;:{&quot;type&quot;:&quot;LoadBalancer&quot;}}&#39;</pre><p>Result:</p><pre>kubectl get svc -n ingress-nginx</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lqvvIUlQPZIhfZVKt99Kig.png" /></figure><p>✔ MetalLB assigned IP<br> ✔ Ingress is now reachable from LAN / Internet (via port forwarding)</p><p><strong>🔹 Step 3: Creating the Ingress Resource (Routing Rules)</strong></p><p>This is my <strong>actual Ingress manifest</strong>, cleaned and explained:</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: app-ingress<br>spec:<br>  ingressClassName: nginx<br>  rules:<br>  - host: app.likeminds.cloud<br>    http:<br>      paths:<br>      - path: /<br>        pathType: Prefix<br>        backend:<br>          service:<br>            name: frontend<br>            port:<br>              number: 80<br>      - path: /api<br>        pathType: Prefix<br>        backend:<br>          service:<br>            name: backend<br>            port:<br>              number: 5000</pre><pre>kubectl apply -f ingress.yaml</pre><p>What this means:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*4h4ekUXi3eM5u8ZIx1Uq1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*7yt7wledIDElXBDiABXngQ.jpeg" /></figure><h3>1️⃣1️⃣ Making the Application Live using TP-Link Router (Port Forwarding)</h3><p>After setting up <strong>Ingress NGINX</strong> inside the Kubernetes cluster, the application was still accessible <strong>only inside the LAN network</strong>.<br>To expose it to the <strong>internet</strong>, I configured <strong>port forwarding on my TP-Link router</strong>.</p><h4>🌐 Step 1: Identify Required IPs</h4><p><strong>1️. Public IP (WAN IP)</strong><br> Checked using:</p><pre>https://whatismyipaddress.com</pre><p><strong>2️. Ingress LoadBalancer IP (MetalLB)</strong></p><pre>kubectl get svc -n ingress-nginx</pre><h4>🔁 Step 2: Configure TP-Link Port Forwarding</h4><p>Router login:</p><pre>http://192.168.0.1</pre><p>Path:</p><p>Advanced → NAT Forwarding → Virtual Servers</p><h4>➕ Add Port Forwarding Rules</h4><p><strong>HTTP</strong></p><ul><li>External Port: 80</li><li>Internal IP: 192.168.0.240</li><li>Internal Port: 80</li></ul><p><strong>HTTPS</strong></p><ul><li>External Port: 443</li><li>Internal IP: 192.168.0.240</li><li>Internal Port: 443</li></ul><h4>🌍 Step 3: Domain Configuration</h4><p>A record:</p><p>app.likeminds.cloud → Public IP</p><h4>Final Traffic Flow</h4><p>User → Public IP → Router → Ingress → Services → Pods</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QWIlIWpBbJeXn9_1ykyA8Q.jpeg" /><figcaption>Final architecture diagram</figcaption></figure><h3>1️⃣2️⃣Horizontal Pod Autoscaling (HPA)</h3><p>After deploying my three-tier application, the next step was to make it <strong>auto-scalable</strong> based on load.<br>For this, I configured <strong>Horizontal Pod Autoscaling (HPA)</strong> for both the <strong>frontend and backend</strong>.</p><p>HPA automatically increases or decreases the number of pod replicas based on resource usage, such as CPU.</p><h4>Step 1️. Install Metrics Server</h4><p>HPA requires <strong>resource metrics</strong> (CPU / memory) to make scaling decisions.<br>By default, Kubernetes does not provide these metrics, so I installed the <strong>Metrics Server</strong>.</p><p>On the master node, I ran:</p><pre>kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.y</pre><p>Since this is a <strong>bare-metal / Hyper-V lab</strong>, I also updated the Metrics Server deployment to allow insecure TLS communication with kubelets:</p><pre>--kubelet-insecure-tls</pre><p>After installation, I verified that Metrics Server was working:</p><pre>kubectl get pods -n kube-system<br>kubectl top nodes<br>kubectl top pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*jccd-I-6CGJ12iHiP947Hg.png" /></figure><p>Once metrics started showing up, I confirmed that the cluster was ready for HPA.</p><h4>Step 2️. Add Resource Requests and Limits</h4><p>HPA only works if <strong>CPU requests</strong> are defined in the pod specification.<br> So I updated both <strong>frontend and backend deployments</strong> to include resource requests and limits.</p><p>Example configuration I added to the container spec:</p><pre>resources:<br>  requests:<br>    cpu: &quot;100m&quot;<br>    memory: &quot;128Mi&quot;<br>  limits:<br>    cpu: &quot;500m&quot;<br>    memory: &quot;256Mi&quot;</pre><p><strong>Why this is important:</strong></p><ul><li>requests.cpu is used by HPA as the baseline</li><li>Kubernetes knows how much CPU each pod needs</li><li>Scaling decisions become predictable and accurate</li></ul><p>After updating the manifests, I redeployed both applications.</p><h4>Step 3️. Create HPA (CPU-Based)</h4><p>Once metrics were available and resource requests were set, I created the <strong>Horizontal Pod Autoscaler</strong>.</p><p>For example, for the backend:</p><pre>kubectl autoscale deployment backend \<br>  --cpu-percent=50 \<br>  --min=1 \<br>  --max=5</pre><p>This means:</p><ul><li>If average CPU usage goes above <strong>50%</strong></li><li>Kubernetes automatically increases the number of pods</li><li>Minimum pods = 1</li><li>Maximum pods = 5</li></ul><p>I repeated the same process for the frontend deployment.</p><p>To verify the HPA:</p><pre>kubectl get hpa</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*nKmer-q0gbLzn-6SIJjNiw.png" /></figure><p>This showed current CPU usage and desired replica count.</p><h4>Step 4️. Load Testing the Application</h4><p>Instead of using complex external tools, I used a <strong>simple Kubernetes-native approach</strong> to generate continuous traffic inside the cluster.</p><p>I launched a temporary BusyBox pod and sent repeated HTTP requests to the frontend service.</p><pre>kubectl run fe-load --image=busybox --rm -it --restart=Never \<br>-- /bin/sh -c &quot;while true; do wget -q -O- http://frontend &gt;/dev/null; done&quot;</pre><h4>What This Command Does</h4><ul><li>Creates a <strong>temporary BusyBox pod</strong></li><li>Continuously sends HTTP requests to the frontend Kubernetes Service</li><li>Discards the response output to focus only on generating load</li><li>Runs in an infinite loop to sustain CPU pressure</li><li>Automatically deletes the pod once stopped (--rm)</li></ul><p>This setup effectively increases CPU utilization on the frontend pods.</p><h4>Observing Autoscaling Behavior</h4><p>While the load test was running, I monitored the HPA using:</p><pre>kubectl get hpa -w</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*Pn5m3zQyQwyio58fB5ZE1A.png" /></figure><p>During the test, I observed:</p><ul><li>CPU utilization exceeding the configured target (50%)</li><li>HPA increasing the number of frontend replicas automatically</li><li>Backend HPA remaining stable as expected</li></ul><p>Example observation:</p><pre>frontend-hpa   cpu: 136%/50%   replicas: 3</pre><p>This confirmed that <strong>HPA was successfully reacting to increased load</strong>.</p><p>I monitored Pod Scaling in Real Time using command:</p><pre>kubectl get pods -l app=frontend -w</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*3HkapYQFpkCjVXisYd0ZTw.png" /></figure><pre>kubectl get pods -l app=backend -w</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*bCBK-ht1oTBaHrhpOG6AQQ.png" /></figure><h3>1️⃣2️⃣ Validation, Testing &amp; Troubleshooting</h3><p>After configuring <strong>Ingress NGINX</strong>, <strong>MetalLB</strong>, <strong>Router Port Forwarding</strong>, and <strong>Domain DNS</strong>, the final step was to <strong>validate the setup</strong> and troubleshoot common issues.</p><h4>✅ Step 12.1: Verify Node &amp; Pod Health</h4><p>First, ensure all nodes and pods are healthy.</p><pre>kubectl get nodes<br>kubectl get pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*I3HhI2DP_KbHgBn1fUL-RA.jpeg" /></figure><p>Expected:</p><ul><li>All nodes → Ready</li><li>Application pods → Running</li></ul><h4>✅ Step 12.2: Verify Ingress Controller Service</h4><pre>kubectl get svc -n ingress-nginx</pre><p>Expected output:</p><pre>ingress-nginx-controller   LoadBalancer   192.168.0.240</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-ZLoYGlgVbvYkXbVKH_GQ.png" /></figure><p>✔ Confirms MetalLB assigned an IP<br> ✔ This IP must match router port forwarding target</p><h4>✅ Step 12.3: Verify Ingress Rules</h4><pre>kubectl get ingress<br>kubectl describe ingress app-ingress</pre><p>Check:</p><ul><li>Correct domain (app.likeminds.cloud)</li><li>Correct backend services</li><li>Correct paths (/ and /api)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*H7H7epVVOCB0zuemacCi_A.png" /></figure><h4>✅ Step 12.4: Test from Inside the Cluster</h4><pre>curl http://frontend<br>curl http://backend:5000</pre><p>✔ Confirms services work internally</p><h4>✅ Step 12.5: Test Ingress via LoadBalancer IP (LAN)</h4><pre>curl http://192.168.0.240<br>curl http://192.168.0.240/api</pre><p>✔ Confirms Ingress routing works<br> ✔ If this fails → Ingress config issue</p><h4>✅ Step 12.6: Test Using Domain (LAN)</h4><pre>curl http://app.likeminds.cloud<br>curl http://app.likeminds.cloud/api</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2N1csFagevy5nwN-hNWm6w.jpeg" /></figure><p>✔ Confirms DNS + Ingress routing</p><h4>🌍 Step 12.7: Test from Internet (Mobile / Outside Network)</h4><ul><li>Disabled Wi-Fi on phone</li><li>Use mobile data</li><li>Open:</li></ul><pre>http://likeminds.cloud</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UeNSsD-WiL62IT82EtkIFQ.jpeg" /></figure><p>✔ Confirms router port forwarding works<br> ✔ Confirms app is publicly accessible</p><h3>🛠 Common Issues &amp; Fixes</h3><h4>❌ Domain opens but shows 404</h4><p>✔ Ingress rule mismatch<br> ✔ Host/path not defined correctly</p><h4>❌ Works in LAN but not from internet</h4><p>✔ Port forwarding missing or wrong<br> ✔ ISP CGNAT blocking inbound traffic</p><h4>❌ Ingress ADDRESS keeps changing</h4><p>✔ Normal behaviour<br> ✔ Always use <strong>Ingress Service LoadBalancer IP</strong>, not pod IP</p><h4>❌ Backend /api returns 406</h4><p>✔ Backend expects JSON headers<br> ✔ Normal behaviour if browser sends plain request</p><h3>🧪 Final Proof Commands</h3><pre>kubectl get ingress<br>kubectl get svc -n ingress-nginx<br>curl http://app.likeminds.cloud</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MKgYlF7AuBpVG-VTrWGsdA.png" /></figure><h3>🎯 Outcome</h3><ul><li>Kubernetes cluster exposed without cloud</li><li>Production-like ingress setup</li><li>Real-world networking experience</li><li>Fully documented bare-metal POC</li></ul><p>“This validation step ensured my Kubernetes home lab behaves exactly like a cloud-hosted production setup.”</p><blockquote><em>This project helped me gain hands-on experience with running Kubernetes on bare metal in a real-world setup.</em></blockquote><blockquote><em>📂 </em><strong><em>Complete Kubernetes manifests and configurations are available on GitHub:</em></strong><em> </em><a href="https://github.com/AAKASHDEEP786/bare-metal-kubernetes"><em>https://github.com/AAKASHDEEP786/bare-metal-kubernetes</em></a></blockquote><p>LinkedIn: <a href="https://www.linkedin.com/in/aakash-deep-v16">https://www.linkedin.com/in/aakash-deep-v16</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da6e04fddd89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Production-Level Blue–Green Deployment]]></title>
            <link>https://medium.com/@akashdeep960/production-level-blue-green-deployment-ci-cd-pipeline-7897d4cba6d0?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/7897d4cba6d0</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[blue-green-deployment]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Wed, 10 Sep 2025 10:36:22 GMT</pubDate>
            <atom:updated>2026-03-16T11:32:32.248Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>A hands‑on walkthrough of how I built a production-ready Blue–Green CI/CD pipeline on AWS using Terraform, EKS (Kubernetes), Jenkins, SonarQube, and Nexus — finished with a zero‑downtime switch from Blue → Green.</em></blockquote><h3>Quick Summary</h3><ul><li>I provisioned infrastructure with <strong>Terraform</strong> (VPC, EKS cluster, EC2 instances for CI tools).</li><li>I installed <strong>Jenkins</strong>, <strong>SonarQube</strong>, and <strong>Nexus</strong> on separate EC2 instances and configured them for CI/CD.</li><li>I created Jenkins jobs (parameterized: DEPLOY_ENV=blue|green) that build, scan, push Docker images (to DockerHub), deploy to EKS, and Switch Traffic.</li><li>Blue and Green are two independent deployments in the cluster; traffic is switched by updating the Kubernetes <strong>Service selector</strong> (or Ingress) to point to the desired environment — achieving zero downtime.</li></ul><h3>What this post covers</h3><ol><li>Infrastructure provisioning (Terraform)</li><li>EKS cluster + kubectl config</li><li>EC2 instances for Jenkins / SonarQube / Nexus</li><li>Jenkins &amp; plugins setup, Docker permissions</li><li>RBAC for Jenkins (service account + cluster role binding)</li><li>Jenkins pipeline (Maven build, Sonar scan, Docker build/push, deploy, switch traffic)</li><li>Kubernetes manifests for Blue &amp; Green deployments and Service traffic switch</li><li>Verification, rollback, and practical tips</li></ol><h3>Architecture (visual)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*eGFzMlKxpPuWg74CG1PYtQ.png" /><figcaption><em>Architecture diagram</em></figcaption></figure><h3>Prerequisites</h3><ul><li>AWS account (IAM user with programmatic access)</li></ul><h3>Step 1— Launch an EC2 Virtual Machine (e.g., Server)</h3><h4><strong>Provision Infrastructure with Terraform</strong></h4><ul><li>Created a EC2 instance with security groups allowing SSH (22), HTTP (80), HTTPS (443), Jenkins (8080), SonarQube (9000), and Nexus (8081), and accessed the instance via SSH using a private key.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3mdB_QMGEueLb7JQSsHTAQ.png" /><figcaption>Security Group</figcaption></figure><ul><li>Install AWS CLI and Configure</li></ul><pre>curl &quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot; -o &quot;awscliv2.zip&quot;<br>unzip awscliv2.zip<br>sudo ./aws/install<br>#Use your Access Key and Secret Access Key to configure<br>aws configure</pre><ul><li>Install Terraform</li></ul><pre>Sudo snap install terraform --classic</pre><h3>Step 2— Create EKS cluster and kubeconfig</h3><ul><li>Clone git repository for VPC, Security Groups, IAM Roles &amp; Policies, EKS, and Node Group.</li></ul><pre>git clone https://github.com/AAKASHDEEP786/Blue-Green-Deployment.git<br>cd Blue-Green-Deployment/Cluster</pre><ul><li>Initialize Terraform, Preview Infrastructure and Apply Changes</li></ul><pre>terraform init<br>terraform plan <br>terraform apply --auto-approve</pre><p><em>Tip:</em> Ensure the variable has the same key name that was used during instance creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*9SW7erVlsIPBjhEvL2MLqg.png" /><figcaption>17 resources are going to create</figcaption></figure><h4>Install kubectl</h4><ul><li>kubectl is the command-line tool used to interact with Kubernetes clusters.</li></ul><pre>sudo snap install kubectl --classic</pre><ul><li>Run the following command to configure your kubeconfig file so that kubectl can connect to your EKS cluster:</li></ul><pre>aws eks update-kubeconfig --region &lt;region&gt; --name &lt;cluster-name&gt;</pre><ul><li>Verify: kubectl get nodes and kubectl get pods --all-namespaces.</li></ul><h3>Step 3— Create a Service Account, assign a Role, and generate a Secret with a Token</h3><ul><li>Creating a Namespace</li></ul><pre>kublectl create ns webapps</pre><ul><li>Creating Service Account</li></ul><pre>apiVersion: v1<br>kind: ServiceAccount<br>metadata:<br>  name: jenkins<br>  namespace: webapps</pre><ul><li>Create Role</li></ul><pre>apiVersion: rbac.authorization.k8s.io/v1<br>kind: Role<br>metadata:<br>  name: app-role<br>  namespace: webapps<br>rules:<br>  - apiGroups:<br>        - &quot;&quot;<br>        - apps<br>        - autoscaling<br>        - batch<br>        - extensions<br>        - policy<br>        - rbac.authorization.k8s.io<br>    resources:<br>      - pods<br>      - componentstatuses<br>      - configmaps<br>      - daemonsets<br>      - deployments<br>      - events<br>      - endpoints<br>      - horizontalpodautoscalers<br>      - ingress<br>      - jobs<br>      - limitranges<br>      - namespaces<br>      - nodes<br>      - secrets<br>      - pods<br>      - persistentvolumes<br>      - persistentvolumeclaims<br>      - resourcequotas<br>      - replicasets<br>      - replicationcontrollers<br>      - serviceaccounts<br>      - services<br>    verbs: [&quot;get&quot;, &quot;list&quot;, &quot;watch&quot;, &quot;create&quot;, &quot;update&quot;, &quot;patch&quot;, &quot;delete&quot;]</pre><ul><li>Bind the role to service account</li></ul><pre>apiVersion: rbac.authorization.k8s.io/v1<br>kind: RoleBinding<br>metadata:<br>  name: app-rolebinding<br>  namespace: webapps <br>roleRef:<br>  apiGroup: rbac.authorization.k8s.io<br>  kind: Role<br>  name: app-role <br>subjects:<br>- namespace: webapps <br>  kind: ServiceAccount<br>  name: jenkins </pre><ul><li>Apply all YAMLs</li></ul><pre>kubectl apply -f sa.yaml<br>kubectl apply -f role.yaml<br>kubectl apply -f rolebinding.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aYK3qcLhOa6EK_IvayI-w.png" /><figcaption>RBAC Created</figcaption></figure><ul><li>Generate token using service account in the namespace</li></ul><p><a href="https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#:~:text=To%20create%20a%20non%2Dexpiring,with%20that%20generated%20token%20data.">Create Token</a></p><pre>apiVersion: v1<br>kind: Secret<br>type: kubernetes.io/service-account-token<br>metadata:<br>  name: mysecretname<br>  annotations:<br>    kubernetes.io/service-account.name: jenkins</pre><pre>kubectl apply -f secret.yaml -n webapps<br>#kubectl describe secret: Shows detailed information about a Kubernetes Secret.<br>kubectl describe secret mysecretname -n webapps</pre><ul><li>Save the token for authentication</li></ul><h3>Step 4— EC2 instances for Jenkins, SonarQube, Nexus</h3><ul><li>Provisioned 3 EC2 instances (t2.medium or larger) with the same security group, and name them Jenkins, SonarQube, and Nexus.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VyL0yyUmupvaPfPWqPwNxw.jpeg" /><figcaption>EC2 Instances</figcaption></figure><h3>On the <strong>Jenkins server</strong></h3><ul><li>Install Java (OpenJDK 17+)</li></ul><p>Jenkins needs Java as a prerequisite because it’s written in Java and runs on the JVM.</p><pre>sudo apt install openjdk-17-jre-headless -y</pre><ul><li>Install Jenkins LTS (Long-Term Support)</li></ul><pre>sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \<br>  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key<br>echo &quot;deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc]&quot; \<br>  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \<br>  /etc/apt/sources.list.d/jenkins.list &gt; /dev/null<br>sudo apt-get update<br>sudo apt-get install jenkins</pre><p>Start Jenkins</p><pre>sudo systemctl enable jenkins<br>#You can start the Jenkins service with the command:<br>sudo systemctl start jenkins<br>#You can check the status of the Jenkins service using the command:<br>sudo systemctl status jenkins</pre><p>Access Jenkins at http://&lt;public_ip&gt;:8080 and get the default password from /var/jenkins_home/secrets/initialAdminPassword</p><ul><li>Set up Docker’s official GPG key</li></ul><pre># Add Docker&#39;s official GPG key:<br>sudo apt-get update<br>sudo apt-get install ca-certificates curl<br>sudo install -m 0755 -d /etc/apt/keyrings<br>sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc<br>sudo chmod a+r /etc/apt/keyrings/docker.asc<br><br># Add the repository to Apt sources:<br>echo \<br>  &quot;deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \<br>  $(. /etc/os-release &amp;&amp; echo &quot;${UBUNTU_CODENAME:-$VERSION_CODENAME}&quot;) stable&quot; | \<br>  sudo tee /etc/apt/sources.list.d/docker.list &gt; /dev/null<br>sudo apt-get update<br><br># Install Docker Engine, CLI, containerd, and plugins.<br>sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin</pre><p>Give Jenkins permission to run Docker by adding the jenkins user to the Docker group:</p><pre>sudo usermod -aG docker jenkins</pre><ul><li>Install Trivy (Container Security Scanner)</li></ul><pre>sudo apt-get install wget apt-transport-https gnupg lsb-release -y<br>wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -<br>echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/trivy.list<br>sudo apt-get update<br>sudo apt-get install trivy -y</pre><ul><li><strong>Install kubectl</strong></li></ul><pre>sudo snap install kubectl --classic</pre><h3>Step 5 — On the <strong>Nexus server</strong></h3><ul><li>Since we are going to run Nexus in a Docker container, we need to install Docker</li></ul><pre>sudo apt install docker.io -y</pre><ul><li>Add the ubuntu user to the Docker group so that the user can run Docker commands without using sudo</li></ul><pre>sudo usermod -aG docker ubuntu<br>#newgrp docker is a shortcut to apply the group change instantly.<br>newgrp docker</pre><ul><li>Run Sonatype Nexus 3 in a Docker container on port 8081</li></ul><pre>docker run -d --name nexus -p 8081:8081 sonatype/nexus3</pre><p>Access Nexus on http://&lt;public_ip&gt;:8081</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zWcs1V06q4ffWrS35_yf1Q.png" /><figcaption>Nexus Repository</figcaption></figure><p><strong>Default Username:</strong> admin | <strong>Password:</strong> stored inside the Nexus container at /nexus-data/admin.password</p><ul><li>To retrieve it:</li></ul><pre>docker exec -it &lt;container_id&gt; /bin/bash</pre><h3>Step 6— On the SonarQube server</h3><ul><li>We are going to run SonarQube in a container, so we need to install Docker and add the ubuntu user to the Docker group.</li></ul><pre>docker run -d --name sonarqube -p 9000:9000 sonarqube:lts-community</pre><p>Access SonarQube on http://&lt;public_ip&gt;:9000</p><p>Default Username &amp; Password: admin / admin</p><ul><li>Create Token for Jenkins Security&gt;Users&gt;Tokens (Save the token)</li><li>Create Webhook for Jenkins</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*rMmaXEoOKo8WTkENhJcycw.png" /><figcaption>SonarQube Webhook</figcaption></figure><h3>Step 7— Jenkins setup</h3><h4>Install Available Plugins for Jenkins</h4><blockquote>Required plugins:<br> SonarQube Scanner, Config File Provider, Maven &amp; Maven Integration, Pipeline: Stage View, Docker Pipeline, Kubernetes, Kubernetes CLI, Kubernetes Credentials, Kubernetes Client API</blockquote><p><strong>Manage Jenkins&gt;</strong></p><ul><li><strong>Configure credentials</strong>: Kubernetes, GitHub, DockerHub, SonarQube token, Nexus credentials.</li><li><strong>System Configuration: </strong>SonarQube Servers</li><li><strong>Tools Configuration: </strong>Maven, SonarQube Scanner</li></ul><h4><strong>Setting up Nexus repository integration in Jenkins</strong></h4><ul><li>Go to Managed Files, add a new configuration, and select Global Maven settings.xml (This step is done to provide Jenkins with Maven configuration globally<strong>)</strong></li></ul><p>Add Credential for Nexus Server here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wl5EtXmw4MCgYWrOD0YpYg.jpeg" /><figcaption>Added Maven Release and Maven Snapshot repositories</figcaption></figure><ul><li>Update the pom.xml in the source repo with the Maven Release and Snapshot repository URLs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*XAMcCb68n-5FxEIOY7p2kA.jpeg" /><figcaption>pom.xml URL update</figcaption></figure><h3>Step 8— <strong>Create a new job-for example, Blue-Green-Deployment</strong></h3><ul><li><strong>Set these</strong> <strong>parameters for Blue/Green Deployment</strong></li><li>when we run a Jenkins pipeline, we want to control how the deployment behaves without editing the Jenkinsfile each time.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pxnyM1O8xEKPmF8wXbrBiQ.jpeg" /><figcaption><em>Blue/Green parameter</em></figcaption></figure><ul><li><strong>DEPLOY_ENV</strong> → A dropdown (choice) with options blue or green.<br> <em>Used to decide which environment (Blue or Green) the application should be deployed to.</em></li><li><strong>DOCKER_TAG</strong> → Another dropdown with options blue or green.<br> <em>Specifies which Docker image tag should be used during deployment.</em></li><li><strong>SWITCH_TRAFFIC</strong> → A checkbox (booleanParam).</li></ul><h3>Step 9— CI/CD Jenkinsfile (core parts)</h3><h4>Kubernetes Blue &amp; Green manifests (pattern)</h4><pre>stage(&#39;Deploy to Kubernetes&#39;) {<br>            steps {<br>                script {<br>                    def deploymentFile = &quot;&quot;<br>                    if (params.DEPLOY_ENV == &#39;blue&#39;) {<br>                        deploymentFile = &#39;app-deployment-blue.yml&#39;<br>                    } else {<br>                        deploymentFile = &#39;app-deployment-green.yml&#39;<br>                    }<br><br>                    withKubeConfig(caCertificate: &#39;&#39;, clusterName: &#39;skyopsx-cluster&#39;, contextName: &#39;&#39;, credentialsId: &#39;k8s-token&#39;, namespace: &#39;webapps&#39;, restrictKubeConfigAccess: false, serverUrl: &#39;https://C462FBBD35A02518BE8F035CB48354B4.gr7.ap-south-1.eks.amazonaws.com&#39;) {<br>                        sh &quot;kubectl apply -f ${deploymentFile} -n ${KUBE_NAMESPACE}&quot;<br>                    }<br>                }<br>            }<br>        }<br>        <br>        stage(&#39;Switch Traffic Between Blue &amp; Green Environment&#39;) {<br>            when {<br>                expression { return params.SWITCH_TRAFFIC }<br>            }<br>            steps {<br>                script {<br>                    def newEnv = params.DEPLOY_ENV<br><br>                    // Always switch traffic based on DEPLOY_ENV<br>                    withKubeConfig(caCertificate: &#39;&#39;, clusterName: &#39;skyopsx-cluster&#39;, contextName: &#39;&#39;, credentialsId: &#39;k8s-token&#39;, namespace: &#39;webapps&#39;, restrictKubeConfigAccess: false, serverUrl: &#39;https://C462FBBD35A02518BE8F035CB48354B4.gr7.ap-south-1.eks.amazonaws.com&#39;) {<br>                        sh &#39;&#39;&#39;<br>                            kubectl patch service bankapp-service -p &quot;{\\&quot;spec\\&quot;: {\\&quot;selector\\&quot;: {\\&quot;app\\&quot;: \\&quot;bankapp\\&quot;, \\&quot;version\\&quot;: \\&quot;&#39;&#39;&#39; + newEnv + &#39;&#39;&#39;\\&quot;}}}&quot; -n ${KUBE_NAMESPACE}<br>                        &#39;&#39;&#39;<br>                    }<br>                    echo &quot;Traffic has been switched to the ${newEnv} environment.&quot;<br>                }<br>            }<br>        }</pre><p>📌 <strong>Deploy to Kubernetes</strong><br> In this stage, Jenkins deploys the application into the Kubernetes cluster. Based on the parameter DEPLOY_ENV, it selects either the <strong>Blue</strong> or <strong>Green</strong> deployment file (app-deployment-blue.yml or app-deployment-green.yml). The selected manifest is then applied using kubectl, ensuring that the application version is deployed to the specified namespace (webapps) in the EKS cluster.</p><p>📌 <strong>Switch Traffic Between Blue &amp; Green Environment</strong><br> This stage handles the traffic routing between the Blue and Green environments. If the SWITCH_TRAFFIC parameter is enabled, Jenkins updates the bankapp-service Kubernetes Service by patching its selector. This ensures that the service routes traffic to the pods of the chosen environment (blue or green). In this way, the traffic can be switched safely without downtime, enabling <strong>Blue-Green Deployment</strong>.</p><p><strong>Traffic switch :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iJKuzgOWo4yy7oXnMNyC3Q.png" /><figcaption>Select parameters for Blue/Green</figcaption></figure><h3><strong>The flow of your Jenkins pipeline step by step:</strong></h3><ol><li><strong>Git Checkout</strong> → Pulls code from GitHub repo.</li><li><strong>Compile</strong> → Runs mvn compile.</li><li><strong>Tests</strong> → Executes mvn test (but with -DskipTests=true, so tests are skipped).</li><li><strong>Trivy FS Scan</strong> → Scans source code files for vulnerabilities.</li><li><strong>SonarQube Analysis</strong> → Runs SonarQube static code analysis.</li><li><strong>Quality Gate Check</strong> → Waits for SonarQube quality gate results.</li><li><strong>Build</strong> → Packages the Java application (mvn package).</li><li><strong>Publish Artifact To Nexus</strong> → Deploys the built artifact (JAR/WAR) to Nexus repository.</li><li><strong>Docker Build &amp; Tag Image</strong> → Builds a Docker image and tags it (blue or green).</li><li><strong>Docker Image Scan</strong> → Scans Docker image using Trivy.</li><li><strong>Docker Push Image</strong> → Pushes the image to DockerHub registry.</li><li><strong>Deploy MySQL Deployment &amp; Service</strong> → Deploys MySQL resources on Kubernetes.</li><li><strong>Deploy SVC-APP</strong> → Ensures bankapp-service exists; if not, it creates it.</li><li><strong>Deploy to Kubernetes</strong> → Deploys the app to Kubernetes using either app-deployment-blue.yml or app-deployment-green.yml depending on DEPLOY_ENV.</li><li><strong>Switch Traffic (optional)</strong> → If SWITCH_TRAFFIC=true, updates the service selector to point traffic to the chosen environment (blue or green).</li><li><strong>Verify Deployment</strong> → Checks running pods and service details to confirm deployment.</li></ol><p>👉<strong> So overall, the flow is:</strong><br> <strong>Code → Compile → Scan → Build → Store artifact → Dockerize → Push → K8s Deploy (Blue/Green) → Optional Traffic Switch → Verify.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*URpTljVg-ZEPmCYemKdk2A.png" /><figcaption><em>CI/CD Pipeline Stage View</em></figcaption></figure><p><strong>Zero-downtime tips:</strong></p><ul><li>Deploy Blue, wait for pods to be Ready, then switch Service.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*mXHnd4tohDKNPHd3MDDvjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*VBp31c30ZQV1qhAmcNwoOA.png" /><figcaption>Blue/Green Deployment</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oT85YE7AfFMlk3w5kUyPPw.png" /><figcaption>Loadbalancer URL</figcaption></figure><h3>Step 10 — Verification &amp; rollback</h3><ul><li>Verify endpoints: curl http://&lt;LB-DNS&gt;/health or visit the app.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Pc71JnD7JcyzolPNGbaDQ.png" /><figcaption>website UI interface</figcaption></figure><ul><li>To rollback, switch Service selector back to previous env or re-deploy previous image.</li><li>Keep logs and Sonar/Nexus artifacts for traceability.</li></ul><h3>Lessons learned &amp; best practices</h3><ul><li>Always pre-warm the Green environment and use readiness probes.</li><li>Keep secrets in Kubernetes Secrets or a secret manager.</li><li>Limit RBAC permissions; don’t use cluster-admin in production.</li><li>Use unique image tags (immutable tags) and avoid latest.</li></ul><p>You can check out the complete code setup on [<a href="https://github.com/AAKASHDEEP786/Blue-Green-Deployment.git">GitHub</a>]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7897d4cba6d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Full DevSecOps + GitOps Amazon Clone Project with Jenkins, Docker, Kubernetes & ArgoCD]]></title>
            <link>https://medium.com/@akashdeep960/full-devsecops-gitops-amazon-clone-project-with-jenkins-docker-kubernetes-argocd-1b11a98ab99e?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b11a98ab99e</guid>
            <category><![CDATA[route-53]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[amazon-clone-app]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Wed, 03 Sep 2025 19:38:36 GMT</pubDate>
            <atom:updated>2025-09-03T19:57:56.985Z</atom:updated>
            <content:encoded><![CDATA[<p>This post walks you through a <strong>step-by-step DevSecOps + GitOps pipeline</strong> using a Node.js <strong>Amazon Clone</strong> project. We’ll integrate Jenkins, Docker, SonarQube, Prometheus, Grafana, EKS, ALB Ingress, and ArgoCD for a production-ready workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*13sDLrvW-MRHrcsVfPnQjw.jpeg" /><figcaption>Architecture Diagram</figcaption></figure><h3>⚙️ Prerequisites</h3><ul><li>Ubuntu/Debian system</li><li>sudo privileges</li><li>AWS account</li></ul><h3>🔑 Ports to Enable in Security Group</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*RahxYxSI8qxVf8h-MQM0Nw.png" /><figcaption>Security Group</figcaption></figure><h3>🖥️ System Update &amp; Common Packages</h3><pre>sudo apt update &amp;&amp; sudo apt upgrade -y<br>sudo apt install -y bash-completion wget git zip unzip curl jq net-tools build-essential ca-certificates apt-transport-https gnupg fontconfig<br>source /etc/bash_completion</pre><p>Install latest Git:</p><pre>sudo add-apt-repository ppa:git-core/ppa<br>sudo apt update<br>sudo apt install git -y</pre><h3>☕ Install Java (JDK 17 or 21)</h3><pre>sudo apt install -y openjdk-17-jdk<br># OR<br>sudo apt install -y openjdk-21-jdk<br>java --version</pre><h3>🔧 Install Jenkins</h3><p>Official docs: <a href="https://www.jenkins.io/doc/book/installing/linux/">Jenkins Installation Guide</a></p><pre>sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key<br>echo &quot;deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/&quot; | sudo tee /etc/apt/sources.list.d/jenkins.list &gt; /dev/null</pre><pre>sudo apt update<br>sudo apt install -y jenkins<br>sudo systemctl enable --now jenkins</pre><p>Initial admin password:</p><pre>sudo cat /var/lib/jenkins/secrets/initialAdminPassword</pre><p>Access Jenkins: <a href="http://your-server-ip:8080/">http://your-server-ip:8080</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2QgtxPeyesvKCziBTTF1qQ.png" /><figcaption>Jenkins unlock page</figcaption></figure><h3>🐳 Install Docker</h3><p>Official docs: <a href="https://docs.docker.com/engine/install/ubuntu/">Docker Installation Guide</a></p><pre>sudo apt-get update<br>sudo apt-get install ca-certificates curl -y<br>sudo install -m 0755 -d /etc/apt/keyrings<br>sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc<br>sudo chmod a+r /etc/apt/keyrings/docker.asc</pre><pre>echo &quot;deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] <a href="https://download.docker.com/linux/ubuntu">https://download.docker.com/linux/ubuntu</a> $(. /etc/os-release &amp;&amp; echo \&quot;${UBUNTU_CODENAME:-$VERSION_CODENAME}\&quot;) stable&quot; | sudo tee /etc/apt/sources.list.d/docker.list &gt; /dev/null</pre><pre>sudo apt-get update<br>sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin</pre><p>Add User(ubuntu) to docker group:</p><pre>sudo usermod -aG docker $USER<br>newgrp docker<br>docker ps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nOY9Qlr3vhF0gQvS3SBVwA.png" /><figcaption>Enable Docker for ubuntu user</figcaption></figure><p>Jenkins needs Docker access:</p><pre>sudo usermod -aG docker jenkins<br>sudo systemctl restart jenkins</pre><p>Check Docker status:</p><pre>sudo systemctl status docker</pre><h3>🔍 Install Trivy (Vulnerability/Security Scanner)</h3><p>Official docs: <a href="https://trivy.dev/v0.65/getting-started/installation/">Trivy</a></p><pre>wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -<br>echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list<br>sudo apt-get update<br>sudo apt-get install -y trivy<br>trivy --version</pre><h3>📊 Install Prometheus</h3><p><a href="https://prometheus.io/download/">Prometheus Download Page</a></p><p>Create system user &amp; install:</p><pre>sudo useradd --system --no-create-home --shell /usr/sbin/nologin prometheus<br>wget -O prometheus.tar.gz &quot;https://github.com/prometheus/prometheus/releases/download/v3.5.0/prometheus-3.5.0.linux-amd64.tar.gz&quot;<br>tar -xvf prometheus.tar.gz<br>cd prometheus-*/<br>sudo mkdir -p /data /etc/prometheus<br>sudo mv prometheus promtool /usr/local/bin/<br>sudo mv consoles/ console_libraries/ /etc/prometheus/<br>sudo mv prometheus.yml /etc/prometheus/prometheus.yml<br>sudo chown -R prometheus:prometheus /etc/prometheus /data</pre><p>Systemd service config: /etc/systemd/system/prometheus.service</p><ul><li>The reason we create a systemd service file for Prometheus is to make it run as a proper background service (daemon) on Linux.</li></ul><pre>sudo nano /etc/systemd/system/prometheus.service</pre><pre>[Unit]<br>Description=Prometheus<br>Wants=network-online.target<br>After=network-online.target</pre><pre>[Service]<br>User=prometheus<br>Group=prometheus<br>Type=simple<br>Restart=on-failure<br>RestartSec=5s<br>ExecStart=/usr/local/bin/prometheus \<br>  --config.file=/etc/prometheus/prometheus.yml \<br>  --storage.tsdb.path=/data \<br>  --web.console.templates=/etc/prometheus/consoles \<br>  --web.console.libraries=/etc/prometheus/console_libraries \<br>  --web.listen-address=0.0.0.0:9090</pre><pre>[Install]<br>WantedBy=multi-user.target[Unit]<br>Description=Prometheus<br>Wants=network-online.target<br>After=network-online.target</pre><p>Enable &amp; start:</p><pre>sudo systemctl daemon-reload<br>sudo systemctl enable --now prometheus<br>sudo systemctl start prometheus<br>sudo systemctl status prometheus</pre><p>Enable &amp; access Prometheus at <a href="http://ip:9090/">http://ip:9090</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kCMnTMMMb2l11nhS2STsA.png" /><figcaption>Prometheus Dashboard</figcaption></figure><h3>📡 Install Node Exporter</h3><pre>sudo useradd --system --no-create-home --shell /usr/sbin/nologin node_exporter<br>wget -O node_exporter.tar.gz &quot;https://github.com/prometheus/node_exporter/releases/download/v1.9.1/node_exporter-1.9.1.linux-amd64.tar.gz&quot;<br>tar -xvf node_exporter.tar.gz<br>sudo mv node_exporter-*/node_exporter /usr/local/bin/</pre><p>Systemd config: /etc/systemd/system/node_exporter.service</p><ul><li>We run this so that Prometheus can collect server metrics continuously, even after reboot, without manual effort.</li></ul><pre>sudo nano /etc/systemd/system/node_exporter.service</pre><pre>[Unit]<br>Description=Node Exporter<br>Wants=network-online.target<br>After=network-online.target<br><br>[Service]<br>User=node_exporter<br>Group=node_exporter<br>Type=simple<br>Restart=on-failure<br>ExecStart=/usr/local/bin/node_exporter --collector.logind<br><br>[Install]<br>WantedBy=multi-user.target</pre><p>Add scrape config in /etc/prometheus/prometheus.yml:</p><ul><li>Prometheus knows to scrape Node Exporter (system metrics) and Jenkins (CI/CD metrics).<br> This way, both your server health and your Jenkins pipeline health are monitored in Grafana/Prometheus dashboards.</li></ul><pre>sudo nano /etc/prometheus/prometheus.yml</pre><pre>- job_name: &quot;node_exporter&quot;<br>    static_configs:<br>      - targets: [&quot;&lt;ip&gt;:9100&quot;]</pre><pre>- job_name: &quot;jenkins&quot;<br>    metrics_path: /prometheus<br>    static_configs:<br>      - targets: [&quot;&lt;jenkins-ip&gt;:8080&quot;]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0FCYBDS92Uw36CkCRiSD6w.png" /><figcaption>Prometheus scrape config</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BvYqMINjgufzz6exCdzqEQ.png" /><figcaption>Prometheus Metrics</figcaption></figure><h3>📈 Install Grafana</h3><p><a href="https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/">Grafana Docs</a></p><pre>sudo apt-get install -y apt-transport-https software-properties-common wget<br><br>sudo mkdir -p /etc/apt/keyrings/<br>wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg &gt; /dev/null<br><br>echo &quot;deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main&quot; | sudo tee -a /etc/apt/sources.list.d/grafana.list<br><br>sudo apt-get update<br>sudo apt-get install -y grafana<br><br>sudo systemctl daemon-reload<br>sudo systemctl enable --now grafana-server<br>sudo systemctl start grafana-server<br>sudo systemctl status grafana-server</pre><p>Access Grafana at <a href="http://ip:3000/">http://ip:3000</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gShW3m5VMURXPkjAo3AsSw.png" /><figcaption>Grafana Dashboard</figcaption></figure><p>Import dashboards:</p><ul><li>Node_Exporter 1860 Docs: <a href="https://grafana.com/grafana/dashboards/1860-node-exporter-full/">https://grafana.com/grafana/dashboards/1860-node-exporter-full/</a></li><li>jenkins 9964 Docs: <a href="https://grafana.com/grafana/dashboards/9964-jenkins-performance-and-health-overview/">https://grafana.com/grafana/dashboards/9964-jenkins-performance-and-health-overview/</a></li><li>kubernetes 18283 Docs: <a href="https://grafana.com/grafana/dashboards/18283-kubernetes-dashboard/">https://grafana.com/grafana/dashboards/18283-kubernetes-dashboard/</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfCcxkmohS0JKe4-uaKXVg.png" /><figcaption>Adding Grafana Dashboards</figcaption></figure><h3>🔌 Jenkins Plugins to Install</h3><ul><li>Eclipse Temurin installer Plugin</li><li>NodeJS</li><li>Email Extension Plugin</li><li>OWASP Dependency-Check Plugin</li><li>Pipeline: Stage View Plugin</li><li>SonarQube Scanner for Jenkins</li><li>Prometheus metrics plugin</li><li>Docker API Plugin</li><li>Docker Commons Plugin</li><li>Docker Pipeline</li><li>Docker plugin</li><li>docker-build-step</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xQTJOA78qnzm3kQv9xafBA.png" /><figcaption>Jenkins Plugins</figcaption></figure><h3>🧪 SonarQube Container</h3><p>SonarQube Docker Container Run for Analysis</p><pre>docker run -d --name sonarqube \<br>  -p 9000:9000 \<br>  -v sonarqube_data:/opt/sonarqube/data \<br>  -v sonarqube_logs:/opt/sonarqube/logs \<br>  -v sonarqube_extensions:/opt/sonarqube/extensions \<br>  sonarqube:lts-community</pre><p>Access SonarQube at <a href="http://ip:9000/">http://ip:9000</a></p><ul><li>Create SonarQube Token and SonarQube Webhook for Jenkins. when Jenkins triggers a SonarQube scan, SonarQube will call Jenkins webhook after analysis is complete.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bfAMqRZJTNjdz8TjZEto9A.png" /><figcaption>SonarQube Webhook for Jenkins</figcaption></figure><h3>Jenkins Tools Configuration</h3><ul><li>JDK</li><li>SonarQube Scanner installations [sonar-scanner]</li><li>Node</li><li>Dependency-Check installations [dp-check]</li><li>Maven installations</li><li>Docker installations</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*V9p5oLb8ZZEamzNZfxHesw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*DzvaaICu_gKkDacJyCHECw.png" /><figcaption>Jenkins Tools Configuration</figcaption></figure><h3>🔑 Jenkins Credentials to Configure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HDotPLA4hAkf9UxTLsiU0A.png" /><figcaption>Jenkins Global Credentials</figcaption></figure><h3>Jenkins System Configuration</h3><p>SonarQube servers:</p><ul><li>Name: sonar-server</li><li>URL: <a href="http://:9000">http://ip:9000</a></li><li>Credentials: Add from Jenkins credentials</li></ul><p>Extended E-mail Notification:</p><ul><li>SMTP server: smtp.gmail.com</li><li>SMTP Port: 465</li><li>Use SSL</li><li>Default user e-mail suffix: @gmail.com</li></ul><p>E-mail Notification:</p><ul><li>SMTP server: smtp.gmail.com</li><li>Default user e-mail suffix: @gmail.com</li><li>Use SMTP Authentication: Yes</li><li>User Name: <a href="/service/mailto:example@gmail.com">akashdeep960@gmail.com</a></li><li>Password: Use credentials</li><li>Use TLS: Yes</li><li>SMTP Port: 587</li><li>Reply-To Address: <a href="/service/mailto:example@gmail.com">akashdeep960@gmail.com</a></li></ul><h3>☁️ EKS Setup with ALB Ingress</h3><h3>1. Install AWS CLI</h3><p>Refer: <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI Installation Guide</a></p><pre>curl &quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot; -o &quot;awscliv2.zip&quot;<br>unzip awscliv2.zip<br>sudo ./aws/install</pre><h3>2. Install kubectl</h3><p>Refer: <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/">kubectl Installation Guide</a></p><pre>sudo apt-get update<br># apt-transport-https may be a dummy package; if so, you can skip that package<br>sudo apt-get install -y apt-transport-https ca-certificates curl gnupg<br><br># If the folder `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.<br># sudo mkdir -p -m 755 /etc/apt/keyrings<br>curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg<br>sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg # allow unprivileged APT programs to read this keyring<br><br># This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list<br>echo &#39;deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.33/deb/ /&#39; | sudo tee /etc/apt/sources.list.d/kubernetes.list<br>sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list   # helps tools such as command-not-found to work correctly<br><br>sudo apt-get update<br>sudo apt-get install -y kubectl bash-completion<br><br># Enable kubectl auto-completion<br>echo &#39;source &lt;(kubectl completion bash)&#39; &gt;&gt; ~/.bashrc<br>echo &#39;alias k=kubectl&#39; &gt;&gt; ~/.bashrc<br>echo &#39;complete -F __start_kubectl k&#39; &gt;&gt; ~/.bashrc<br><br># Apply changes immediately<br>source ~/.bashrc</pre><h3>3. Install eksctl</h3><p>Refer: <a href="https://eksctl.io/installation/">eksctl Installation Guide</a></p><pre># for ARM systems, set ARCH to: `arm64`, `armv6` or `armv7`<br>ARCH=amd64<br>PLATFORM=$(uname -s)_$ARCH<br><br>curl -sLO &quot;https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz&quot;<br><br># (Optional) Verify checksum<br>curl -sL &quot;https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt&quot; | grep $PLATFORM | sha256sum --check<br><br>tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp &amp;&amp; rm eksctl_$PLATFORM.tar.gz<br><br>sudo install -m 0755 /tmp/eksctl /usr/local/bin &amp;&amp; rm /tmp/eksctl<br><br># Install bash completion<br>sudo apt-get install -y bash-completion<br><br># Enable eksctl auto-completion<br>echo &#39;source &lt;(eksctl completion bash)&#39; &gt;&gt; ~/.bashrc<br>echo &#39;alias e=eksctl&#39; &gt;&gt; ~/.bashrc<br>echo &#39;complete -F __start_eksctl e&#39; &gt;&gt; ~/.bashrc<br><br># Apply changes immediately<br>source ~/.bashrc</pre><h3>4. Install Helm</h3><p>Refer: <a href="https://helm.sh/docs/intro/install/">Helm Installation Guide</a></p><pre>curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg &gt; /dev/null<br>sudo apt-get install apt-transport-https --yes<br>echo &quot;deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main&quot; | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list<br>sudo apt-get update<br>sudo apt-get install -y helm bash-completion<br><br># Enable Helm auto-completion<br>echo &#39;source &lt;(helm completion bash)&#39; &gt;&gt; ~/.bashrc<br>echo &#39;alias h=helm&#39; &gt;&gt; ~/.bashrc<br>echo &#39;complete -F __start_helm h&#39; &gt;&gt; ~/.bashrc<br><br># Apply changes immediately<br>source ~/.bashrc</pre><h3>5. AWS CLI Configuration</h3><pre>aws configure<br>aws configure list</pre><h3>6. Create EKS Cluster</h3><pre>eksctl create cluster \<br>  --name my-cluster \<br>  --region ap-south-1 \<br>  --version 1.33 \<br>  --without-nodegroup</pre><pre>eksctl create nodegroup \<br>  --cluster my-cluster \<br>  --name my-nodes-ng \<br>  --nodes 2 --nodes-min 2 --nodes-max 6 \<br>  --node-type t3.medium</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*njIgNNi8HuPejzIEXHwNxA.png" /><figcaption>EKS Cluster with Nodes</figcaption></figure><h3>7. Update kubeconfig</h3><ul><li>This command links your local kubectl with your EKS cluster so you can manage it directly from your terminal.</li></ul><pre>aws eks update-kubeconfig --name my-cluster --region ap-south-1</pre><h3>8. Associate IAM OIDC Provider</h3><ul><li>We associate the IAM OIDC provider so that EKS can use IRSA (IAM Roles for Service Accounts). This allows Kubernetes pods to assume IAM roles securely and get AWS permissions without exposing credentials.</li></ul><pre>eksctl utils associate-iam-oidc-provider --cluster my-cluster --approve</pre><h3>9. Create IAM Policy for AWS Load Balancer Controller</h3><p>New policy link: <a href="https://docs.aws.amazon.com/eks/latest/userguide/lbc-manifest.html">AWS EKS LBC Policy</a></p><ul><li>We create this IAM policy because the AWS Load Balancer Controller pod in EKS needs specific AWS API permissions to create/manage load balancers.<br> This policy defines those permissions, and later we attach it to the IAM ServiceAccount so the controller can work securely.</li></ul><pre>curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.13.3/docs/install/iam_policy.json<br><br>aws iam create-policy \<br>  --policy-name AWSLoadBalancerControllerIAMPolicy \<br>  --policy-document file://iam_policy.json</pre><h3>10. Create IAM Service Account</h3><ul><li>We create this IAM ServiceAccount so the AWS Load Balancer Controller pod in EKS can securely call AWS APIs (create/manage load balancers) using IAM permissions, without giving permissions to the whole worker node.</li></ul><p>Replace &lt;ACCOUNT_ID&gt; with your AWS account ID.</p><pre>eksctl create iamserviceaccount \<br>  --cluster=my-cluster \<br>  --namespace=kube-system \<br>  --name=aws-load-balancer-controller \<br>  --attach-policy-arn=arn:aws:iam::&lt;ACCOUNT_ID&gt;:policy/AWSLoadBalancerControllerIAMPolicy \<br>  --override-existing-serviceaccounts \<br>  --region ap-south-1 \<br>  --approve</pre><h3>11. Install AWS Load Balancer Controller via Helm</h3><pre>helm repo add eks https://aws.github.io/eks-charts<br>helm repo update eks<br><br>helm install aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system \<br>  --set clusterName=my-cluster \<br>  --set serviceAccount.create=false \<br>  --set serviceAccount.name=aws-load-balancer-controller \<br>  --set region=ap-south-1 \<br>  --version 1.13.3</pre><p>Verify installation:</p><pre>kubectl get deployment -n kube-system aws-load-balancer-controller</pre><h3>12. Create and Set Namespace for Your Application</h3><pre><br>git clone https://github.com/AAKASHDEEP786/amazon-Devsecops.git<br>cd amazon-Devsecops/k8s-80<br><br>kubectl apply -f .<br>kubectl config set-context --current --namespace=amazon-ns<br>kubectl get ingress -w<br>kubectl delete -f .</pre><h3>Monitor Kubernetes with Prometheus</h3><p>Add to /etc/prometheus/prometheus.yml:</p><pre>sudo nano /etc/prometheus/prometheus.yml</pre><pre>  - job_name: &#39;k8s&#39;<br>    metrics_path: &#39;/metrics&#39;<br>    static_configs:<br>      - targets: [&#39;node1Ip:9100&#39;]</pre><ul><li>Docs: <a href="https://grafana.com/grafana/dashboards/17119-kubernetes-eks-cluster-prometheus/">https://grafana.com/grafana/dashboards/17119-kubernetes-eks-cluster-prometheus/</a> ID FOR EKS 17119</li></ul><p>Validate config:</p><pre>promtool check config /etc/prometheus/prometheus.yml<br>sudo systemctl restart  prometheus.service</pre><h3>🔄 Install ArgoCD (GitOps)</h3><p>Argocd installation via helm chart</p><pre>helm repo add argo https://argoproj.github.io/argo-helm<br>helm repo update<br>kubectl create namespace argocd<br>helm install argocd argo/argo-cd --namespace argocd<br>kubectl patch svc argocd-server -n argocd -p &#39;{&quot;spec&quot;: {&quot;type&quot;: &quot;LoadBalancer&quot;}}&#39;</pre><p>Get ArgoCD password:</p><pre>kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=&quot;{.data.password}&quot; | base64 -d</pre><p>Access ArgoCD: http://&lt;LB-URL&gt;</p><p><strong>Create a Project using ArgoCD Web UI</strong></p><ul><li>Open ArgoCD UI → https://&lt;argocd-server-ip&gt;</li><li>Log in (default: admin / &lt;initial-password&gt; from argocd-initial-admin-secret).</li><li>Go to <strong>Projects</strong> → <strong>New Project</strong>.</li></ul><p>Fill details:</p><ul><li><strong>Name</strong>: amazon-project</li><li><strong>Description</strong>: e.g. My amazon-clone project</li><li><strong>Source Repos</strong>: Add Git repo URL (or *)</li><li><strong>Destinations</strong>: Add cluster URL + namespace (or *)</li><li><strong>Namespaces</strong>: amazon-ns</li><li>Save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RzTAo3yp1I1MmkRN5kXryg.png" /><figcaption>Adding ArgoCD Project</figcaption></figure><h3>Setup <strong>Route53 with HTTPS</strong></h3><h4>🔹 1. Register or Use a Domain</h4><ul><li>Either buy/register a domain in <strong>Route53</strong> or transfer it.</li></ul><h4>🔹 2. Create a Hosted Zone in Route53</h4><ol><li>Open <strong>Route53 Console → Hosted Zones → Create Hosted Zone</strong>.</li><li>Enter your domain name (e.g., devopshackarena.xyz).</li><li>Copy the <strong>NS records</strong> and update them in your domain registrar.</li></ol><h4>🔹 3. Point Your Domain to Your Server / Load Balancer</h4><ul><li>Create a <strong>Record Set (A or CNAME)</strong>:</li><li>For EC2/ALB/NLB → Add an <strong>A record</strong> pointing to the IP or load balancer DNS.</li><li>For services behind CloudFront → Add a <strong>CNAME</strong> pointing to CloudFront distribution.</li></ul><p>Example:</p><ul><li>A record → amazon.devopshackarena.xyz → ALB DNS name</li><li>CNAME record → www.devopshackarena.xyz → CloudFront distribution</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_vzWph78ScZwjSOLNQsIXw.png" /></figure><h4>🔹 4. Get an SSL Certificate</h4><p>Use AWS Certificate Manager (ACM) to request a free certificate:</p><pre>AWS Console → Certificate Manager → Request Certificate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKasMW9P2dsfFChfStNfBA.png" /><figcaption>SSL Certificate</figcaption></figure><p>Once you finish the Route53 + ACM + Load Balancer, your app becomes accessible with HTTPS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*csnDOJ86VvyJRs3MlFogJw.png" /><figcaption>Amazon UI</figcaption></figure><h3>🧹 Cleanup</h3><pre>eksctl delete cluster --name my-cluster --region ap-south-1</pre><h3>📌 Final Thoughts</h3><p>With this setup, you now have a <strong>complete CI/CD + Security + Monitoring + GitOps pipeline</strong> for a Node.js Amazon Clone project. 🎉</p><p>You can check out the complete code setup on [<a href="https://github.com/AAKASHDEEP786/amazon-Devsecops">GitHub</a>]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b11a98ab99e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitOps with ArgoCD and GitHub Actions on AWS EKS]]></title>
            <link>https://medium.com/@akashdeep960/gitops-with-argocd-and-github-actions-on-aws-eks-8b419a8e7bba?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b419a8e7bba</guid>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[gitops-with-argocd]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 19:18:53 GMT</pubDate>
            <atom:updated>2025-11-29T05:07:06.178Z</atom:updated>
            <content:encoded><![CDATA[<h3>📌 Introduction</h3><p>In this project, I implemented a <strong>GitOps-based CI/CD pipeline</strong> using <strong>GitHub Actions</strong> for CI and <strong>ArgoCD</strong> for CD on an <strong>AWS EKS cluster</strong>.</p><p>The main goal was to:</p><ul><li>Automate build, test, and image push using <strong>GitHub Actions</strong></li><li>Manage deployments using <strong>ArgoCD</strong> and GitOps principles</li><li>Ensure security checks with <strong>Gitleaks, Trivy, and SonarQube</strong></li><li>Deploy a 3-tier application (frontend, backend, database) on <strong>Kubernetes</strong></li></ul><h3>🏗️ Architecture</h3><p><strong>Flow:</strong></p><ol><li>Developer pushes code → GitHub CI Repo triggers build.</li><li>Pre-build scans → Gitleaks, Unit Test, SonarQube, Trivy.</li><li>Build Docker Image → Push to DockerHub.</li><li>Update CD Repo (K8s manifests) → Trigger ArgoCD.</li><li>ArgoCD syncs desired state → Deploys to EKS.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jaOTmbGn2FxRymYKC2pZKQ.jpeg" /><figcaption>Architecture Diagram</figcaption></figure><h3>📂 Repository Structure</h3><p>We used two repositories:</p><ul><li><strong>CI Repo (3-tier-gitops-CI)</strong> → Application source code + GitHub Actions pipelines.</li><li><strong>CD Repo (3-tier-gitops-CD)</strong> → Kubernetes manifests for deployment.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HmmQF5yGTmmbbI8YWVyarw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*ikKWunSCnEloKgi5Wt_p4g.png" /><figcaption>CI/CD Repositories</figcaption></figure><h3>🔹 Step 1: Create EKS Cluster</h3><ol><li>Launch an EC2 instance (Installer VM).</li><li>Install AWS CLI and configure credentials:</li></ol><pre>aws configure</pre><p>3. Clone EKS Terraform repo:</p><pre># Install Terraform<br>sudo yum install -y yum-utils<br>sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo<br>sudo yum -y install terraform</pre><pre>git clone https://github.com/AAKASHDEEP786/EKS-Terraform.git<br>cd eks-terraform<br>terraform init<br>terraform apply -auto-approve</pre><p>4. Configure cluster access:</p><pre>aws eks --region ap-south-1 update-kubeconfig --name devopsshack-cluster</pre><h3>🔹 Step 2: Setup Dependencies</h3><p>Install tools inside EC2/Installer VM:</p><pre># Install kubectl<br>curl -LO &quot;https://dl.k8s.io/release/$(curl -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl&quot;<br>chmod +x kubectl &amp;&amp; mv kubectl /usr/local/bin/<br><br># Install eksctl<br>curl --silent --location &quot;https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz&quot; | tar xz -C /tmp<br>sudo mv /tmp/eksctl /usr/local/bin<br><br>#Associate IAM OIDC Provider with EKS<br>eksctl utils associate-iam-oidc-provider \<br>  --region ap-south-1 \<br>  --cluster devopsshack-cluster \<br>  --approve</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2oeYCAXvgprvCEfKuEHRGQ.png" /><figcaption>Installing kubectl, eksctl and iam-oicd-provider</figcaption></figure><h3>🛡️ Create IAM Service Account for EBS CSI Driver</h3><pre>eksctl create iamserviceaccount \<br>  --region ap-south-1 \<br>  --name ebs-csi-controller-sa \<br>  --namespace kube-system \<br>  --cluster devopsshack-cluster \<br>  --attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \<br>  --approve \<br>  --override-existing-serviceaccounts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tQ2qwpRKMlavgXA0uaZO3g.png" /><figcaption>AWS Service Account</figcaption></figure><h3>Deploy Add-ons:</h3><h3>✅ EBS CSI Driver</h3><pre>kubectl apply -k &quot;github.com/kubernetes-sigs/aws-ebs-csi-driver/deploy/kubernetes/overlays/stable/ecr/?ref=release-1.11&quot;</pre><h3>🌐 NGINX Ingress Controller</h3><pre>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml</pre><h3>🔒 cert-manager</h3><pre>kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.12.0/cert-manager.yaml</pre><h3>🔹 Step 3: Install ArgoCD</h3><ol><li>Create namespace:</li></ol><pre>kubectl create namespace argocd</pre><p>2. Install ArgoCD:</p><pre>kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml</pre><p>3. Check pods:</p><pre>kubectl get pods -n argocd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5zUhEo9g9GMT3hpXnL0-cQ.png" /><figcaption>Checking Pods</figcaption></figure><p>4. Expose ArgoCD via LoadBalancer:</p><pre>kubectl edit svc argocd-server -n argocd<br># Change type: ClusterIP → LoadBalancer</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*Zv4MLMHGq3ersxNui9m9ew.png" /><figcaption>Change type ClusterIP → LoadBalancer</figcaption></figure><p>5. Get ArgoCD password:</p><pre>kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath=&quot;{.data.password}&quot; | base64 -d</pre><p>6. Login to ArgoCD dashboard using LoadBalancer URL.</p><h3>🔹 Step 4: Configure ArgoCD</h3><ul><li>Go to <strong>Settings → Repositories → Connect Repo</strong></li><li>Add your <strong>CD Repository</strong> (public or private with token).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J42QxgDP9qZvpMzs7UWLvA.png" /><figcaption>Adding CD Repository to ArgoCD</figcaption></figure><ul><li>Create an <strong>Application</strong> in ArgoCD:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TWERWdbUpvnpW4_gqaQPGA.png" /><figcaption>ArgoCD Application Creation</figcaption></figure><p>Example:</p><ul><li>Name → user-management</li><li>Project → default</li><li>Repository URL → https://github.com/&lt;username&gt;/cd-repo</li><li>Path → k8s-prod</li><li>Destination → <a href="https://kubernetes.default.svc/">https://kubernetes.default.svc</a></li><li>Namespace → prod</li><li>Sync Policy → Enable Auto-Sync &amp; Prune</li></ul><h3>🔹 Step 5: GitHub Actions (CI Pipeline)</h3><p>In <strong>CI Repo</strong>, add .github/workflows/docker-image.yml:</p><pre>name: Node.js CI</pre><pre>on:<br>  push:<br>    branches: [ main ]<br>  pull_request:<br>    branches: [ main ]</pre><pre>permissions:<br>  contents: write   # required to push to CD repo with GITHUB_TOKEN or PAT</pre><pre>env:<br>  IMAGE_TAG: ${{ github.sha }}</pre><pre>jobs:<br>  compile:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4</pre><pre>- name: Set up Node.js (LTS recommended)<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: &#39;23&#39;   # use LTS if you don&#39;t need v23</pre><pre>- name: Frontend Compilation (Syntax Check)<br>        run: |<br>          cd client<br>          find . -name &quot;*.js&quot; -exec node --check {} +</pre><pre>- name: Backend Compilation (Syntax Check)<br>        run: |<br>          cd api<br>          find . -name &quot;*.js&quot; -exec node --check {} +</pre><pre>gitleaks-scan:<br>    runs-on: ubuntu-latest<br>    needs: compile<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4</pre><pre>- name: Gitleaks Setup<br>        uses: gitleaks/gitleaks-action@v2</pre><pre>- name: Gitleaks Scan<br>        run: |<br>          gitleaks detect --source ./client --exit-code 1<br>          gitleaks detect --source ./api --exit-code 1</pre><pre>trivy_fs_scan:<br>    runs-on: ubuntu-latest<br>    needs: gitleaks-scan<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4</pre><pre>- name: Run Trivy vulnerability scanner (FS)<br>        uses: aquasecurity/trivy-action@0.28.0<br>        with:<br>          scan-type: fs<br>          scan-ref: .<br>          format: table<br>          ignore-unfixed: true<br>          vuln-type: os,library<br>          severity: CRITICAL,HIGH</pre><pre>build_backend_docker_image_and_push:<br>    runs-on: ubuntu-latest<br>    needs: trivy_fs_scan<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4</pre><pre>- name: Login to Docker Hub<br>        uses: docker/login-action@v3<br>        with:<br>          username: ${{ vars.DOCKERHUB_USERNAME }}<br>          password: ${{ secrets.DOCKERHUB_TOKEN }}</pre><pre>- name: Set up QEMU<br>        uses: docker/setup-qemu-action@v3</pre><pre>- name: Set up Docker Buildx<br>        uses: docker/setup-buildx-action@v3</pre><pre>- name: Build and Push Docker image (backend)<br>        uses: docker/build-push-action@v6<br>        with:<br>          context: ./api<br>          file: ./api/Dockerfile<br>          push: true<br>          tags: |<br>            aakashdevops/backend:latest<br>            aakashdevops/backend:${{ env.IMAGE_TAG }}</pre><pre>build_frontend_docker_image_and_push:<br>    runs-on: ubuntu-latest<br>    needs: trivy_fs_scan<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4</pre><pre>- name: Login to Docker Hub<br>        uses: docker/login-action@v3<br>        with:<br>          username: ${{ vars.DOCKERHUB_USERNAME }}<br>          password: ${{ secrets.DOCKERHUB_TOKEN }}</pre><pre>- name: Set up QEMU<br>        uses: docker/setup-qemu-action@v3</pre><pre>- name: Set up Docker Buildx<br>        uses: docker/setup-buildx-action@v3</pre><pre>- name: Build and Push Docker image (frontend)<br>        uses: docker/build-push-action@v6<br>        with:<br>          context: ./client<br>          file: ./client/Dockerfile<br>          push: true<br>          tags: |<br>            aakashdevops/frontend:latest<br>            aakashdevops/frontend:${{ env.IMAGE_TAG }}</pre><pre>trivy_image_scan:<br>    runs-on: ubuntu-latest<br>    needs:<br>      - build_backend_docker_image_and_push<br>      - build_frontend_docker_image_and_push<br>    steps:<br>      - name: Checkout (noop, keeps workspace consistent)<br>        uses: actions/checkout@v4</pre><pre>- name: Run Trivy image scan for backend<br>        uses: aquasecurity/trivy-action@0.28.0<br>        with:<br>          scan-type: image<br>          image-ref: aakashdevops/backend:${{ env.IMAGE_TAG }}<br>          format: table<br>          exit-code: &#39;0&#39;                 # set to &#39;1&#39; to fail on vulns<br>          ignore-unfixed: true<br>          vuln-type: os,library<br>          severity: CRITICAL,HIGH</pre><pre>- name: Run Trivy image scan for frontend<br>        uses: aquasecurity/trivy-action@0.28.0<br>        with:<br>          scan-type: image<br>          image-ref: aakashdevops/frontend:${{ env.IMAGE_TAG }}<br>          format: table<br>          exit-code: &#39;0&#39;<br>          ignore-unfixed: true<br>          vuln-type: os,library<br>          severity: CRITICAL,HIGH</pre><pre>update_cd_repo:<br>    runs-on: ubuntu-latest<br>    needs: trivy_image_scan<br>    steps:<br>      - name: Checkout CD repo<br>        uses: actions/checkout@v4<br>        with:<br>          repository: AAKASHDEEP786/3-Tier-GitOps-CD<br>          ref: main<br>          token: ${{ secrets.CD_REPO_TOKEN }}<br>          path: cd</pre><pre>- name: Bump images in manifests (safe)<br>        working-directory: cd<br>        env:<br>          IMAGE_TAG: ${{ env.IMAGE_TAG }}<br>        run: |<br>          curl -sL <a href="https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64">https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64</a> -o yq &amp;&amp; sudo install yq /usr/local/bin/yq</pre><pre># -- Safety cleanup: remove any accidental .spec.template from Service docs<br>          yq -i &#39;(. | select(.kind==&quot;Service&quot;)) |= del(.spec.template)&#39; k8s-prod/backend.yaml<br>          yq -i &#39;(. | select(.kind==&quot;Service&quot;)) |= del(.spec.template)&#39; k8s-prod/frontend.yaml</pre><pre># -- Update ONLY Deployment images (backend)<br>          yq -i &#39;<br>            (. | select(.kind==&quot;Deployment&quot;)<br>               | .spec.template.spec.containers[]<br>               | select(.name==&quot;backend&quot;)<br>               | .image)<br>            = &quot;aakashdevops/backend:&quot; + strenv(IMAGE_TAG)<br>          &#39; k8s-prod/backend.yaml</pre><pre># -- Update ONLY Deployment images (frontend)<br>          yq -i &#39;<br>            (. | select(.kind==&quot;Deployment&quot;)<br>               | .spec.template.spec.containers[]<br>               | select(.name==&quot;frontend&quot;)<br>               | .image)<br>            = &quot;aakashdevops/frontend:&quot; + strenv(IMAGE_TAG)<br>          &#39; k8s-prod/frontend.yaml</pre><pre>- name: Commit &amp; push to CD repo<br>        working-directory: cd<br>        run: |<br>          git config user.name &quot;ci-bot&quot;<br>          git config user.email &quot;<a href="/service/mailto:ci-bot@users.noreply.github.com">ci-bot@users.noreply.github.com</a>&quot;<br>          git add -A<br>          git commit -m &quot;bump images to ${IMAGE_TAG}&quot; || echo &quot;no changes&quot;<br>          git push</pre><h3>🔹 Step 6: ArgoCD Sync</h3><p>Once CD Repo is updated → <strong>ArgoCD detects changes → Syncs automatically → Deploys to EKS.</strong></p><p>You can verify deployment:</p><pre>kubectl get pods -n prod<br>kubectl get svc -n prod</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gLzJXvQ5Vrilv-wyNYuwxQ.png" /><figcaption>Github Actions Auto-Trigger</figcaption></figure><h3>⚡ Benefits of This Setup</h3><ul><li><strong>Zero-cost CI/CD</strong> → GitHub runners are free.</li><li><strong>Rollback is easy</strong> → Just revert Git commit.</li><li><strong>No manual kubectl needed</strong> → ArgoCD ensures Git = Cluster state.</li></ul><h3>🏁 Conclusion</h3><p>With GitHub Actions + ArgoCD, I successfully implemented a <strong>GitOps pipeline on AWS EKS</strong>.<br> This setup ensures:</p><ul><li>Automated testing &amp; security checks</li><li>Continuous delivery with GitOps principles</li><li>Scalable &amp; production-ready workflow</li></ul><p>You can check out the complete code setup on [<a href="https://github.com/AAKASHDEEP786/3-Tier-GitOps-CI.git">CI</a>] [<a href="https://github.com/AAKASHDEEP786/3-Tier-GitOps-CD.git">CD</a>]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b419a8e7bba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ Retail Store Sample App — GitOps with Amazon EKS Auto Mode]]></title>
            <link>https://medium.com/@akashdeep960/%EF%B8%8F-retail-store-sample-app-gitops-with-amazon-eks-auto-mode-845db75568ee?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/845db75568ee</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 14:36:02 GMT</pubDate>
            <atom:updated>2025-08-22T14:56:25.378Z</atom:updated>
            <content:encoded><![CDATA[<h3>🛍️ Retail Store Sample App — GitOps with Amazon EKS Auto Mode</h3><h3>⭐ Deploying a Cloud-Native Retail Application using Terraform, GitHub Actions, ArgoCD, and AWS EKS</h3><h3>📖 Introduction</h3><p>In this blog, I will walk you through deploying a <strong>Retail Store Sample App</strong> on <strong>Amazon EKS (Auto Mode)</strong> using <strong>GitOps</strong> principles.<br> This application simulates a real-world e-commerce store, showcasing:</p><ul><li>✅ <strong>Microservices</strong> architecture (UI, Catalog, Cart, Orders, Checkout)</li><li>✅ <strong>GitOps with ArgoCD</strong> for automated deployments</li><li>✅ <strong>Infrastructure as Code</strong> with Terraform</li><li>✅ <strong>CI/CD pipeline</strong> using GitHub Actions</li><li>✅ <strong>EKS Auto Mode</strong> to simplify node management</li></ul><p>By the end, you’ll have a fully running retail store application on Kubernetes, accessible via a public URL.</p><h3>🏗️ Architecture Overview</h3><h3>🔹 Application Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*czn7MeKQajbRxKi5_U5yTA.png" /><figcaption>Application Architecture</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*NYup7E0yhtbTECt2do3ppA.png" /><figcaption>Application Architecture Workflow</figcaption></figure><h3>🔹 Infrastructure Architecture</h3><ul><li><strong>EKS (Auto Mode)</strong> with managed scaling</li><li><strong>VPC</strong> with public and private subnets</li><li><strong>Ingress Controller (NGINX)</strong> for routing</li><li><strong>ArgoCD</strong> for GitOps deployment</li><li><strong>Cert-Manager</strong> for SSL certificates</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3vipB-FuNnfcqBmBubFKnQ.gif" /><figcaption><em>Architecture Diagram</em></figcaption></figure><h3>⚙️ Prerequisites</h3><p>Before you start, install the following tools:</p><ul><li>AWS CLI v2+</li><li>Terraform 1.0+</li><li>kubectl 1.33+</li><li>Docker 20+</li><li>Helm 3+Git 2+</li></ul><h3>Install AWS CLI and Configure Credentials</h3><pre>aws configure</pre><p>👉 Use your <strong>AWS Access Key, Secret Key, Region, and Output format</strong>.</p><h3>🚀 Step 1: Clone the Repository</h3><pre>git clone https://github.com/AAKASHDEEP786/retail-store-sample-app.git<br>cd retail-store-sample-app/terraform/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eDTZ051FgfXPuIkkGX5BLQ.png" /></figure><h3>🚀 Step 2: Deploy Infrastructure with Terraform</h3><p>We’ll deploy in <strong>two phases</strong> for better control.</p><h3>🔹 Phase 1: Create EKS Cluster + VPC</h3><pre>terraform init</pre><pre>terraform apply -target=module.vpc --auto-approve<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*aWIX-I1CzPiO9ou5mxrPOw.png" /><figcaption>AWS VPC</figcaption></figure><pre>terraform apply -target=module.retail_app_eks --auto-approve</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JuwnJsmj2kRIOuDkDvxkHg.png" /><figcaption>AWS EKS Cluster</figcaption></figure><p>✅ This sets up:</p><ul><li>VPC (public + private subnets)</li><li>EKS cluster (Auto Mode enabled)</li><li>IAM roles and security groups</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wa4p-2UEVUy8djqXq2jipw.png" /><figcaption><em>Successful Terraform Apply and Created VPC and EKS Cluster</em></figcaption></figure><h3>🔹 Update kubeconfig</h3><pre>aws eks update-kubeconfig --name retail-store-kpim --region us-west-2</pre><h3>🔹 Phase 2: Deploy Add-ons + App</h3><pre>terraform apply --auto-approve</pre><p>✅ This installs:</p><ul><li>ArgoCD</li><li>NGINX Ingress Controller</li><li>Cert-Manager</li><li>Retail Store microservices</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2cbQReLkANhKnkD2oUwwA.png" /><figcaption>Terraform Apply Results: ArgoCD | NGINX Ingress | Cert-Manager | Retail Store Microservices</figcaption></figure><h3>🚀 Step 3: Verify Kubernetes Setup</h3><p>Check nodes:</p><pre>kubectl get nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*B6ib9x2qQX6dhFN-aaUSrw.png" /><figcaption>EKS worker Node</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*MtRylpjtKWPypdDmVez89g.png" /><figcaption>AWS Console View</figcaption></figure><p>Check services:</p><pre>kubectl get ingress -A</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfOdqbpvKR_TVPTrSIuj3g.png" /><figcaption>All Ingress resources</figcaption></figure><p>👉 Copy the <strong>EXTERNAL-IP</strong> and open in browser to access your Retail Store App 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jt0p7hts9JOzjlIaIBNfQA.png" /><figcaption>Application UI</figcaption></figure><h3>🚀 Step 4: Setup GitOps with ArgoCD</h3><h3>🔹 Get ArgoCD Password</h3><pre>kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=&#39;{.data.password}&#39; | base64 -d</pre><h3>🔹 Port-Forward ArgoCD UI</h3><pre>kubectl port-forward svc/argocd-server -n argocd 8080:443 &amp;</pre><p>👉 Open: <a href="https://localhost:8080/">https://localhost:8080</a></p><ul><li>Username: admin</li><li>Password: <em>(copied from above)</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VLV47v0by54HZzU3g3f_Mg.png" /><figcaption>ArgoCD Dashboard</figcaption></figure><h3>🚀 Step 5: CI/CD with GitHub Actions (Production Only)</h3><p>If using the <strong>Production Branch</strong>:</p><ol><li>Go to <strong>GitHub Repo → Settings → Secrets → Actions</strong></li><li>Add secrets:</li></ol><ul><li>AWS_ACCESS_KEY_ID</li><li>AWS_SECRET_ACCESS_KEY</li><li>AWS_REGION</li><li>AWS_ACCOUNT_ID</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Znoy5DogfqYDYY1Ge-xBlQ.png" /><figcaption>Repo. Secret Configuration</figcaption></figure><p>✅ GitHub Actions will:</p><ul><li>Build Docker images</li><li>Push to <strong>Private ECR</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4aWb4-PpjqGuwvL7f0RHkw.png" /><figcaption>Images Pushed to AWS Private ECR</figcaption></figure><ul><li>Trigger ArgoCD to auto-deploy</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgaF_FzxWhvR_F7i028FLQ.png" /><figcaption>Github Actions Auto-Deploy</figcaption></figure><h3>📊 Monitoring &amp; Observability</h3><p>You can monitor the application with:</p><pre>kubectl get pods -n retail-store-kpim<br>kubectl get ingress -n retail-store-kpim</pre><p>ArgoCD dashboard provides:</p><ul><li>Real-time sync status</li><li>Resource health monitoring</li><li>Rollback capability</li></ul><h3>🧹 Cleanup</h3><p>When done, destroy resources:</p><pre>terraform destroy --auto-approve</pre><h3>✅ Conclusion</h3><p>We successfully deployed a <strong>Retail Store Sample App</strong> on <strong>Amazon EKS Auto Mode</strong> using:</p><ul><li>Terraform (Infrastructure as Code)</li><li>GitOps (ArgoCD)</li><li>CI/CD (GitHub Actions)</li></ul><p>This project showcases how enterprises can run microservices applications at scale with <strong>automation, observability, and security</strong>.</p><p>You can check out the complete code setup on [<a href="https://github.com/AAKASHDEEP786/retail-store-sample-app">GitHub</a>]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=845db75568ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Secure CI/CD Pipeline with Jenkins, SonarQube, Trivy, and GitLeaks on AWS]]></title>
            <link>https://medium.com/@akashdeep960/building-a-secure-ci-cd-pipeline-with-jenkins-sonarqube-trivy-and-gitleaks-on-aws-5003e6bdc911?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5003e6bdc911</guid>
            <category><![CDATA[sonarqube]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Wed, 20 Aug 2025 18:13:31 GMT</pubDate>
            <atom:updated>2025-08-20T18:13:31.809Z</atom:updated>
            <content:encoded><![CDATA[<h3>📌 Introduction</h3><p>In this project, I built a complete CI/CD pipeline on AWS using <strong>Jenkins, SonarQube, Trivy, GitLeaks, Docker, and Docker Compose</strong>.<br> The pipeline ensures:</p><ul><li>✅ Automated builds and deployments</li><li>✅ Code quality checks with SonarQube</li><li>✅ Security scanning with Trivy and GitLeaks</li><li>✅ Deployment of frontend and backend Docker containers</li><li>✅ Final application running on <strong>http://&lt;Jenkins-IP&gt;:3000</strong></li></ul><p>This story walks you step by step with commands, configurations, and screenshots.</p><h3>⚡ Prerequisites</h3><ul><li>AWS account</li><li>Two <strong>EC2 instances</strong> (Jenkins &amp; SonarQube)</li><li>Open security group ports:</li><li>22 (SSH)</li><li>8080 (Jenkins)</li><li>9000 (SonarQube)</li><li>3000 (Application)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OFC4D2WGVKzmqU9LTS9nKg.png" /><figcaption>Security Group inbound rules</figcaption></figure><h3>🛠️ Step 1: Launch EC2 Instances</h3><p>I launched two EC2 instances:</p><ul><li><strong>Jenkins EC2</strong></li><li><strong>SonarQube EC2</strong></li></ul><p>Attached the required security groups to allow external access.</p><h3>🛠️ Step 2: Jenkins Setup</h3><p>SSH into Jenkins server:</p><pre>ssh -i &quot;your-key.pem&quot; ubuntu@18.201.236.62</pre><p>Install Java:</p><pre>sudo apt update<br>sudo apt install -y openjdk-21-jdksudo cat /var/lib/jenkins/secrets/initialAdminPassword</pre><p>Install Jenkins:</p><pre>sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \<br>  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key<br>echo &quot;deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc]&quot; \<br>  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \<br>  /etc/apt/sources.list.d/jenkins.list &gt; /dev/null<br>sudo apt-get update<br>sudo apt-get install jenkins</pre><p>Get Jenkins initial password:</p><pre>sudo cat /var/lib/jenkins/secrets/initialAdminPassword</pre><p>Access Jenkins:<br> 👉 http://18.201.236.62:8080</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7k93t6Yp5Jk0Px-X1cQFjA.png" /><figcaption>Jenkins unlock screen</figcaption></figure><h3>🛠️ Step 3: SonarQube Setup with Docker</h3><p>SSH into SonarQube EC2:</p><pre>ssh -i &quot;your-key.pem&quot; ubuntu@125.243.1.24</pre><p>Install Docker:</p><pre>sudo apt update<br>sudo apt install -y docker.io<br>sudo usermod -aG docker ubuntu</pre><p>Run SonarQube in Docker:</p><pre>docker run -d -p 9000:9000 sonarqube:lts-community</pre><p>Access SonarQube:<br> 👉 <a href="http://125.243.1.24:9000/">http://125.243.1.24:9000</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F1hIA2Zc1HGw9ohNCl7J3Q.png" /><figcaption>SonarQube home page</figcaption></figure><p>🛠️ Step 4: Jenkins Plugins &amp; Configurations</p><p>In Jenkins → Manage Plugins → Install:</p><ul><li>Pipeline</li><li>Stage View</li><li>NodeJS</li><li>SonarQube Scanner</li><li>Docker Pipeline</li><li>Docker Compose Build Step</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f3d8XwwB8dsu6cjCfXuS0Q.png" /><figcaption>Jenkins plugin manager</figcaption></figure><p>In Jenkins → Manage Jenkins → Tools:</p><ul><li>Add <strong>NodeJS</strong></li><li>Add <strong>SonarQube Scanner</strong></li></ul><p>In Jenkins → Manage Jenkins → Credentials:</p><ul><li>Add <strong>SonarQube Token</strong> (from SonarQube → Administration → Security → Tokens)</li><li>Add <strong>DockerHub Credentials</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mbmRJvMhUOhOKC_J4Rbmvw.png" /><figcaption>SonarQube, GitHub, Docker Credentials</figcaption></figure><h3>🛠️ Step 5: Webhook Setup</h3><p>In SonarQube:<br> 👉 Administration → Webhooks → Add Jenkins URL:</p><pre>http://18.201.236.62:8080/sonarqube-webhook/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*zoOKc7bQBUy7MLKLmVqAkQ.png" /><figcaption>Webhook page in SonarQube</figcaption></figure><h3>🛠️ Step 6: Install Security Tools on Jenkins</h3><p>Install <strong>Trivy</strong>:</p><pre>wget https://github.com/aquasecurity/trivy/releases/latest/download/trivy_0.50.0_Linux-64bit.deb<br>sudo dpkg -i trivy_0.50.0_Linux-64bit.deb</pre><p>Install <strong>GitLeaks</strong>:</p><pre>wget https://github.com/gitleaks/gitleaks/releases/download/v8.17.0/gitleaks_8.17.0_linux_x64.tar.gz<br>tar -xvzf gitleaks_8.17.0_linux_x64.tar.gz<br>sudo mv gitleaks /usr/local/bin/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*R_5IWiA_MMWV0YJI-kw3CA.png" /><figcaption>Trivy &amp; GitLeaks version check</figcaption></figure><h3>🛠️ Step 7: Jenkins Pipeline (Jenkinsfile)</h3><p>Here’s the full Jenkinsfile I used for CI/CD:</p><pre>pipeline {<br>    agent any<br>    <br>    tools {<br>        nodejs &#39;nodejs23&#39;<br>    }<br><br>    environment {<br>        SCANNER_HOME = tool &#39;sonar-scanner&#39;<br>    }<br>    stages {<br>        stage(&#39;Git Checkout&#39;) {<br>            steps {<br>                git branch: &#39;docker-build-deploy&#39;, url: &#39;https://github.com/AAKASHDEEP786/3-Tier-DevSecOps-Mega-Project.git&#39;<br>            }<br>        }<br>        <br>        stage(&#39;Frontend Compilation&#39;) {<br>            steps {<br>                dir(&#39;client&#39;) {<br>                    sh &#39;find . -name &quot;*.js&quot; -exec node --check {} +&#39;<br>                }<br>            }<br>        }<br>        <br>        stage(&#39;Backend Compilation&#39;) {<br>            steps {<br>                dir(&#39;api&#39;) {<br>                    sh &#39;find . -name &quot;*.js&quot; -exec node --check {} +&#39;<br>                }<br>            }<br>        }<br>        <br>        stage(&#39;GitLeaks Scan&#39;) {<br>            steps {<br>                sh &#39;gitleaks detect --source ./client --exit-code 1&#39;<br>                sh &#39;gitleaks detect --source ./api --exit-code 1&#39;<br>            }<br>        }<br>        <br>        stage(&#39;SonarQube Analysis&#39;) {<br>            steps {<br>                withSonarQubeEnv(&#39;sonar&#39;) {<br>                    sh &#39;&#39;&#39; $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=NodeJS-Project \<br>                            -Dsonar.projectKey=NodeJS-Project &#39;&#39;&#39;<br>                }<br>            }<br>        }<br>        stage(&#39;Quality Gate Check&#39;) {<br>            steps {<br>                timeout(time: 1, unit: &#39;HOURS&#39;) {<br>                    waitForQualityGate abortPipeline: false, credentialsId: &#39;sonar-token&#39;<br>                }<br>            }<br>        }<br>        stage(&#39;Trivy FS Scan&#39;) {<br>            steps {<br>                sh &#39;trivy fs --format table -o fs-report.html .&#39;<br>            }<br>        }<br>        <br>        stage(&#39;Build-Tag &amp; Push Backend Docker Image&#39;) {<br>            steps {<br>                script {<br>                    withDockerRegistry(credentialsId: &#39;docker-cred&#39;) {<br>                        dir(&#39;api&#39;) {<br>                            sh &#39;docker build -t aakashdevops/backend:latest .&#39;<br>                            sh &#39;trivy image --format table -o backend-image-report.html aakashdevops/backend:latest &#39;<br>                            sh &#39;docker push aakashdevops/backend:latest&#39;<br>                        }<br>                    }<br>                }<br>            }<br>        }  <br>            <br>        stage(&#39;Build-Tag &amp; Push Frontend Docker Image&#39;) {<br>            steps {<br>                script {<br>                    withDockerRegistry(credentialsId: &#39;docker-cred&#39;) {<br>                        dir(&#39;client&#39;) {<br>                            sh &#39;docker build -t aakashdevops/frontend:latest .&#39;<br>                            sh &#39;trivy image --format table -o frontend-image-report.html aakashdevops/frontend:latest &#39;<br>                            sh &#39;docker push aakashdevops/frontend:latest&#39;<br>                        }<br>                    }<br>                }<br>            }<br>        }  <br>        stage(&#39;Docker Deploy via Compose&#39;) {<br>            steps {<br>                script {<br>                    sh &#39;docker-compose up -d&#39;<br>                }<br>            }<br>        }<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*y3fRSkKl2DmS8mrUdM1QYA.png" /><figcaption>Jenkins pipeline stages view (all green)</figcaption></figure><h3>🛠️ Step 8: Final Deployment</h3><p>Once the pipeline runs successfully, Docker Compose deploys both frontend and backend.<br> Access the app:<br> 👉 <a href="http://18.201.236.62:3000/">http://18.201.236.62:3000</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7krtmhhjFRgLlncFCxgsA.png" /><figcaption>Application running in browser</figcaption></figure><h3>✅ Conclusion</h3><p>We successfully built a <strong>secure CI/CD pipeline</strong> with:</p><ul><li>Jenkins (automation)</li><li>SonarQube (code quality)</li><li>GitLeaks (secrets detection)</li><li>Trivy (security scanning)</li><li>Docker + Docker Compose (deployment)</li></ul><p>This project showcases how to integrate DevSecOps practices into a modern CI/CD pipeline.<br> 🚀 Future improvement: extend this to Kubernetes with Helm &amp; Istio.</p><p>You can check out the complete code setup on [<a href="https://github.com/AAKASHDEEP786/3-Tier-DevSecOps-Mega-Project">GitHub</a>]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5003e6bdc911" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Jenkins Setup on AWS EC2 with Terraform]]></title>
            <link>https://medium.com/@akashdeep960/automating-jenkins-setup-on-aws-ec2-with-terraform-ff1024d18be6?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff1024d18be6</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[route-53]]></category>
            <category><![CDATA[terraform-modules]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 14:12:57 GMT</pubDate>
            <atom:updated>2025-08-20T05:14:19.218Z</atom:updated>
            <content:encoded><![CDATA[<p>Automating the setup of Jenkins on cloud infrastructure is a crucial skill for any DevOps engineer. In this project, I provisioned an <strong>AWS EC2 instance and configured Jenkins</strong> from scratch using <strong>Terraform</strong>, enabling a fully automated and reproducible environment. This post walks you through the architecture, tools, implementation steps, and key learnings for setting up Jenkins on EC2.</p><h3>🔧 Tools &amp; Technologies Used</h3><ul><li><strong>Terraform</strong> — Infrastructure as Code (IaC) for provisioning AWS resources.</li><li><strong>Jenkins</strong> — CI/CD tool for automating builds and deployments.</li><li><strong>AWS Cloud</strong> — EC2, VPC, ALB, RDS, Route 53, ACM, S3.</li><li><strong>GitHub</strong> — Source code management (application, Terraform, Jenkins pipeline).</li></ul><h3>🏗️ Project Architecture</h3><p>The architecture consists of:</p><ol><li><strong>Networking</strong>: VPC with public subnets, route tables, and internet gateway.</li><li><strong>Compute</strong>: EC2 instance running Jenkins and Terraform.</li><li><strong>Load Balancing</strong>: ALB with a Target Group and security group configuration.</li><li><strong>DNS &amp; SSL</strong>: Route 53 hosted zone and AWS Certificate Manager.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dkAr3nFEtqF1bJcddNtwvQ.jpeg" /><figcaption>Architecture diagram</figcaption></figure><h3>⚙️ Implementation Steps</h3><h3>1. Setting Up Networking</h3><ul><li>Created <strong>VPC</strong> with public subnet.</li><li>Configured <strong>route tables</strong> and <strong>internet gateway</strong> to allow traffic.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*YKxqz2Ywbjj2iEUHSWBCsA.png" /><figcaption>Terraform code for VPC creation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3No0t6vVYnjbbFxdNVJKOA.png" /><figcaption>VPC visible in AWS Console</figcaption></figure><h3>2. Configuring Security Groups</h3><ul><li>The security group was configured to allow access on port 8080 for the Jenkins EC2 instance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*CAl-Wq29AKI8TLL9f9lxGQ.png" /><figcaption>Terraform code for security group</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a0TZhzrDjmOsAcBmKv1s2w.png" /><figcaption>Security group visible in AWS Console</figcaption></figure><h3>3. Provisioning Jenkins EC2 Instance</h3><ul><li>EC2 instance created using Terraform with a <strong>user-data script</strong> to install:</li><li>Jenkins</li><li>Terraform</li><li>JDK 21</li><li>GitHub repository clone</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QOQz_LGLgMcuchvfdsXKzQ.png" /><figcaption>Terraform code for EC2 instance</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2skF8oVQfu2RA1BjnXYanQ.png" /><figcaption>EC2 instance running in AWS Console</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7k93t6Yp5Jk0Px-X1cQFjA.png" /><figcaption>Jenkins web UI setup and plugin installation</figcaption></figure><h3>4. Load Balancer &amp; Target Group</h3><ul><li>Created a <strong>Target Group</strong> for the Jenkins instance.</li><li>Configured <strong>Application Load Balancer</strong> with correct subnets and security groups.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*Tq8MaRYTSmlNOzn407c0VQ.png" /><figcaption>Terraform code for Target Group</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xuETKqXI7ncrpWEtkPhwAw.png" /><figcaption>Target Group in AWS Console</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwDGVsgPFbVov1UhUBzciw.png" /><figcaption>Terraform code for ALB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uzaslM5lk2PHldihmUvMcw.png" /><figcaption>ALB visible in AWS Console</figcaption></figure><h3>5. Hosted Zone &amp; SSL Certificate</h3><ul><li>Created a <strong>Route 53 hosted zone</strong> and added A records pointing to ALB.</li><li>Issued SSL certificate via <strong>AWS Certificate Manager</strong> for HTTPS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*4TarwUw7KYUvPtLEyGkWUw.png" /><figcaption>Terraform code for Route 53 hosted zone &amp; ACM</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ThkDTUhJMXcNbA0fyFatzw.png" /><figcaption>Hosted zone records in AWS Console</figcaption></figure><h3>✅ Results</h3><p>By the end of this project, I had a <strong>fully functional Jenkins server running on AWS EC2</strong>, provisioned entirely using Terraform.</p><ul><li>Jenkins was accessible securely through the domain name over HTTPS.</li><li>Security groups restricted access to only the required ports (8080 for Jenkins via ALB).</li><li>Route 53 and ACM ensured that Jenkins could be accessed using a <strong>custom domain with SSL encryption</strong>.</li></ul><p>This automation eliminates manual provisioning steps and enables a <strong>production-ready Jenkins environment</strong> in just a few commands.</p><h3>✅ Key Learnings</h3><ul><li>Modular <strong>Terraform code</strong> improves reusability.</li><li>Integration of <strong>Terraform and Jenkins pipelines</strong> for automation.</li><li><strong>Route 53 + ACM</strong> enable secure domain setup with HTTPS.</li></ul><h3>🚀 Conclusion</h3><p>This project shows how Terraform and AWS simplify the automated setup of Jenkins on EC2. With infrastructure as code, the environment is consistent, secure, and easily scalable — laying a strong foundation for future CI/CD pipelines and cloud-native automation.</p><p>You can check out the full Terraform + Jenkins setup on [<a href="https://github.com/AAKASHDEEP786/terraform-jenkins">GitHub]</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff1024d18be6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering AWS VPC Endpoints: A Step-by-Step Project Guide]]></title>
            <link>https://medium.com/@akashdeep960/mastering-aws-vpc-endpoints-a-step-by-step-project-guide-cd0a331f957c?source=rss-dc6a9d3b40f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd0a331f957c</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-route-table]]></category>
            <category><![CDATA[aws-vpc]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[aws-endpoint]]></category>
            <dc:creator><![CDATA[Aakash Deep]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 15:16:24 GMT</pubDate>
            <atom:updated>2025-08-19T14:44:02.210Z</atom:updated>
            <content:encoded><![CDATA[<h3>📌 Introduction</h3><p>In cloud architectures, applications often need secure and efficient access to AWS services (like S3 or DynamoDB) without exposing traffic to the public internet. This is where <strong>VPC Endpoints</strong> come into play.</p><p>In this project, I:</p><ul><li>Created a custom <strong>VPC</strong>.</li><li>Configured <strong>Subnets</strong> and <strong>Route Tables</strong>.</li><li>Deployed an <strong>EC2 instance</strong> inside the VPC.</li><li>Set up a <strong>VPC Endpoint</strong> for secure communication with <strong>S3</strong>.</li><li>Validated that the EC2 instance could securely access S3 via the VPC Endpoint.</li><li>This article is both a <strong>guide</strong> and a <strong>project showcase</strong>.</li></ul><h3>🏗️ Project Architecture</h3><p>Here’s a high-level architecture of the setup:</p><ul><li>A <strong>VPC</strong> with public and private subnets.</li><li>An <strong>EC2 instance</strong> in the private subnet.</li><li>An <strong>S3 bucket</strong> for testing.</li><li>A <strong>VPC Endpoint</strong> to securely connect the EC2 instance to the S3 bucket.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IbjMy71J6fpDW8zrpbqXjg.png" /><figcaption>Architecture diagram</figcaption></figure><h3>🔹 Step 1: Creating a VPC</h3><ol><li>Go to <strong>VPC Console</strong> → Create VPC.</li><li>Choose a <strong>CIDR block</strong> (e.g., 11.0.0.0/16).</li><li>Name the VPC (e.g., demo-vpcendpoint-vpc).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TaIzm2Db__isnU9VAITboQ.png" /><figcaption>VPC creation</figcaption></figure><h3>🔹 Step 2: Creating Subnets</h3><ol><li>Create a <strong>public subnet</strong> (e.g., 11.0.1.0/24).</li><li>Create a <strong>private subnet</strong> (e.g., 11.0.3.0/24).</li><li>Associate subnets with the VPC.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q7HLgqMfxyKoI5hvRudiow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqjmpZITL5PKEaWiKMosVw.png" /><figcaption>Public &amp; Private subnet creation</figcaption></figure><h3>🔹Step 3: Configuring Route Tables and <strong>Internet Gateway</strong></h3><p>In AWS, <strong>Route Tables</strong> control how network traffic is directed inside your VPC. For a secure architecture, we will create <strong>two separate route tables</strong>:</p><p><strong>Public Route Table</strong> → For the Public Subnet (with Internet access)</p><p><strong>Private Route Table</strong> → For the Private Subnet (no direct Internet access)</p><h4>✅ Step 3.1: Create a Public Route Table</h4><p>Navigate to <strong>VPC → Route Tables → Create Route Table</strong>.</p><ol><li>Name it something like <strong>vpc-endpoint-public-rt</strong> and select your VPC.</li></ol><p>2 . After creation, go to the <strong>Routes tab</strong> → click <strong>Edit Routes</strong> → add a route:</p><p><strong>3. Destination:</strong> 0.0.0.0/0</p><p><strong>4. Target:</strong> Select your <strong>Internet Gateway (IGW)</strong></p><p>This ensures traffic from the Public Subnet can go to the Internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VN8amW9ozop_iFj5FRImKg.png" /><figcaption>Route table creation for Public subnet</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qXsHeUg2tF3MyLxsCpDow.png" /><figcaption>Attaching Internet Gateway to Public Route Table</figcaption></figure><h4>✅ Step 3.2: Associate the Public Subnet</h4><ol><li>In the <strong>Subnet Associations tab</strong> of <strong>vpc-endpoint-public-rt</strong>, click <strong>Edit Subnet Associations</strong>.</li><li>Select only your <strong>Public Subnet</strong>.</li><li>Save changes.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-RNd47bAaJxJz8V4pqfeLg.png" /><figcaption>Public Subnet Association</figcaption></figure><h4>✅ Step 3.3: Create a Private Route Table</h4><ol><li>Again go to <strong>VPC → Route Tables → Create Route Table</strong>.</li><li>Name it <strong>vpc-endpoint-private-rt</strong> and attach it to the same VPC.</li><li>Leave the routes as default (only Local VPC route is needed).</li><li>This ensures instances in the private subnet can only communicate within the VPC, not directly with the Internet.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cMdBdUaShvQo084-G0tkyA.png" /><figcaption>Route table creation for Private subnet</figcaption></figure><h4>✅ Step 3.4: Associate the Private Subnet</h4><ol><li>Go to the <strong>Subnet Associations tab</strong> of <strong>vpc-endpoint-private-rt</strong>.</li><li>Select only your <strong>Private Subnet</strong>.</li><li>Save changes.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iby_mMSciSPRecP2B5JCJQ.png" /><figcaption>Private Subnet Association</figcaption></figure><h3>🔹 Step 4: Launching EC2 Instances</h3><h3>Step 4.1: Public EC2 Instance (Jump Server)</h3><ol><li>Launch an <strong>EC2 instance</strong> in the public subnet.</li><li>Assign it a <strong>public IP address</strong>.</li><li>Attach a <strong>key pair</strong> (e.g., vpc-endpoint-public-key).</li><li>Security Group should allow <strong>SSH (port 22)</strong> from your IP.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2d8eouvGNKVVXkDeNPbfYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQFSNVi5V68IzFONIIm9Cw.png" /><figcaption>Public EC2 configuration &amp; Key pair</figcaption></figure><h3>Step 4.2: Private EC2 Instance</h3><ol><li>Launch another <strong>EC2 instance</strong> in the private subnet.</li><li>Do <strong>not</strong> assign a public IP.</li><li>Attach a <strong>different key pair</strong> (e.g., vpc-endpoint-private-key).</li><li>Security Group should allow <strong>SSH only from the Public EC2</strong> (not from the internet).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sUrivUCT7CFsoak-A6vEWg.png" /><figcaption>Private EC2 configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6DOsyBaiTF6T7feH96omQ.png" /><figcaption>Only Private IP is Assigned</figcaption></figure><h3>Step 4.3: Enabling Access to Private EC2</h3><ol><li>Upload the <strong>private EC2 key</strong> (vpc-endpoint-private-key) onto the <strong>Public EC2 instance</strong>.</li><li>SSH into the Public EC2, then use the private key to connect into the Private EC2:</li></ol><pre>chmod 400 vpc-endpoint-public-key.pem</pre><pre>ssh -i &quot;vpc-endpoint-public-key.pem&quot; username@&lt;public-ip&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cmSeyfDAmZpNt9PJwWrOFw.png" /><figcaption>SSH into Public EC2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wmE3bEeSmGZx4Rh9baBXXQ.png" /><figcaption>Create Private Key for Access Private Instance</figcaption></figure><h3>🔹 Step 5: Creating an S3 Bucket</h3><ol><li>Create an <strong>S3 bucket</strong> for testing if not existing (e.g., demo-s3-bucket-endpoint-vpc-12345).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9w-77Yo6_xbAolDOD2s_mg.png" /><figcaption>demo S3 Bucket</figcaption></figure><h3>🔹 Step 6: Creating a VPC Endpoint</h3><ol><li>Go to <strong>VPC → Endpoints → Create Endpoint</strong>.</li><li>Choose <strong>S3 service</strong>.</li><li>Select your <strong>VPC</strong> and the <strong>private subnet’s route table</strong>.</li><li>Enable <strong>private DNS</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2WhBUvTwH3enNZD7Wt-nDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kc6Vw2_u5Xuq4-cRMvYh9w.png" /><figcaption>VPC Endpoint creation screen</figcaption></figure><h3>🔹 Step 7: Testing the Setup</h3><ol><li>SSH into the <strong>Public EC2</strong>.</li><li>From there, SSH into the <strong>Private EC2</strong> using the private key.</li><li>Run the command inside the Private EC2:</li></ol><pre>chmod 400 vpc-endpoint-private-key.pem</pre><pre>ssh -i &quot;vpc-endpoint-private-key.pem&quot; ec2-user@&lt;private-ip&gt;</pre><pre>aws s3 ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*G-UVbpk0YP0wN2ek3p5Liw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*YEtZXU7J_Z5axR9M4XQDDw.png" /><figcaption><em>EC2 connected via SSH to Private Instance &amp; S3 bucket listed from Private EC2</em></figcaption></figure><ol><li>You should see the S3 bucket without needing internet access.</li></ol><h3>✅ Results</h3><ul><li>The <strong>Private EC2 instance</strong> accessed <strong>S3 securely</strong> via the <strong>VPC Endpoint</strong>.</li><li>No public internet access was needed for the private EC2.</li><li>The <strong>Public EC2 acted as a jump host</strong> to securely connect into the private instance.</li><li>Improved security and reduced latency.</li></ul><h3>📚 Key Learnings</h3><ul><li>How to set up <strong>jump host architecture</strong> (Public → Private EC2).</li><li>Difference between <strong>Gateway Endpoints</strong> and <strong>Interface Endpoints</strong>.</li><li>How VPC endpoints increase <strong>security</strong> by avoiding internet routing.</li><li>Practical use case of <strong>private EC2 instances accessing AWS services</strong> securely.</li></ul><h3>🚀 Conclusion</h3><p>This project demonstrated how to <strong>securely connect a private EC2 instance to S3</strong> using a VPC Endpoint, accessed through a public EC2 jump server. It’s a fundamental skill for designing secure AWS architectures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd0a331f957c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>