<?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"><channel><title><![CDATA[Pranesh's Blogs | Automation | DevSecOps]]></title><description><![CDATA[Sharing insights on Flutter, DevSecOps and Agentic AI Workflow Automation]]></description><link>https://blogs.praneshpyarashrestha.com.np</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1667706810191/FgYHLeWgf.jpg</url><title>Pranesh&apos;s Blogs | Automation | DevSecOps</title><link>https://blogs.praneshpyarashrestha.com.np</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 09:34:07 GMT</lastBuildDate><atom:link href="https://blogs.praneshpyarashrestha.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Spec-Driven Development Tutorial using GitHub Spec Kit]]></title><description><![CDATA[Spec-Driven Development (SDD) is the idea of beginning every AI-assisted project with clearly defined requirements, not jumping right into code.
This companion piece takes that idea from theory to practice. Here, we’ll walk through the complete workf...]]></description><link>https://blogs.praneshpyarashrestha.com.np/spec-driven-development-tutorial-using-github-spec-kit</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/spec-driven-development-tutorial-using-github-spec-kit</guid><category><![CDATA[Github spec kit]]></category><category><![CDATA[Spec-Driven-Development]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Mon, 26 Jan 2026 09:09:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769418069496/1cbc76fc-0e49-40bd-bdda-64add155e92a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Spec-Driven Development (SDD) is the idea of beginning every AI-assisted project with clearly defined requirements, not jumping right into code.</p>
<p>This companion piece takes that idea from theory to practice. Here, we’ll walk through the <strong>complete workflow</strong>, from the first line of a specification to long-term maintenance, using a real-world example.</p>
<p>If you want to see how to bring SDD to life and how tools like GitHub Spec Kit can help operationalize it, this guide will show you the way.</p>
<h2 id="heading-before-you-begin"><strong>Before You Begin</strong></h2>
<p>Before diving into the step-by-step workflow, it’s worth pausing to see what makes Spec-Driven Development different from traditional agile or documentation-heavy approaches.</p>
<ol>
<li><p>It isn’t about adding paperwork. It’s about creating clarity.</p>
</li>
<li><p>The goal is shared understanding, every contributor, human or AI, aligned around the same mental model.</p>
</li>
<li><p>The best specs are built together, with product, engineering, and QA shaping a single source of truth.</p>
</li>
</ol>
<p>Once you start treating the spec as a living contract rather than a static document, the rest of the process naturally falls into place.</p>
<h2 id="heading-sdd-workflow-deepdive"><strong>SDD Workflow Deepdive</strong></h2>
<p>Below is a practical, spec-first workflow using a trip-planner AI agent as the running example. We’ll reference GitHub-style spec tooling using <a target="_blank" href="https://github.com/github/spec-kit">GitHub’s Spec Kit</a> to keep things concrete, but any well-structured markdown spec can work. </p>
<p>The same flow works with other tools or writing from scratch as long as you capture the same ingredients.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769418219653/74209b65-8bf1-4940-ba93-251daa99ccbb.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-1-specify"><strong>1) Specify</strong></h3>
<p><strong>Goal:</strong> write a crisp product spec that states the problem, scope, users, success criteria, and constraints. Focus on what and why. Avoid implementation details here.</p>
<p><strong>Trip-planner example (product spec highlights):</strong></p>
<ul>
<li><p><strong>Problem:</strong> help travelers plan multi-city trips with realistic timing, budget guidance, and offline availability.</p>
</li>
<li><p><strong>Users:</strong> casual travelers, travel bloggers, and small tour operators.</p>
</li>
<li><p><strong>Key flows:</strong> create trips, add cities, auto-generate itinerary, adjust by preferences (pace, interests, budget), export to mobile.</p>
</li>
<li><p><strong>Non-functional constraints:</strong> P95 itinerary generation under 4 seconds for 7-day trips. Store PII securely. Offline read mode on mobile.</p>
</li>
<li><p><strong>Out of scope:</strong> airline booking, hotel payments.</p>
</li>
</ul>
<p>Now run the <strong>/specify</strong> step to capture the above in a project-local spec that lives in version control so both humans and agents can reference it.</p>
<pre><code class="lang-bash">/specify Build a trip planner that generates day-by-day itineraries <span class="hljs-keyword">for</span> multi-city travel.Include personas, key flows, success metrics, and constraints (perf, privacy, offline).It<span class="hljs-string">'s a free to use platform.
Problem: help travelers plan multi-city trips with realistic timing, budget guidance, and offline availability.Users: casual travelers, travel bloggers, and small tour operators.Key flows: create trips, add cities, auto-generate itinerary, adjust by preferences (pace, interests, budget), export to mobile.Non-functional constraints: P95 itinerary generation under 4 seconds for 7-day trips. Store PII securely. Offline read mode on mobile.Out of scope: airline booking, hotel payments.</span>
</code></pre>
<p>It will generate a markdown file with an initial specification based on your request. The more context and detail you provide, the stronger that first draft will be.</p>
<p>Keep in mind: this file isn’t a finished spec. It’s a starting point. It is usually easier to edit a draft than to write from a blank page.. You’ll need to review it carefully—read through, validate assumptions, adjust for your actual needs, and fill in any gaps. </p>
<p>The agent may flag certain sections with <strong>[NEEDS CLARIFICATION]</strong>, which is a prompt for you to remove ambiguity or make key project decisions before moving forward.</p>
<p>Here’s an example excerpt from the generated spec document from the command above:</p>
<pre><code class="lang-bash"><span class="hljs-comment">## Requirements *(mandatory)*</span>
<span class="hljs-comment">### Functional Requirements</span>
- **FR-001**: System MUST generate day-by-day itineraries <span class="hljs-keyword">for</span> multi-city trips up to [NEEDS CLARIFICATION: maximum trip length not specified - 30 days? 90 days?]
- **FR-002**: System MUST optimize travel routes between cities to minimize travel time and costs
- **FR-003**: Users MUST be able to input travel preferences including dates, cities, interests, and budget ranges
- **FR-004**: System MUST provide activity suggestions categorized by interests (art, food, culture, adventure, family-friendly, etc.)
- **FR-005**: System MUST calculate and display estimated costs <span class="hljs-keyword">for</span> activities and transportation
</code></pre>
<p>Notice [NEEDS CLARIFICATION: maximum trip length not specified – 30 days? 90 days?]</p>
<p>Since we didn’t say anything about this, it’s asking us to adjust the specs and make it clear for the Agent and other people involved in this project.</p>
<h3 id="heading-2-plan"><strong>2) Plan</strong></h3>
<p><strong>Goal:</strong> translate the product spec into a technical plan. Choose stack, architecture, and integration boundaries. Call out risks.</p>
<p><strong>Trip-planner example (technical plan highlights):</strong></p>
<ul>
<li><p><strong>Architecture:</strong> API-first. Backend service + vector store for POI embeddings. Frontend web + mobile shell. (<em>POI stands for “Point of Interest,” such as landmarks, attractions, or restaurants that the planner uses to build itineraries.)</em></p>
</li>
<li><p><strong>AI:</strong> use a routing agent to choose POIs, a scheduler to pack days, a critic to check timing and transit.</p>
</li>
<li><p><strong>Data:</strong> city catalogs, POI metadata, transit times.</p>
</li>
<li><p><strong>Performance:</strong> target end-to-end plan in under 4 seconds at P95.</p>
</li>
<li><p><strong>Security:</strong> redact PII in logs, encrypt at rest.</p>
</li>
<li><p><strong>Risks:</strong> rate limits on external APIs, cost spikes from long prompts, cold starts.</p>
</li>
</ul>
<p>With Spec Kit you can use <strong>/plan</strong> to record stack and architecture choices in the repo next to the spec so agents do not guess.  </p>
<p>You don’t have to stick to any strict format when using this command. It accepts a freeform text prompt, so just describe your stack, tools, and architectural choices in your own words. Use commas, semicolons, or even line breaks if you like. The tool reads your input in context and turns it into a structured technical plan automatically.</p>
<p>That flexibility is by design. The idea is to capture what you mean, your technologies, roles, dependencies, not to force you into some rigid syntax.</p>
<p>If you prefer, you can also write your input as bullet points or separate lines. The result will be exactly the same.</p>
<pre><code class="lang-bash">/plan Stack: FastAPI + Postgres + Redis; Next.js front end; mobile via Expo. Agents: planner, scheduler, critic. Use OpenRouteService <span class="hljs-keyword">for</span> travel <span class="hljs-built_in">times</span>.
</code></pre>
<p>Once the spec looks solid and you run this command, the workflow shifts into more detailed implementation planning. At this stage, the spec doesn’t just describe <em>what</em> to build, it begins shaping <em>how</em> to build it, aligning development with the architecture and direction you’ve defined.</p>
<p><img src="https://cdn-blog.scalablepath.com/uploads/2025/11/spec-contract-documents.png" alt /></p>
<p><img src="https://cdn-blog.scalablepath.com/uploads/2025/11/spec-driven-development-prompt-1024x621.png" alt /></p>
<p>At this stage, the spec starts shaping implementation. The plan reduces ambiguity and accelerates reviews.. Remember that using these tools is just a helper for writing great specifications and feeding it to the agent. It’s always your responsibility to check and adjust anything in the generated specification.</p>
<h3 id="heading-3-break-into-tasks"><strong>3) Break into Tasks</strong></h3>
<p><img src="https://cdn-blog.scalablepath.com/uploads/2025/11/spec-driven-development-tasks-1024x216.png" alt /></p>
<p><strong>Goal:</strong> convert the plan into an ordered, testable task list with acceptance criteria. Include owner, dependencies, and links back to spec sections.</p>
<p><strong>Trip-planner example (tasks):</strong></p>
<ul>
<li><p>API contract for itinerary generation, with request/response schemas.</p>
</li>
<li><p>Agent prompts and guardrails for planner, scheduler, critic.</p>
</li>
<li><p>Data loaders for POI metadata.</p>
</li>
<li><p>Caching and rate-limit handling.</p>
</li>
<li><p>Frontend flows: create trip, edit preferences, view itinerary, export.</p>
</li>
<li><p>Observability: timing spans, cost tracking, error taxonomies.</p>
</li>
</ul>
<p>The list you see above is the kind of output you’ll get when you run the <strong>/tasks</strong> command in Spec Kit. Behind the scenes, the tool scans your <strong>SPEC.md</strong> and <strong>PLAN.md</strong> files, then builds a clear, connected backlog, complete with acceptance criteria, dependencies, and links back to the right sections of your spec.</p>
<p>Basically, you don’t have to handwrite every task yourself. Spec Kit drafts them automatically based on your project’s context. From there, you can review, tweak, and rearrange the list however you like before assigning owners or kicking off development.</p>
<p>So can just run <strong>/tasks</strong> to generate an actionable backlog that references the spec and the plan.</p>
<pre><code class="lang-basic">/tasks
</code></pre>
<p><img src="https://cdn-blog.scalablepath.com/uploads/2025/11/spec-driven-development-tasks-breakdown-1024x659.png" alt /></p>
<h3 id="heading-4-implement"><strong>4) Implement</strong></h3>
<p><strong>Goal:</strong> execute tasks in small slices. Keep agents inside your constraints by pointing them back to SPEC.md and PLAN.md for every change.</p>
<p><strong>Trip-planner example (one slice):</strong></p>
<ul>
<li><p>Implement POST /itinerary with schema validation and budget checks.</p>
</li>
<li><p>Add scheduler agent prompt that respects daily walking limits and opening hours.</p>
</li>
<li><p>Cache POI lookups and transit matrices.</p>
</li>
</ul>
<p>Agents can work from the spec, the plan, and the task file, rather than ad-hoc prompts.</p>
<h3 id="heading-5-tests"><strong>5) Tests</strong></h3>
<p><strong>Goal:</strong> attach tests directly to requirements so you can trace “what was promised” to “what was delivered.”<br />Spec-Kit doesn’t include a separate /test command, testing is built into the workflow itself.</p>
<p>By default, it follows a <a target="_blank" href="https://www.scalablepath.com/qa/getting-started-test-driven-development">test-driven development (TDD</a><strong>)</strong> structure: when you run /tasks, test-related items are automatically included and ordered <strong>before</strong> implementation tasks. This ensures that requirements are verified early and consistently.  </p>
<p>If your project doesn’t follow TDD, you can explicitly state that in your specification to adjust task ordering.</p>
<p><strong>Trip-planner example (tests):</strong></p>
<ul>
<li><p><strong>Contract tests:</strong> request with 3 cities returns day-by-day plan with transit times and costs.</p>
</li>
<li><p><strong>Property tests:</strong> no day exceeds 10 km walking; opening hours respected.</p>
</li>
<li><p><strong>Performance checks:</strong> P95 latency under 4 seconds for a 7-day trip.</p>
</li>
<li><p><strong>Security checks:</strong> PII never logged; redaction verified.</p>
</li>
</ul>
<p>The spec and plan drive validations and checkpoints. Many teams pair this with contract-first samples or API specs that evolve alongside features.</p>
<h3 id="heading-6-maintain"><strong>6) Maintain</strong></h3>
<p><strong>Goal:</strong> evolve safely as requirements change. Update the spec first, regenerate plan and tasks, and let agents refactor within those boundaries.</p>
<p><strong>Trip-planner example (change request):</strong></p>
<ul>
<li><p>Add “family mode” that favors kid-friendly POIs and shorter walking segments.</p>
</li>
<li><p>Update spec.md constraints, re-run planning, regenerate affected tasks, adjust prompts, and extend tests for new rules.</p>
</li>
<li><p>Keep a changelog of spec revisions so future contributors see why trade-offs were made.</p>
</li>
</ul>
<p>SDD treats the spec as a living artifact that feeds tasks, prompts, and validations. That makes mid-course corrections cheaper and more predictable.</p>
<h4 id="heading-handling-partial-updates-and-re-planning"><strong>Handling Partial Updates and Re-Planning</strong></h4>
<p>One common question is what happens when you tweak the spec and ask the planner to run again, after some of the code already exists. Because large language models don’t produce identical results every time, a re-plan can occasionally spill over and adjust parts of the project you didn’t mean to touch.</p>
<p>Teams usually rely on two practical workarounds to keep things under control:</p>
<p><strong>1. Mark completed tasks as done</strong></p>
<p>Spec-Kit keeps track of which tasks have been completed. When you flag something as “done” before re-planning, you’re effectively telling the system, and the AI agent behind it, <em>hands off this section</em>.</p>
<p>That said, the protection isn’t perfect. Users have noticed that a full re-plan can sometimes nudge or overwrite these “done” areas anyway. So it’s still smart to read through the new output before merging it back into the main branch.</p>
<p><strong>2. Create a separate spec for new features</strong></p>
<p>If you’re adding a big feature or experimenting with something fresh, it’s cleaner to spin up a new spec branch (for example, 001-feature-family-mode) instead of editing the main one. This approach follows Spec-Kit’s branch-based workflow and keeps your new code isolated, minimizing any knock-on effects elsewhere in the project.</p>
<p>Both methods are community-tested stopgaps until Spec-Kit offers true incremental-update support. They depend on the LLM respecting boundaries rather than enforcing them, which means a human review step isn’t optional, it’s essential before you accept any regenerated plans or tasks.</p>
<h2 id="heading-how-ai-tools-fit-into-the-process"><strong>How AI Tools Fit Into the Process</strong></h2>
<p>Every phase of this workflow can be supported by different tools. Some teams keep it simple with markdown and GitHub. Others lean on AI-native platforms like Kiro or Claude Code.</p>
<p>What matters most is consistency. Once you decide where your spec lives, make sure every plan, task, and test points back to that same source of truth.</p>
<p>A disciplined setup beats a fancy tool every time.</p>
<h3 id="heading-note-on-tooling"><strong>Note on tooling</strong></h3>
<p>I’ve used GitHub’s Spec Kit here because it offers a ready path for <strong>spec → plan → tasks → implementation</strong> and ships repo-friendly templates. Any well-documented specification document can work, as long as you cover the main areas: goals, users, scope, constraints, architecture, data contracts, acceptance criteria, and tests. Use the tools that fit your environment; the principle remains the same.</p>
<p>So feel free to write your own specification document or use other templates. The most important thing here is to provide a concrete path for AI agents as a single source of truth. They won’t be assuming anything on the project, they just execute it according to what you’ve specified and then you can review the work.</p>
<p>The tool does not replace judgment. Teams still need to review, refine, and approve specs before coding begins.</p>
<h2 id="heading-common-pitfalls-when-applying-spec-driven-development"><strong>Common Pitfalls When Applying Spec-Driven Development</strong></h2>
<p>Even teams that adopt the right workflow can stumble if they treat specs as one-time tasks instead of living assets.</p>
<h3 id="heading-over-specifying-too-early"><strong>Over-specifying too early</strong></h3>
<p>You don’t need to capture every pixel or parameter before building. Specs should evolve with insight. <a target="_blank" href="https://kpavlov.me/blog/contract-first-vs-contract-last/">Contract-first research on APIs</a> shows that an early, lean contract accelerates feedback; you can refine details once real data surfaces. Aim for just-enough structure to support test automation and AI generation, then iterate as you validate assumptions.</p>
<h3 id="heading-letting-specs-drift"><strong>Letting specs drift</strong></h3>
<p> When changes sneak into production without a corresponding spec update, reviewers lose confidence in both sources. Treat the document as the change-log’s front line: update the spec first, then merge the code. This discipline preserves traceability for later audits and enables AI agents to generate accurate tests or documentation against the newest contract.</p>
<h3 id="heading-no-clear-ownership"><strong>No clear ownership</strong></h3>
<p>Someone must be accountable for the health of the spec. Appoint a “spec steward”, a role that rotates but always exists. The steward ensures merge requests include spec updates, flags inconsistencies early, and champions living documentation at retrospectives. Without that curator, specs quickly fall prey to “someone else will fix it later” syndrome.</p>
<h3 id="heading-focusing-on-the-what-instead-of-the-why"><strong>Focusing on the what instead of the why</strong></h3>
<p>A great spec captures rationale as well as requirements. Future teammates—human or AI—need context to make confident changes. Including the business driver (“reduce checkout time to under two seconds”) or the risk mitigated (“meet SOC 2 audit log mandates”) helps newcomers reason about trade-offs instead of repeating past debates.</p>
<h2 id="heading-scaling-spec-driven-workflows-across-teams"><strong>Scaling Spec-Driven Workflows Across Teams</strong></h2>
<p>When more developers, or AI agents, join a project, the benefits of Spec-Driven Development multiply.</p>
<h3 id="heading-a-shared-vocabulary-across-squads"><strong>A Shared vocabulary across squads</strong></h3>
<p>When multiple feature crews reference the same glossary of user flows, metrics, and error states, conversations stay crisp. Specs eliminate dueling definitions of “session,” “tenant,” or “SLA,” lowering the friction that often plagues cross-functional work.</p>
<h3 id="heading-accelerated-onboarding"><strong>Accelerated onboarding</strong></h3>
<p>Instead of wading through endless chat threads, new hires skim change-tracked specs to see how requirements evolved. A well-curated history section reads like an executive summary of design debates, letting engineers reach productive coding in days rather than weeks.</p>
<h3 id="heading-safe-parallel-development"><strong>Safe Parallel development</strong></h3>
<p>Teams can code separate modules at the same time when interfaces are frozen in a contract. Mock servers and test harnesses generated from that specification surface integration issues early, long before staging, cutting costly rework.</p>
<h3 id="heading-auditability-for-regulated-domains"><strong>Auditability for regulated domains</strong></h3>
<p>Financial-services or medical-device teams often need a provable chain from requirement to implementation. A spec commit linked to every release provides that chain and satisfies auditors who demand evidence of due diligence. Siemens Polarion research shows that failing to maintain requirement-to-code traceability is now a top cause of non-compliance penalties.</p>
<h2 id="heading-when-to-introduce-this-workflow"><strong>When to Introduce This Workflow</strong></h2>
<p>Not every project needs this level of structure. A full spec-first approach delivers the biggest return when you’re working on:</p>
<h3 id="heading-complex-systems-with-many-contributors"><strong>Complex systems with many contributors</strong></h3>
<p>Microservice architectures, multi-repo front-ends, and AI-powered back-ends thrive when every boundary is explicit. The spec shields each team from internal churn and enables contract testing to catch interface regressions automatically.</p>
<h3 id="heading-high-stakes-features"><strong>High-stakes features</strong></h3>
<p>Payment flows, healthcare diagnostics, or safety-critical automation cannot rely on implicit tribal knowledge. Formal specs encode performance, security, and reliability thresholds so CI tooling can block a release that drifts below the bar.</p>
<h3 id="heading-long-term-projects-that-will-outlive-the-founding-team"><strong>Long-term projects that will outlive the founding team</strong></h3>
<p>Turnover is inevitable. A living specification serves as institutional memory, preserving design intent for future maintainers who would otherwise reverse-engineer decisions from commit history.</p>
<p>For quick prototypes or design experiments, you can lighten the process: a short spec, a simple plan, and a few manual notes are often enough to preserve intent without slowing momentum.</p>
<h2 id="heading-final-thoughts"><strong>Final Thoughts</strong></h2>
<p>Spec-Driven Development doesn’t replace creativity, it gives it form. By anchoring AI-driven work in clear intent and traceable artifacts, you build systems that ship faster and evolve more safely.</p>
<p>Whether you’re using GitHub Spec Kit, Claude Code, or a custom markdown setup, the rhythm stays the same:</p>
<p><strong>specify clearly, plan with intent, test without compromise, and evolve with purpose.</strong></p>
<p>That’s how teams move from <em>vibe-coding</em> to real engineering discipline.</p>
]]></content:encoded></item><item><title><![CDATA[Vibe Coding vs Spec-Driven Development]]></title><description><![CDATA[Introduction
One of the most common ways to critique vibe coding is by pointing to technical limitations such as context length, token limits, or LLM “amnesia.” While those are real constraints, the deeper issue based on my experience is the workflow...]]></description><link>https://blogs.praneshpyarashrestha.com.np/vibe-coding-vs-spec-driven-development</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/vibe-coding-vs-spec-driven-development</guid><category><![CDATA[vibe coding]]></category><category><![CDATA[Spec-Driven-Development]]></category><category><![CDATA[spec-kit]]></category><category><![CDATA[#PromptEngineering]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Sat, 27 Dec 2025 11:07:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1766834411692/b1a39e24-c83b-4ca1-9016-04f04e39a063.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction"><strong>Introduction</strong></h2>
<p>One of the most common ways to critique vibe coding is by pointing to technical limitations such as context length, token limits, or LLM “amnesia.” While those are real constraints, the deeper issue based on my experience is the workflow.</p>
<p>In real life, we rarely expect a human counterpart to take a single-line request or a short PRD and return a perfectly working solution. We expect clarifying questions, intermediate artifacts, reviews, and course correction which can be expensive. Over time, engineering practices such as Behaviour-Driven Development emerged precisely to help teams articulate intent clearly before implementation by promoting better dialogue between stakeholders.</p>
<p>When working with AI coding agents, the same principle applies. If we cannot articulate our intent clearly to ourselves first, what eventually gets built will almost certainly deviate from what we originally wanted, regardless of how capable the model is.</p>
<p>This article looks at the fundamental workflow differences between vibe coding and spec-driven development, and how those workflows either amplify or reduce intent-to-implementation deviation.</p>
<h2 id="heading-the-vibe-coding-lifecycle"><strong>The Vibe Coding Lifecycle</strong></h2>
<p>In a typical vibe coding flow, we describe what we want in a single prompt, review the generated code, provide feedback, and iterate until we are satisfied. It is fast, flexible, and requires very little upfront planning.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1766833181581/5890b7bb-b56b-4c3e-8d31-a21df49862b2.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-how-vibe-coding-works"><strong>How Vibe Coding Works</strong></h3>
<p>The vibe coding workflow usually follows a linear loop:</p>
<ol>
<li><p><strong>Single-line prompt</strong> describing what needs to be built</p>
</li>
<li><p><strong>General-purpose agent</strong> that interprets the prompt and fills in gaps</p>
</li>
<li><p><strong>Code generation</strong> based on those assumptions</p>
</li>
<li><p><strong>Review and feedback</strong> from the human</p>
</li>
<li><p><strong>Iteration</strong> using the updated prompt or follow-up instructions</p>
</li>
</ol>
<p>This feels natural, especially because chat-based interfaces encourage getting something working quickly and using that output as the basis for further refinement. The workflow optimizes for speed and momentum.</p>
<h3 id="heading-implicit-assumptions-accumulate"><strong>Implicit Assumptions Accumulate</strong></h3>
<p>The core problem emerges as iterations progress.</p>
<p>Each prompt and correction focuses on the <em>current</em> concern. To satisfy new feedback, the agent often revises or overrides earlier decisions. Constraints that were previously implied or loosely stated are weakened or forgotten.</p>
<p>Initially, intent deviation may reduce as obvious gaps are fixed based on feedback. Over time, however, corrections become fragile. Changes in one area introduce regressions in another. The human ends up in a sustained negotiation loop with the agent, repeatedly restating intent in different ways to keep the output on track.</p>
<p>This is not a model failure, it is a workflow limitation where context is not managed effectively. Moreover, the other issue you might experience is you exhaust your premium requests quota to you coding agent.</p>
<h2 id="heading-the-spec-driven-development-workflow"><strong>The Spec-Driven Development Workflow</strong></h2>
<p>Spec-driven development takes a fundamentally different approach. Instead of starting with implementation, it focuses on establishing clear intent <em>before</em> asking the agent to write code.</p>
<p>By breaking work into explicit phases with review gates, the spec-driven workflow makes intent articulation deliberate and verifiable, significantly reducing downstream deviation.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1766832987932/62c6c365-54bf-4050-b5be-eda1ccd13297.png" alt /></p>
<h3 id="heading-the-four-phases-of-spec-driven-development"><strong>The Four Phases of Spec-Driven Development</strong></h3>
<p>Each tool may have a few more or a few less, however overall these aspects are usually covered.</p>
<h4 id="heading-phase-1-what-specify-propose-requirements">Phase 1: What (Specify / Propose / Requirements)</h4>
<p>This phase focuses on defining <strong>what</strong> needs to be built:</p>
<ul>
<li><p>Feature requirements and acceptance criteria</p>
</li>
<li><p>User needs and business goals</p>
</li>
<li><p>Scope, boundaries, and non-goals</p>
</li>
<li><p>Success metriccs</p>
</li>
</ul>
<h4 id="heading-phase-2-how-design-plan">Phase 2: How (Design / Plan)</h4>
<p>Once intent is clear, the next phase addresses <strong>how</strong> it will be implemented:</p>
<ul>
<li><p>Architecture and technical approach</p>
</li>
<li><p>Technology and pattern choices</p>
</li>
<li><p>Data models, APIs, and interfaces</p>
</li>
<li><p>Risks and dependencies</p>
</li>
</ul>
<h4 id="heading-phase-3-task-granular-steps-with-checks">Phase 3: Task (Granular Steps with Checks)</h4>
<p>With design approved, work is decomposed into concrete tasks:</p>
<ul>
<li><p>Small, verifiable work items</p>
</li>
<li><p>Clear validation criteria per task</p>
</li>
<li><p>Explicit dependencies and ordering</p>
</li>
<li><p>Testing and verification strategy</p>
</li>
</ul>
<p>At this point, task ordering and parallelization opportunities can be reviewed. Tasks may also be delegated to sub-agents, reducing context burden in the primary thread while keeping intent anchored.</p>
<h4 id="heading-phase-4-build-implementation">Phase 4: Build (Implementation)</h4>
<p>Only after intent, design, and tasks are validated does implementation begin:</p>
<ul>
<li><p>Tasks executed sequentially or in parallel</p>
</li>
<li><p>Validation against acceptance criteria</p>
</li>
<li><p>Automated tests run</p>
</li>
<li><p>Implementation reviewed against specs</p>
</li>
</ul>
<p><strong>Output:</strong> Working code that matches documented intent.</p>
<hr />
<h2 id="heading-conversation-matters"><strong>Conversation Matters</strong></h2>
<p>Spec-Driven Development is sometimes criticized as an anti-pattern because it appears to conflict with <em>“Working software over comprehensive documentation”</em> from the Agile Manifesto. This criticism often stems from viewing specs as artifacts rather than as a mechanism for intent negotiation.</p>
<p>To give you an analogy, Behaviour-Driven Development was never about Gherkin syntax for its own sake. It was about enabling collaboration between business and technology through structured conversation. That aligns with <em>“Collaboration over contract negotiation.”</em></p>
<p>Similarly, SDD facilitates structured conversation between humans and coding agents. Specs and plans are not the goal, they are scaffolding that helps clarify and stabilize intent.</p>
<p>Tooling quality and verbosity vary, but the underlying purpose remains the same, ensuring that intent is explicit, reviewable, and durable across iterations.</p>
<h2 id="heading-the-conclusion"><strong>The Conclusion</strong></h2>
<p>Vibe coding and spec-driven development represent two fundamentally different philosophies for working with AI coding agents.</p>
<p><strong>Vibe coding optimizes for speed.</strong> It favors rapid iteration, minimal planning, and flexibility. It works well for prototypes, scripts, and exploratory work.</p>
<p><strong>Spec-driven development optimizes for intent alignment.</strong> It emphasizes clarity, validation, and verifiable outcomes. This makes it better suited for production systems, team environments, and long-lived codebases, and, over time, even for smaller prototypes.</p>
<p>The critical differentiator is <strong>intent management</strong>.</p>
<p>Vibe coding accepts deviation as a cost of speed. Spec-driven development reduces deviation by introducing structure, review gates, and explicit intent articulation.</p>
<p>If intent matters beyond the next prompt, structure wins.</p>
]]></content:encoded></item><item><title><![CDATA[Context Engineering: AI Agents Fail on Bad Context, Not Bad Models]]></title><description><![CDATA[Your agent fails on a task. The conversation spans 50 turns. The model made decisions that don't make sense.
Your first thought: I need a better model.Here's what you should think instead: What's actually in my context window?
Think of your LLM as an...]]></description><link>https://blogs.praneshpyarashrestha.com.np/context-engineering</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/context-engineering</guid><category><![CDATA[context engineering]]></category><category><![CDATA[ai-agent]]></category><category><![CDATA[AI]]></category><category><![CDATA[#ai-tools]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Mon, 27 Oct 2025 15:41:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1761579601623/eecb2305-9963-4429-9f57-022e3be22d3b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Your agent fails on a task. The conversation spans 50 turns. The model made decisions that don't make sense.</p>
<p>Your first thought: <strong>I need a better model.</strong><br />Here's what you should think instead: <strong>What's actually in my context window?</strong></p>
<p>Think of your LLM as an engineer. A brilliant one. You keep upgrading - GPT-4 then GPT-5, then Claude Sonnet 4.1, then Sonnet 4.5. Each time, you're hiring someone smarter.</p>
<p>But here's what you're handing them:</p>
<ul>
<li><p>A desk with 50 browser tabs open</p>
</li>
<li><p>Three different sets of instructions that contradict each other</p>
</li>
<li><p>Printouts from projects completed 40 turns ago</p>
</li>
<li><p>Notes that are 70% irrelevant to the current task</p>
</li>
</ul>
<p><strong>The engineer isn't the problem. The workspace is.</strong></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>What’s Actually In Your Context Window</strong></div>
</div>

<p>Let's look at a typical AI agent at turn 50:</p>
<pre><code class="lang-plaintext">Token Breakdown:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
System prompt:            2,000 tokens
Tool results (47 turns):  85,000 tokens
Conversation history:     40,000 tokens  
Retrieved documents:      25,000 tokens
Few-shot examples:        8,000 tokens
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total:                   160,000 tokens
</code></pre>
<p>The problem? About 60% of those 85,000 tool result tokens are completely irrelevant to what the agent is doing right now.</p>
<p>Here's what that looks like:</p>
<p><img src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/02ebaa9d-4728-48c8-bfc5-1c29a59dec40/image.png?t=1760833139" alt /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Common Ways Bad Context Kills Agents</strong></div>
</div>

<h4 id="heading-1-signal-drowning"><strong>1. Signal Drowning</strong></h4>
<p>The instruction the agent needs is in the context. But it's buried under noise.</p>
<p>Let’s assume that you are building a database migration agent. Early on, you tell it: "When migrating users, check deleted_at and skip soft-deleted records."</p>
<p>By turn 45, your context is bloated.</p>
<p><em>“Old schema exploration logs. Connection test results from work that's already done. A posts migration that logged every single batch hundreds of repetitive "Fetched... Inserted..." lines. Debugging output from an issue that was fixed ten turns ago.”</em></p>
<p>All of this is still sitting in context.</p>
<p>When the agent finally migrates users, it processes 1,000 rows. 127 of them are soft-deleted. It inserts all of them anyway.</p>
<p>Your instruction was there, but it was <strong>competing for attention with mountains of stale logs</strong>. The field name "deleted_at" appeared everywhere in old documentation.</p>
<p>The model saw it but missed what to do with it.</p>
<p>Clean out completed work. Your context drops from 195,000 tokens to 12,000. Same instruction, but now the model actually pays attention to it.</p>
<h4 id="heading-2-conflicting-information"><strong>2. Conflicting Information</strong></h4>
<p>Your context accumulates contradictions. The model sees both instructions. It picks one. Sometimes it's the right one. Often it's not.</p>
<p>You're building a customer support agent that handles refund requests. Early in the conversation, you set a policy: "For orders under $50, approve refunds automatically without manager review."</p>
<p>Twenty turns later, you're dealing with fraud concerns. You add: "All refund requests require manager approval until further notice." You're testing stricter controls.</p>
<p>By turn 50, a customer requests a $30 refund. Both instructions are in context. The agent sees "approve refunds under $50 automatically" and also sees "all refunds require manager approval." It picks the second one i.e. requires manager approval. The request gets flagged for review.</p>
<p>But you've already resolved the fraud issue. You wanted the refund to go through automatically. The temporary restriction was meant to be removed. The model saw conflicting rules and picked the more recent one. You call it a <strong>model failure</strong>. It's a <strong>context failure</strong>.</p>
<p>When you update policies, remove the old ones. Or be explicit: "Fraud concerns resolved. Resume automatic approval for refunds under $50." Don't leave contradictory instructions in context and expect the model to figure out which one is current.</p>
<h4 id="heading-3-pattern-pollution"><strong>3. Pattern Pollution</strong></h4>
<p>You include few-shot examples to show the model how to use tools. But those examples demonstrate solving a different type of problem.</p>
<p>The model is an excellent mimic. It follows the pattern, not the reasoning. Your examples taught it the wrong thing.</p>
<p>Your code review agent learned from examples showing small PRs: fetch the file, analyze it carefully, provide feedback. Works great for focused changes.</p>
<p>Then someone submits an 87-file refactoring. The entire API is being restructured. Your agent does exactly what it learned - analyzes each file individually. By file 67, context is full and early files get truncated. Now file 72 references something from file 15, which is gone. The agent reports phantom errors (Phantom errors are bugs the agent <strong>imagines</strong> because it lost or never loaded the right context).</p>
<p>For massive refactors, you need a different approach: check the scope, understand the intent, sample key files, give high-level feedback. Your examples never showed that. The agent applied the wrong pattern because that's all it knew.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Context Quality Degrades Over Time</strong></div>
</div>

<p>Here's what happens as your agent runs:</p>
<p><img src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/39f73a6f-d06c-467a-8491-5e9e148cc0cb/image.png?t=1761439758" alt /></p>
<p>Early turns: clean context, good decisions.<br />Later turns: polluted context, degraded performance.</p>
<p>This isn't the model getting tired. This is your context window filling with garbage.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>The Model Upgrade Trap</strong></div>
</div>

<p>Let's do the math:</p>
<p><strong>Upgrading from Claude Sonnet 4 to Claude Opus 4:</strong><br />→ ~15% improvement in reasoning capability<br />→ Cost increase: significant</p>
<p><strong>Cleaning your context (removing 70k irrelevant tokens):</strong><br />→ ~40% improvement in task success rate<br />→ Cost increase: zero</p>
<p>You're paying for a smarter model to wade through your garbage.</p>
<p>Here's where the disconnect happens:</p>
<p><img src="https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/af1b8dd3-8144-47ad-8a8c-cdf07eef9673/diagram3_focus_vs_impact.png?t=1760831632" alt /></p>
<p>You're optimizing the wrong layer.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>What Good Context Looks Like</strong></div>
</div>

<p>The quality of your context is the single biggest factor that decides whether your agent works well at turn 50 or falls apart. Think of it like running a tight ship: everything on deck should serve the task at hand. No stale notes, no noise, no clutter.</p>
<p>Some simple rules to follow:</p>
<ol>
<li><p><strong>Only keep tool results relevant to the current subtask</strong><br /> Tool outputs pile up fast. By turn 50, your logs can be bigger than the actual task. Don’t keep every API response forever. Keep the latest outputs that the agent actually needs for the current subtask. Everything else should be either cleared or summarized.  </p>
<p> <strong>Why:</strong> Because when the model sees 10 logs that look similar, it can easily pick the wrong one.</p>
</li>
<li><p><strong>One clear source of truth for instructions</strong><br /> Agents break when they see two rules that contradict each other. If you update instructions, remove or clearly mark the old one as outdated.</p>
</li>
</ol>
<p>    <strong>Why:</strong> The model won’t magically know which rule is current. It’ll pick one. Often the wrong one.</p>
<ol start="3">
<li><strong>Keep the story short</strong><br /> A conversation that started clean can become a swamp by turn 40. Summarize past turns into a short, factual digest. Keep only the recent few turns that are still active. You don't need turn-by-turn history from 40 turns ago.</li>
</ol>
<p>    <strong>Why:</strong> The model doesn’t need to hold on to every step of how you got here. It just needs a clean summary of the key intent, decisions, and open threads.</p>
<ol start="4">
<li><p><strong>Similarity ≠ Relevance</strong><br /> Vector search gives you similar documents, not always useful ones. Before dumping them into context, ask: does this actually help with the task right now?</p>
<p> <strong>Why:</strong> Loading 5 “kind of similar” docs drowns the one that actually matters.</p>
</li>
<li><p><strong>Few-shot examples should match the problem</strong><br /> Your examples teach the model how to act. If your examples are about small code fixes but the task is a massive refactor, the model will copy the wrong behavior.</p>
<p> <strong>Why:</strong> While good examples guide the model, wrong examples may mislead it.</p>
</li>
</ol>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>How This Looks in Practice</strong></div>
</div>

<ul>
<li><p>Instead of 200k tokens of clutter, you have a lean 30–45k token window.</p>
</li>
<li><p>There’s only one instruction set, not five competing ones.</p>
</li>
<li><p>The agent has just enough history to understand the task, not your entire Slack transcript.</p>
</li>
<li><p>Every doc and example serves a purpose.</p>
</li>
</ul>
<pre><code class="lang-plaintext">Before:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total tokens:      160,000
Signal ratio:      30%
Task success:      41%
Model:             X
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

After context cleanup:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total tokens:      45,000
Signal ratio:      90%
Task success:      73%
Model:             X (same model)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
</code></pre>
<p>When your context looks like this, the same model that failed yesterday can suddenly perform far better - not because it got smarter, but because you stopped making it read the junk.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Check This Before Upgrading the Model</strong></div>
</div>

<p><strong>1.</strong> What percentage of my context window is actually relevant to the current task?<br />→ Open your context. Count tokens. How many are signal? How many are noise?</p>
<p><strong>2.</strong> Are there conflicting instructions anywhere in my context?<br />→ Search for phrases like "always," "never," "make sure to." Do they contradict?</p>
<p><strong>3.</strong> Am I keeping tool results I'll never reference again?<br />→ That database query from turn 8—does the agent need it at turn 50?</p>
<p><strong>4.</strong> Do my few-shot examples match the current problem type?<br />→ If you're doing analysis, don't show examples of data transformation.</p>
<p><strong>5.</strong> Have I summarized or cleared old conversation turns?<br />→ Someone said something 30 turns ago. Is it still relevant?</p>
<p>Fix what you find. Measure again. Then and only then consider if you need a better model.</p>
<p>The next time your agent fails and you think "I need a better model," stop.</p>
<p>Open your context window. Count the signal. Count the noise.</p>
<p>You're probably asking a brilliant engineer to work at a desk buried in printouts from last month's project.</p>
<p>Clean the desk first.</p>
<p>The model you have is likely good enough. Your context isn't.</p>
]]></content:encoded></item><item><title><![CDATA[Automate Your Viral Tweets with AI + n8n: A Complete Workflow Breakdown]]></title><description><![CDATA[In the age of personal branding, Twitter (now X) is a goldmine for audience building. But staying consistent with high-quality, niche-specific tweets is hard—unless you automate it.
This guide introduces a fully automated tweet generation and posting...]]></description><link>https://blogs.praneshpyarashrestha.com.np/n8n-tweets</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/n8n-tweets</guid><category><![CDATA[n8n]]></category><category><![CDATA[automation]]></category><category><![CDATA[AI-automation]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Sun, 18 May 2025 10:03:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1747562437603/831db0c0-8a33-4c41-93f5-ab905a6733dc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the age of personal branding, Twitter (now X) is a goldmine for audience building. But staying consistent with high-quality, niche-specific tweets is hard—unless you automate it.</p>
<p>This guide introduces a <strong>fully automated tweet generation and posting system</strong> built with <a target="_blank" href="https://n8n.io">n8n</a> and OpenAI’s GPT model. Whether you're a thought leader, startup founder, or digital philosopher, this system helps you post personalized, high-impact tweets on autopilot—without sounding like a bot.</p>
<p>I will also be sharing the JSON which you can directly use in n8n and configure the automation at the end of the blog.</p>
<h2 id="heading-the-mission">The Mission</h2>
<blockquote>
<p><em>Generate and post viral-quality tweets every 6 hours—with randomness, intelligence, and human-like tone.</em></p>
</blockquote>
<p>This project includes:</p>
<ul>
<li><p>Scheduled &amp; manual tweet generation</p>
</li>
<li><p>AI-generated tweets based on your persona</p>
</li>
<li><p>Tweet validation (length check)</p>
</li>
<li><p>Auto-posting to X (Twitter)</p>
</li>
</ul>
<h2 id="heading-workflow-overview"><strong>Workflow Overview</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747561528873/ca78a8dc-3d5d-4061-86bb-da5ec3423a3d.png" alt class="image--center mx-auto" /></p>
<p>Here’s the high-level pipeline:</p>
<ol>
<li><p><strong>Trigger</strong> (Scheduled or Manual)</p>
</li>
<li><p><strong>Configure Influencer Profile</strong></p>
</li>
<li><p><strong>Generate Tweet with GPT-4 Turbo</strong></p>
</li>
<li><p><strong>Validate Tweet Length</strong></p>
</li>
<li><p><strong>Post to Twitter</strong></p>
</li>
</ol>
<p>Let’s dive into each component 👇</p>
<h2 id="heading-1-scheduled-or-manual-triggers">1️⃣ Scheduled or Manual Triggers</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747561933950/bc67eb70-f5b7-4b34-98a8-328b31a40ecc.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-scheduled-trigger-every-6-hours">🕒 Scheduled Trigger (Every 6 Hours)</h3>
<p>This node schedules the workflow to run every 6 hours. It randomizes the minute field using:</p>
<pre><code class="lang-json">={{ Math.floor(Math.random() * 60) }}
</code></pre>
<p>This makes tweet times seem human—not robotic.</p>
<blockquote>
<p>Bonus: You can use this in tandem with a <strong>Manual Trigger Node</strong> for on-demand tweets (e.g. testing or instant publishing).</p>
</blockquote>
<h2 id="heading-2-configure-your-influencer-profile">2️⃣ Configure Your Influencer Profile</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747561987254/5a155a5c-af41-4280-a98f-196f5cf7acac.png" alt class="image--center mx-auto" /></p>
<p>The <code>Set</code> node acts like your <strong>persona engine</strong>. This is where you define your:</p>
<ul>
<li><p>🧭 Niche</p>
</li>
<li><p>✍️ Writing style</p>
</li>
<li><p>📚 Inspirational sources</p>
</li>
</ul>
<h3 id="heading-example-configuration">Example Configuration:</h3>
<ul>
<li><p><strong>Niche:</strong> Modern Stoicism for Tech &amp; Women in STEM</p>
</li>
<li><p><strong>Style:</strong> Personal, authentic, wisdom-driven</p>
</li>
<li><p><strong>Inspiration:</strong> Dale Carnegie, Jonah Berger, Brendan Cox, etc.</p>
</li>
</ul>
<p>This lets your AI write like <em>you</em> consistently, every single time.</p>
<h2 id="heading-3-ai-powered-tweet-generation">3️⃣ AI-Powered Tweet Generation</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747562008007/9241c107-d3c8-4bf0-99dc-d38a17940737.png" alt class="image--center mx-auto" /></p>
<p>The core of the workflow leverages <strong>OpenAI’s GPT-4 Turbo</strong> via n8n’s <code>@n8n/n8n-nodes-langchain.openAi</code> node.</p>
<h3 id="heading-prompt-engineering">Prompt Engineering:</h3>
<p>We simulate a top-tier influencer with rich context:</p>
<pre><code class="lang-json">- You are a successful modern Twitter influencer.
- Your writing style is {{ style }}
- Your inspiration is {{ inspiration }}
- Your niche is {{ niche }}
- Always return one tweet only, max <span class="hljs-number">280</span> chars, with emojis and hashtags.
</code></pre>
<p>It generates:</p>
<ul>
<li><p>Time-sensitive content (via <code>{{</code> <a target="_blank" href="http://DateTime.now"><code>DateTime.now</code></a><code>() }}</code>)</p>
</li>
<li><p>Viral hooks</p>
</li>
<li><p>Hashtags and formatting</p>
</li>
</ul>
<h2 id="heading-4-tweet-validation">4️⃣ Tweet Validation</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747562034131/5a87edca-ba49-4381-a15f-e0f78a0aa06a.png" alt class="image--center mx-auto" /></p>
<p>Tweets must be within <strong>280 characters</strong> to avoid errors. We use an <code>IF</code> node that checks:</p>
<pre><code class="lang-json">{{ $json.message.content.tweet.length }} &gt; <span class="hljs-number">280</span>
</code></pre>
<p>If too long, it loops back to regenerate from the same persona config. This ensures only compliant tweets make it through.</p>
<h2 id="heading-5-auto-posting-to-x-twitter">5️⃣ Auto-Posting to X (Twitter)</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1747562057030/ad40cb6a-9bd0-4816-8c99-d967a1699651.png" alt class="image--center mx-auto" /></p>
<p>The final step uses the <code>Twitter</code> node to <strong>automatically post</strong> the validated tweet.</p>
<p>You just sit back and watch your brand grow. 📈</p>
<blockquote>
<p>Note: You’ll need an authenticated Twitter/X OAuth credential configured in your n8n instance.</p>
</blockquote>
<p>This completes the entire workflow.</p>
<h2 id="heading-sticky-notes-as-documentation">📌 Sticky Notes as Documentation</h2>
<p>Throughout the workflow, <code>Sticky Note</code> nodes are used to visually document steps:</p>
<ul>
<li><p>Scheduled Posting</p>
</li>
<li><p>Profile Setup</p>
</li>
<li><p>Tweet Generation</p>
</li>
<li><p>Validation</p>
</li>
<li><p>Posting</p>
</li>
</ul>
<p>This helps when collaborating or revisiting after a while.</p>
<hr />
<h2 id="heading-use-cases">💡 Use Cases</h2>
<p>This workflow is perfect for:</p>
<ul>
<li><p><strong>Niche content creators</strong></p>
</li>
<li><p><strong>Startup founders sharing insights</strong></p>
</li>
<li><p><strong>Personal brand builders</strong></p>
</li>
<li><p><strong>Newsletter or podcast creators cross-posting quotes</strong></p>
</li>
</ul>
<h2 id="heading-final-thoughts">🎯 Final Thoughts</h2>
<p>This isn't just automation—it's <strong>personalized content delivery at scale</strong>. With n8n and GPT, you're building a system that learns your tone, thinks like you, and tweets like a real human.</p>
<p>No more writer's block. No more forgetting to post. Just a consistent stream of authentic, high-impact tweets that resonate with your audience.</p>
<p>Resource:</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Tweet Generation"</span>,
  <span class="hljs-attr">"nodes"</span>: [
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"content"</span>: <span class="hljs-string">"## Scheduled posting \nWrite a tweet every 6 hours and randomize the minutes that it's posted at to make it seem natural.\n"</span>,
        <span class="hljs-attr">"height"</span>: <span class="hljs-number">265</span>,
        <span class="hljs-attr">"width"</span>: <span class="hljs-number">389</span>
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"12eb0a3e-df75-4a4b-8708-1de6f43337c1"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Sticky Note"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.stickyNote"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">0</span>,
        <span class="hljs-number">0</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"text"</span>: <span class="hljs-string">"={{ $json.message.content.tweet }}"</span>,
        <span class="hljs-attr">"additionalFields"</span>: {}
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"ae3e9f37-aa05-4c45-83f2-ab18abda3beb"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Post tweet"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.twitter"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">2020</span>,
        <span class="hljs-number">120</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">2</span>,
      <span class="hljs-attr">"credentials"</span>: {
        <span class="hljs-attr">"twitterOAuth2Api"</span>: {
          <span class="hljs-attr">"id"</span>: <span class="hljs-string">"HGysfpMe0rlrAk7O"</span>,
          <span class="hljs-attr">"name"</span>: <span class="hljs-string">"X account"</span>
        }
      }
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"rule"</span>: {
          <span class="hljs-attr">"interval"</span>: [
            {
              <span class="hljs-attr">"field"</span>: <span class="hljs-string">"hours"</span>,
              <span class="hljs-attr">"hoursInterval"</span>: <span class="hljs-number">6</span>,
              <span class="hljs-attr">"triggerAtMinute"</span>: <span class="hljs-string">"={{ Math.floor(Math.random() * 60) }}"</span>
            }
          ]
        }
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"ecb11468-a3fb-4f2b-a155-02821e89cd33"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Schedule posting every 6 hours"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.scheduleTrigger"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">220</span>,
        <span class="hljs-number">100</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1.1</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {},
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"5160c946-5bca-479e-b422-16833eca51b0"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Trigger posting manually"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.manualTrigger"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">220</span>,
        <span class="hljs-number">420</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"content"</span>: <span class="hljs-string">"## Configure influencer profile \nSet your target niche, writing style, and inspiration.\n"</span>,
        <span class="hljs-attr">"height"</span>: <span class="hljs-number">265</span>,
        <span class="hljs-attr">"width"</span>: <span class="hljs-number">389</span>
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"aabe700c-0dd7-45b1-acea-64f05e1a3bf3"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Sticky Note1"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.stickyNote"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">440</span>,
        <span class="hljs-number">0</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"content"</span>: <span class="hljs-string">"## Generate tweet\nGenerate a potentially viral tweet based on your configuration."</span>,
        <span class="hljs-attr">"height"</span>: <span class="hljs-number">265</span>,
        <span class="hljs-attr">"width"</span>: <span class="hljs-number">389</span>
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"860b7afd-1583-49c6-ba82-40b9ebeb44df"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Sticky Note3"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.stickyNote"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">880</span>,
        <span class="hljs-number">0</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"content"</span>: <span class="hljs-string">"## Validate tweet\nIf the generated tweet does not meet length constraints, regenerate it."</span>,
        <span class="hljs-attr">"height"</span>: <span class="hljs-number">265</span>,
        <span class="hljs-attr">"width"</span>: <span class="hljs-number">389</span>
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"0f5423ca-b292-4f91-b08c-9067888ff1b3"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Sticky Note4"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.stickyNote"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">1320</span>,
        <span class="hljs-number">0</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"content"</span>: <span class="hljs-string">"## Post the tweet\nPost the tweet to your X account."</span>,
        <span class="hljs-attr">"height"</span>: <span class="hljs-number">265</span>,
        <span class="hljs-attr">"width"</span>: <span class="hljs-number">389</span>
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"a1fff191-e1e8-433b-a228-850bcd72efc8"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Sticky Note5"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.stickyNote"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">1760</span>,
        <span class="hljs-number">0</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"conditions"</span>: {
          <span class="hljs-attr">"options"</span>: {
            <span class="hljs-attr">"leftValue"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-attr">"caseSensitive"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-attr">"typeValidation"</span>: <span class="hljs-string">"strict"</span>
          },
          <span class="hljs-attr">"combinator"</span>: <span class="hljs-string">"and"</span>,
          <span class="hljs-attr">"conditions"</span>: [
            {
              <span class="hljs-attr">"id"</span>: <span class="hljs-string">"0a6ebbb6-4b14-4c7e-9390-215e32921663"</span>,
              <span class="hljs-attr">"operator"</span>: {
                <span class="hljs-attr">"type"</span>: <span class="hljs-string">"number"</span>,
                <span class="hljs-attr">"operation"</span>: <span class="hljs-string">"gt"</span>
              },
              <span class="hljs-attr">"leftValue"</span>: <span class="hljs-string">"={{ $json.message.content.tweet.length }}"</span>,
              <span class="hljs-attr">"rightValue"</span>: <span class="hljs-number">280</span>
            }
          ]
        },
        <span class="hljs-attr">"options"</span>: {}
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"754254d7-2656-4412-9b8b-6108f3c08687"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Verify tweet constraints"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.if"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">1560</span>,
        <span class="hljs-number">100</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">2</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"content"</span>: <span class="hljs-string">"## On-demand posting \nWrite a tweet on demand, when you manually run your workflow.\n"</span>,
        <span class="hljs-attr">"height"</span>: <span class="hljs-number">265</span>,
        <span class="hljs-attr">"width"</span>: <span class="hljs-number">389</span>
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"39e837a9-a8b9-4c0f-8273-b3742158e4e8"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Sticky Note2"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.stickyNote"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">0</span>,
        <span class="hljs-number">320</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1</span>
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"modelId"</span>: {
          <span class="hljs-attr">"__rl"</span>: <span class="hljs-literal">true</span>,
          <span class="hljs-attr">"mode"</span>: <span class="hljs-string">"list"</span>,
          <span class="hljs-attr">"value"</span>: <span class="hljs-string">"gpt-4-turbo-preview"</span>,
          <span class="hljs-attr">"cachedResultName"</span>: <span class="hljs-string">"GPT-4-TURBO-PREVIEW"</span>
        },
        <span class="hljs-attr">"messages"</span>: {
          <span class="hljs-attr">"values"</span>: [
            {
              <span class="hljs-attr">"content"</span>: <span class="hljs-string">"=You are a successful modern Twitter influencer. Your tweets always go viral. "</span>,
              <span class="hljs-attr">"role"</span>: <span class="hljs-string">"system"</span>
            },
            {
              <span class="hljs-attr">"content"</span>: <span class="hljs-string">"=You have a specific writing style: {{ $json.style }}"</span>,
              <span class="hljs-attr">"role"</span>: <span class="hljs-string">"system"</span>
            },
            {
              <span class="hljs-attr">"content"</span>: <span class="hljs-string">"=You follow the principles described in your inspiration sources closely and you write your tweets based on that: {{ $json.inspiration }}"</span>,
              <span class="hljs-attr">"role"</span>: <span class="hljs-string">"system"</span>
            },
            {
              <span class="hljs-attr">"content"</span>: <span class="hljs-string">"=You have a very specific niche: {{ $json.niche }}"</span>,
              <span class="hljs-attr">"role"</span>: <span class="hljs-string">"system"</span>
            },
            {
              <span class="hljs-attr">"content"</span>: <span class="hljs-string">"=Answer with the viral tweet and nothing else as a response. Keep the tweet within 280 characters. Current date and time are {{DateTime.now()}}. Add hashtags and emojis where relevant."</span>,
              <span class="hljs-attr">"role"</span>: <span class="hljs-string">"system"</span>
            },
            {
              <span class="hljs-attr">"content"</span>: <span class="hljs-string">"Write a tweet that is certain to go viral. Take your time in writing it. Think. Use the vast knowledge you have."</span>
            }
          ]
        },
        <span class="hljs-attr">"jsonOutput"</span>: <span class="hljs-literal">true</span>,
        <span class="hljs-attr">"options"</span>: {}
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"d0c6067b-5ac0-4225-8e00-5291dd9d319d"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Generate tweet content"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"@n8n/n8n-nodes-langchain.openAi"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">980</span>,
        <span class="hljs-number">100</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">1</span>,
      <span class="hljs-attr">"credentials"</span>: {
        <span class="hljs-attr">"openAiApi"</span>: {
          <span class="hljs-attr">"id"</span>: <span class="hljs-string">"jaspGfKySbP3MuZ8"</span>,
          <span class="hljs-attr">"name"</span>: <span class="hljs-string">"OpenAi account"</span>
        }
      }
    },
    {
      <span class="hljs-attr">"parameters"</span>: {
        <span class="hljs-attr">"assignments"</span>: {
          <span class="hljs-attr">"assignments"</span>: [
            {
              <span class="hljs-attr">"id"</span>: <span class="hljs-string">"45268b04-68a1-420f-9ad2-950844d16af1"</span>,
              <span class="hljs-attr">"name"</span>: <span class="hljs-string">"niche"</span>,
              <span class="hljs-attr">"type"</span>: <span class="hljs-string">"string"</span>,
              <span class="hljs-attr">"value"</span>: <span class="hljs-string">"Modern Stoicism for Tech &amp; Wisdom Seekers. You tweet timeless Stoic wisdom—quotes, principles, and real-life applications—blended with modern insights for tech, productivity, and digital well-being, appealing to both philosophy lovers and tech-savvy minds (especially women in STEM). Whether it’s Marcus Aurelius on resilience, how Stoicism improves coding focus, or managing startup stress with Epictetus’ mindset, you make ancient philosophy practical for today’s thinkers, builders, and ambitious women navigating tech’s challenges. Personal stories, tech-friendly Stoic tips, and a touch of wit keep it engaging."</span>
            },
            {
              <span class="hljs-attr">"id"</span>: <span class="hljs-string">"d95f4a1c-ab1c-4eca-8732-3d7a087f82d8"</span>,
              <span class="hljs-attr">"name"</span>: <span class="hljs-string">"style"</span>,
              <span class="hljs-attr">"type"</span>: <span class="hljs-string">"string"</span>,
              <span class="hljs-attr">"value"</span>: <span class="hljs-string">"All of your tweets are very personal. "</span>
            },
            {
              <span class="hljs-attr">"id"</span>: <span class="hljs-string">"1ee088f7-7021-48c0-bcb7-d1011eb0db3d"</span>,
              <span class="hljs-attr">"name"</span>: <span class="hljs-string">"inspiration"</span>,
              <span class="hljs-attr">"type"</span>: <span class="hljs-string">"string"</span>,
              <span class="hljs-attr">"value"</span>: <span class="hljs-string">"Your inspiration comes from tens of books on stoicism, psychology, tech experience and how to influence people. Books such as \"Contagious\" by Jonah Bergen, \"How To Be Internet Famous\" by Brendan Cox, \"How to Win Friends and Influence People\" by Dale Carnegie, and \"Influencers and Creators\" by Robert V Kozinets, Ulrike Gretzel, Rossella Gambetti strongly influence the way you write your tweets. "</span>
            }
          ]
        },
        <span class="hljs-attr">"options"</span>: {}
      },
      <span class="hljs-attr">"id"</span>: <span class="hljs-string">"19fe9fc0-2366-4e23-8c18-431fb7445004"</span>,
      <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Configure your influencer profile"</span>,
      <span class="hljs-attr">"type"</span>: <span class="hljs-string">"n8n-nodes-base.set"</span>,
      <span class="hljs-attr">"position"</span>: [
        <span class="hljs-number">660</span>,
        <span class="hljs-number">100</span>
      ],
      <span class="hljs-attr">"typeVersion"</span>: <span class="hljs-number">3.3</span>
    }
  ],
  <span class="hljs-attr">"pinData"</span>: {},
  <span class="hljs-attr">"connections"</span>: {
    <span class="hljs-attr">"Generate tweet content"</span>: {
      <span class="hljs-attr">"main"</span>: [
        [
          {
            <span class="hljs-attr">"node"</span>: <span class="hljs-string">"Verify tweet constraints"</span>,
            <span class="hljs-attr">"type"</span>: <span class="hljs-string">"main"</span>,
            <span class="hljs-attr">"index"</span>: <span class="hljs-number">0</span>
          }
        ]
      ]
    },
    <span class="hljs-attr">"Trigger posting manually"</span>: {
      <span class="hljs-attr">"main"</span>: [
        [
          {
            <span class="hljs-attr">"node"</span>: <span class="hljs-string">"Configure your influencer profile"</span>,
            <span class="hljs-attr">"type"</span>: <span class="hljs-string">"main"</span>,
            <span class="hljs-attr">"index"</span>: <span class="hljs-number">0</span>
          }
        ]
      ]
    },
    <span class="hljs-attr">"Verify tweet constraints"</span>: {
      <span class="hljs-attr">"main"</span>: [
        [
          {
            <span class="hljs-attr">"node"</span>: <span class="hljs-string">"Configure your influencer profile"</span>,
            <span class="hljs-attr">"type"</span>: <span class="hljs-string">"main"</span>,
            <span class="hljs-attr">"index"</span>: <span class="hljs-number">0</span>
          }
        ],
        [
          {
            <span class="hljs-attr">"node"</span>: <span class="hljs-string">"Post tweet"</span>,
            <span class="hljs-attr">"type"</span>: <span class="hljs-string">"main"</span>,
            <span class="hljs-attr">"index"</span>: <span class="hljs-number">0</span>
          }
        ]
      ]
    },
    <span class="hljs-attr">"Schedule posting every 6 hours"</span>: {
      <span class="hljs-attr">"main"</span>: [
        [
          {
            <span class="hljs-attr">"node"</span>: <span class="hljs-string">"Configure your influencer profile"</span>,
            <span class="hljs-attr">"type"</span>: <span class="hljs-string">"main"</span>,
            <span class="hljs-attr">"index"</span>: <span class="hljs-number">0</span>
          }
        ]
      ]
    },
    <span class="hljs-attr">"Configure your influencer profile"</span>: {
      <span class="hljs-attr">"main"</span>: [
        [
          {
            <span class="hljs-attr">"node"</span>: <span class="hljs-string">"Generate tweet content"</span>,
            <span class="hljs-attr">"type"</span>: <span class="hljs-string">"main"</span>,
            <span class="hljs-attr">"index"</span>: <span class="hljs-number">0</span>
          }
        ]
      ]
    }
  },
  <span class="hljs-attr">"active"</span>: <span class="hljs-literal">false</span>,
  <span class="hljs-attr">"settings"</span>: {
    <span class="hljs-attr">"executionOrder"</span>: <span class="hljs-string">"v1"</span>
  },
  <span class="hljs-attr">"versionId"</span>: <span class="hljs-string">"6efe7268-12ad-4625-b12c-4a654a2053de"</span>,
  <span class="hljs-attr">"meta"</span>: {
    <span class="hljs-attr">"templateCredsSetupCompleted"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">"instanceId"</span>: <span class="hljs-string">"d03768ae40c5255f838188a39a903c303e55f2e35d13f75453bcd01fc0d4a4e2"</span>
  },
  <span class="hljs-attr">"id"</span>: <span class="hljs-string">"kPlSpKcpXOiNALu8"</span>,
  <span class="hljs-attr">"tags"</span>: []
}
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Serverless solution for AWS Cost Optimization: Automating Stale EBS Snapshot Deletion]]></title><description><![CDATA[Cost optimization is crucial for maintaining efficient and affordable cloud infrastructure in the ever-evolving cloud landscape. AWS provides numerous services and tools to help manage and optimize costs. One effective cost-saving measure is identify...]]></description><link>https://blogs.praneshpyarashrestha.com.np/aws-cost-optimization</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/aws-cost-optimization</guid><category><![CDATA[AWS]]></category><category><![CDATA[serverless]]></category><category><![CDATA[Lambda function]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Sun, 24 Nov 2024 15:31:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1732462611858/b88b0f99-5843-4266-8118-3bdb3c5e5c68.avif" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Cost optimization is crucial for maintaining efficient and affordable cloud infrastructure in the ever-evolving cloud landscape. AWS provides numerous services and tools to help manage and optimize costs. One effective cost-saving measure is identifying and deleting stale Amazon Elastic Block Store (EBS) snapshots. EBS snapshots are point-in-time backups of EBS volumes, and over time, they can accumulate and incur significant storage costs if not managed properly.</p>
<p>In this blog, we'll walk through a practical project to create an AWS Lambda function that identifies EBS snapshots no longer associated with any active EC2 instance and deletes them to save on storage costs. This Lambda function will utilize AWS SDK for Python (Boto3) to interact with AWS services.</p>
<h2 id="heading-prerequisites"><strong>Prerequisites</strong></h2>
<p>Before we dive into the implementation, ensure you have the following:</p>
<ol>
<li><p>An AWS account.</p>
</li>
<li><p>Basic understanding of AWS EC2, EBS, and Lambda.</p>
</li>
<li><p>AWS CLI configured on your local machine (optional for testing locally).</p>
</li>
<li><p>IAM role with appropriate permissions to manage EC2 instances, EBS volumes, and snapshots.</p>
</li>
</ol>
<h2 id="heading-project-overview"><strong>Project Overview</strong></h2>
<h3 id="heading-step-1-create-an-ec2-instance-and-ebs-volume">Step 1: Create an EC2 Instance and EBS Volume</h3>
<p>First, create an EC2 instance (free-tier specs) with an EBS volume. This volume will be used to create a snapshot for demonstration purposes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732460727363/1d8f505b-1784-4794-91c0-f050e0306c47.png" alt class="image--center mx-auto" /></p>
<p>The instance is up and running, now check the EBS volume attached to this instance.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732460705321/7d457fe1-8769-44c0-be59-bec862df8733.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-step-2-create-a-snapshot-for-the-ebs-volume"><strong>Step 2: Create a Snapshot for the EBS Volume</strong></h3>
<p>In the EC2 dashboard, navigate to the Snapshots section and create a snapshot for the newly created EBS volume.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732460808618/200d90c4-42a7-46e3-8077-8d3688c6c6e4.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732460860733/9c1d4b8b-9276-4121-8506-758c256eede5.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-step-3-create-a-lambda-function"><strong>Step 3: Create a Lambda Function</strong></h3>
<p>Next, create a Lambda function to identify and delete stale EBS snapshots. <strong>Navigate to AWS Lambda</strong>: Go to Services -&gt; Lambda -&gt; Create Function.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732460939924/858a51c3-97e8-4329-a632-d16cf18e010c.png" alt class="image--center mx-auto" /></p>
<p><strong>Configure the Function</strong>:</p>
<ul>
<li><p>Function Name: <code>cost-optimization-ebs-snapshot</code></p>
</li>
<li><p>Runtime: Python</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732460986490/9f70be07-2181-4075-b386-7a1c7af7b2ce.png" alt class="image--center mx-auto" /></p>
<p><strong>Create the Function</strong> with default permissions (we'll update permissions later).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732461117446/18260bf7-9fa2-46e2-8526-fdc8e8bd0a3c.png" alt class="image--center mx-auto" /></p>
<p>The function is successfully created.</p>
<h3 id="heading-step-4-add-python-code-to-the-lambda-function">Step 4: Add Python Code to the Lambda Function</h3>
<p>Replace the default code with the following Python script, which will identify and delete stale EBS snapshots:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732461166904/f1f0dd39-33d3-42f5-b217-e932fca666b2.png" alt class="image--center mx-auto" /></p>
<p>After pasting the code, click on Deploy. Since we will manually trigger the function, click on Test, set the event name as “test” and then click on Save.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1719070591060/bff1853d-5a80-44f8-b8fa-93f4c9d5dd58.png?auto=compress,format&amp;format=webp" alt /></p>
<h3 id="heading-step-5-configure-lambda-execution-time"><strong>Step 5: Configure Lambda Execution Time</strong></h3>
<p>Increase the Lambda function's execution time to 10 seconds to ensure it completes its task. Navigate to Configuration -&gt; General Configuration -&gt; Edit -&gt; Save.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732461557239/ddba5776-047f-43a4-a919-975b6ae2213d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-step-6-update-iam-permissions"><strong>Step 6: Update IAM Permissions</strong></h3>
<p>Update the Lambda function's IAM role to allow it to describe and delete snapshots, as well as list EC2 instances and volumes:</p>
<ol>
<li><p>Go to Configuration -&gt; Permissions.</p>
</li>
<li><p>Click on the role name to open it in a new tab.</p>
</li>
<li><p>Add the following inline policy:</p>
</li>
</ol>
<pre><code class="lang-powershell">{
    <span class="hljs-string">"Version"</span>: <span class="hljs-string">"2012-10-17"</span>,
    <span class="hljs-string">"Statement"</span>: [
        {
            <span class="hljs-string">"Effect"</span>: <span class="hljs-string">"Allow"</span>,
            <span class="hljs-string">"Action"</span>: [
                <span class="hljs-string">"ec2:DescribeInstances"</span>,
                <span class="hljs-string">"ec2:DescribeSnapshots"</span>,
                <span class="hljs-string">"ec2:DeleteSnapshot"</span>,
                <span class="hljs-string">"ec2:DescribeVolumes"</span>
            ],
            <span class="hljs-string">"Resource"</span>: <span class="hljs-string">"*"</span>
        }
    ]
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1732461689835/f50fa791-4bf4-4403-b8dc-60024fda412b.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-step-7-test-the-lambda-function"><strong>Step 7: Test the Lambda Function</strong></h3>
<p>Manually trigger the Lambda function to test it. Ensure that the snapshot created earlier is not deleted because it is associated with an active EC2 instance and EBS volume.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1719070794311/b45cfbc5-c0e2-497e-8cf1-bbafc44ddb66.png?auto=compress,format&amp;format=webp" alt /></p>
<p>The function has been executed successfully. If we go to the EC2 dashboard and see the Snapshot, it would still be there since the EC2 instances are active and as per our Python code, only those Snapshots will be deleted, which are not associated with an active volume/instance.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1719070835146/6bd43afb-5231-476d-8244-3b405da0171f.png?auto=compress,format&amp;format=webp" alt /></p>
<h3 id="heading-step-8-delete-the-ec2-instance-and-associated-volume">Step 8: Delete the EC2 Instance and Associated Volume</h3>
<p>Delete the EC2 instance and verify that its associated volume is also deleted. Trigger the Lambda function again to confirm that the snapshot is now identified as stale and deleted.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1719070882009/051021a2-3545-4aeb-afff-235b89849fe5.png?auto=compress,format&amp;format=webp" alt /></p>
<p>After the instance and its associated volume have been deleted, come back to the Lambda dashboard and click on Test again.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1719070896739/31a326d9-6187-40b8-bc90-18e7acbd700d.png?auto=compress,format&amp;format=webp" alt /></p>
<p>The function has been successfully executed and now let’s see if the Snapshot has been deleted.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1719070931354/aa92587c-e9ea-4ac7-9ce0-bf4650d93897.png?auto=compress,format&amp;format=webp" alt /></p>
<p>The Snapshot has been successfully deleted.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Congratulations! You have successfully created an AWS Lambda function to optimize storage costs by identifying and deleting stale EBS snapshots. This automated approach helps maintain efficient cloud infrastructure and reduce unnecessary storage expenses.</p>
<h2 id="heading-additional-tips"><strong>Additional Tips</strong></h2>
<ul>
<li><p><strong>Automation</strong>: Schedule the Lambda function to run periodically using AWS CloudWatch Events.</p>
</li>
<li><p><strong>Cost-Effective Storage</strong>: Consider moving snapshots to Amazon S3 Glacier for long-term, low-cost storage.</p>
</li>
<li><p><strong>Monitoring and Alerts</strong>: Set up monitoring and alerts to track storage usage and optimization results.</p>
</li>
</ul>
<p>By following these steps, we can implement an effective cost optimization strategy for our AWS environment, ensuring you only pay for the resources you actively use.</p>
]]></content:encoded></item><item><title><![CDATA[Introduction to AWS DevOps Tools & Services]]></title><description><![CDATA[AWS, short for Amazon Web Services, is a cloud computing platform provided by Amazon. In simple terms, AWS offers a wide range of services and tools that allow individuals and businesses to access computing power, storage, databases, and other resour...]]></description><link>https://blogs.praneshpyarashrestha.com.np/aws-devops</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/aws-devops</guid><category><![CDATA[aws devops]]></category><category><![CDATA[Devops]]></category><category><![CDATA[AWS]]></category><category><![CDATA[aws lambda]]></category><category><![CDATA[aws ec2]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Mon, 29 Apr 2024 14:18:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1714399888200/b23e2424-f6f3-439b-b1bd-59ac7baf5437.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>AWS, short for <strong>Amazon Web Services</strong>, is a cloud computing platform provided by Amazon. In simple terms, AWS offers a wide range of services and tools that allow individuals and businesses to access computing power, storage, databases, and other resources over the internet.</p>
<p>Imagine you have a computer or server at home or in your office. With AWS, you can think of accessing a similar computer or server, but it is located remotely and managed by Amazon. Instead of physically owning and maintaining hardware, AWS provides virtual resources that you can rent and use based on your needs.</p>
<p>AWS offers various services, including computing power with Amazon EC2, storage with Amazon S3, databases with Amazon RDS, and many more. These services are highly scalable, meaning you can easily adjust the resources you use based on the demand of your applications or business.</p>
<p>One of the key advantages of AWS is its flexibility and pay-as-you-go pricing model. You can start with minimal resources and expand as your needs grow. This allows individuals and businesses to access powerful computing resources without the upfront costs and complexities of setting up and managing their own infrastructure.</p>
<p>AWS also provides a global infrastructure, with data centers located in different regions worldwide. This allows you to deploy your applications and services closer to your users, improving performance and reducing latency.</p>
<p>Overall, AWS is a cloud computing platform that offers a wide range of services and resources to help individuals and businesses build and scale their applications, store and process data, and leverage the power of the cloud without the need for extensive hardware and infrastructure management.</p>
<p><img src="https://www.igmguru.com/blog/wp-content/uploads/2023/11/What-Is-AWS-DevOps.jpg" alt="What Is AWS DevOps? Everything You Need To Know" /></p>
<h1 id="heading-exploring-the-aws-global-infrastructure"><strong>Exploring the AWS Global Infrastructure:</strong></h1>
<p><img src="https://miro.medium.com/v2/resize:fit:700/0*PPxiV53Fl8VRZzO0.png" alt="AWS Global Infrastructure &amp; Outposts- (SAA-CO3 Summary 2024) | by Tom van  Eijk | Medium" /></p>
<p><strong>A Foundation for the Cloud</strong></p>
<p><strong>Introduction:</strong> In today's digital era, businesses rely heavily on cloud computing to power their applications and services. One of the leading cloud providers, Amazon Web Services (AWS), offers a robust and extensive global infrastructure that forms the backbone of their cloud platform. Let's take a closer look at the AWS Global Infrastructure and understand how it supports businesses worldwide.</p>
<p><strong>Regions:</strong> The Building Blocks AWS operates in multiple geographic regions worldwide. Think of a region as a separate area where AWS has built and deployed its data centers. These regions are carefully chosen to ensure proximity to customers and compliance with local regulations. Each region operates independently, providing high availability and fault tolerance.</p>
<p><strong>Availability Zones:</strong> The Pillars of Resilience Within each region, AWS creates Availability Zones (AZs) that are isolated from one another. You can think of an AZ as a data center or a cluster of data centers. These AZs are designed to be physically and logically separate, connected by high-speed networking. This architecture ensures that if one AZ experiences an issue, the others can continue serving traffic seamlessly.</p>
<p><strong>Edge Locations:</strong> Bringing the Cloud Closer AWS has a network of Edge Locations spread across the globe. These locations act as entry points to the AWS network and are strategically placed in major cities. Edge Locations help reduce latency and improve performance by caching frequently accessed data and content closer to end users. They play a crucial role in delivering services like content delivery and improving the user experience.</p>
<p><strong>Global Network:</strong> Seamlessly Connecting the Dots To provide a reliable and fast network experience, AWS has built a global network that connects its regions, Availability Zones, and Edge Locations. This network ensures high bandwidth, low latency, and resilience. It enables smooth communication between different AWS services, as well as secure and efficient data transfer to and from the internet.</p>
<p><strong>Benefits for Businesses:</strong> The AWS Global Infrastructure offers several advantages to businesses of all sizes:</p>
<ol>
<li><p>High Availability: The distributed nature of AWS regions and Availability Zones provides redundancy, ensuring that applications remain available even in the face of failures or disruptions.</p>
</li>
<li><p>Scalability: With the vast AWS infrastructure at their disposal, businesses can easily scale their resources up or down based on demand, ensuring optimal performance and cost-efficiency.</p>
</li>
<li><p>Global Reach: By leveraging AWS regions and Edge Locations, businesses can expand their reach and deliver their services to customers worldwide, while maintaining low latency and high performance.</p>
</li>
<li><p>Resilience: The geographically dispersed infrastructure, coupled with AWS's expertise in data center management, offers businesses resilience against natural disasters, power outages, and other unforeseen events.</p>
</li>
</ol>
<p><strong>Conclusion:</strong> The AWS Global Infrastructure serves as the foundation for businesses to build and deploy their applications and services in the cloud. Its extensive network of regions, Availability Zones, and Edge Locations ensures high availability, scalability, and global reach. By leveraging this infrastructure, businesses can focus on innovation and growth while relying on AWS's robust and reliable cloud platform. Whether you're a startup or an enterprise, AWS's global infrastructure provides the necessary tools to succeed in the ever-evolving digital landscape.</p>
<h2 id="heading-aws-important-services">AWS Important Services</h2>
<p><img src="https://allcode.com/wp-content/uploads/2024/03/top-aws-services1.jpg" alt="Top AWS Services" /></p>
<h3 id="heading-aws-compute-service">AWS Compute Service</h3>
<p>AWS Compute service refers to a set of services provided by Amazon Web Services (AWS) that allows you to run your applications and perform computational tasks in the cloud without needing to manage the underlying hardware.</p>
<p>In simple terms, AWS Compute services offer virtual servers or computing resources that you can use to run your software, store data, and perform computations. These services take care of the infrastructure, such as servers, networking, and storage, so you can focus on building and running your applications.</p>
<p>The main AWS Compute services are:</p>
<ol>
<li><p><strong>Amazon Elastic Compute Cloud (EC2):</strong> EC2 provides virtual servers, known as instances, that you can rent on demand. You can choose the configuration of these instances based on your needs, including the type of processor, memory, storage, and network capacity. EC2 allows you to run various types of applications, from simple web servers to complex enterprise software.</p>
</li>
<li><p><strong>AWS Lambda:</strong> Lambda is a serverless compute service. Instead of renting and managing virtual servers, you write code functions and upload them to Lambda. Lambda automatically runs your code in response to events, such as changes to data in an Amazon S3 bucket or incoming API requests. It handles all the infrastructure and scales your code automatically, so you don't have to worry about provisioning or managing servers.</p>
</li>
<li><p><strong>Amazon Elastic Container Service (ECS):</strong> ECS is a container orchestration service. Containers are lightweight, portable, and isolated environments that package an application and its dependencies. ECS helps you run and manage containers at scale. You can deploy and manage containerized applications using ECS, which takes care of the underlying infrastructure and ensures high availability and scalability.</p>
</li>
<li><p><strong>Amazon Elastic Kubernetes Service (EKS):</strong> EKS is a managed Kubernetes service. Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. With EKS, AWS takes care of setting up and managing the Kubernetes control plane, while you focus on deploying and managing your applications.</p>
</li>
</ol>
<p>These compute services offer flexibility, scalability, and cost-efficiency. You can easily adjust your compute resources based on demand, scale up or down as needed, and pay only for the resources you consume. This allows you to focus on your applications and business logic without worrying about the underlying infrastructure, making it easier to build and deploy your software in the cloud.</p>
<h3 id="heading-aws-auth-and-security-service">AWS Auth and Security Service</h3>
<p><img src="https://d2908q01vomqb2.cloudfront.net/22d200f8670dbdb3e253a90eee5098477c95c23d/2021/03/14/Approaches-authenticating-external-apps-1-ForSocial.jpg" alt="Approaches for authenticating external applications in a machine-to-machine  scenario | AWS Security Blog" /></p>
<p>AWS provides various authentication and security services to help protect your applications, data, and resources in the cloud. Let's explore some of these services in simple terms:</p>
<ol>
<li><p>AWS Identity and Access Management (IAM): IAM allows you to manage access to AWS services and resources securely. It enables you to create and manage users, groups, and roles with specific permissions. IAM helps you control who can access your AWS resources and what actions they can perform. With IAM, you can grant least privilege access, ensuring that users have only the permissions they need to perform their tasks.</p>
</li>
<li><p>AWS Web Application Firewall (WAF): WAF is a firewall service that helps protect your web applications from common web exploits and attacks. It allows you to define rules to filter and monitor HTTP and HTTPS traffic to your applications. WAF helps block malicious requests, such as SQL injection and cross-site scripting, and provides protection against Distributed Denial of Service (DDoS) attacks.</p>
</li>
<li><p>AWS Key Management Service (KMS): KMS is a managed service that helps you create and control the encryption keys used to encrypt your data. It allows you to encrypt data stored in AWS services and your own applications. KMS integrates with various AWS services and provides an easy way to manage encryption keys securely.</p>
</li>
<li><p>AWS Certificate Manager (ACM): ACM simplifies the process of provisioning, managing, and deploying Secure Sockets Layer/Transport Layer Security (SSL/TLS) certificates for your websites and applications. It helps you secure communication between clients and your applications by providing free SSL/TLS certificates and automating certificate renewals.</p>
</li>
<li><p>AWS Single Sign-On (SSO): SSO simplifies access management for multiple AWS accounts and business applications. It allows users to sign in once with their existing corporate credentials and access multiple applications and AWS accounts without needing to enter credentials again. SSO helps streamline access management and improves security by reducing the need for multiple passwords.</p>
</li>
<li><p>AWS CloudTrail: CloudTrail provides a record of events and activities that occur in your AWS account. It captures detailed information about API calls, resource changes, and account activity. CloudTrail helps with compliance, auditing, and security analysis by providing visibility into the actions performed in your AWS environment.</p>
</li>
</ol>
<p>These are just a few examples of the authentication and security services offered by AWS. By leveraging these services, you can enhance the security of your applications and data, manage access to your AWS resources effectively, and meet regulatory requirements.</p>
<h3 id="heading-aws-storage-service">AWS Storage Service</h3>
<p><img src="https://cdn.educba.com/academy/wp-content/uploads/2019/11/AWS-Storage-Services.png" alt="AWS Storage Services | 7 Types of Storage Services in AWS" /></p>
<p>AWS offers a variety of storage services that enable you to store and manage your data in the cloud. Let's explore some of these storage services in simple terms:</p>
<ol>
<li><p>Amazon Simple Storage Service (S3): Amazon S3 is a scalable and durable object storage service. It allows you to store and retrieve any amount of data at any time. S3 provides a simple web services interface that you can use to upload, manage, and organize your data in "buckets." You can think of S3 as a vast, secure, and reliable digital storage space where you can store files, images, videos, backups, and other types of data.</p>
</li>
<li><p>Amazon Elastic Block Store (EBS): EBS provides persistent block-level storage volumes for use with EC2 instances. In simpler terms, it offers storage that can be attached to virtual servers (EC2 instances) and allows you to install an operating system or store application data. EBS volumes provide durable and consistent performance, making them suitable for databases, file systems, and other applications that require low-latency storage.</p>
</li>
<li><p>Amazon Elastic File System (EFS): EFS offers scalable and fully managed file storage for EC2 instances. It provides a simple, scalable file system accessible from multiple EC2 instances simultaneously. EFS is designed to support a wide range of workloads, such as content management systems, web serving, and data sharing across multiple instances.</p>
</li>
<li><p>AWS Storage Gateway: Storage Gateway is a hybrid storage service that enables you to seamlessly integrate your on-premises infrastructure with AWS storage services. It acts as a bridge between your on-premises environment and AWS, allowing you to store data in S3, EBS, or EFS while maintaining local access to your applications and data. It enables backup, disaster recovery, and hybrid cloud scenarios.</p>
</li>
<li><p>Amazon Glacier: Glacier is a secure, durable, and low-cost storage service for data archiving and long-term backup. It is designed for data that is infrequently accessed and can tolerate longer retrieval times. Glacier offers different retrieval options, ranging from expedited to bulk retrievals, depending on the urgency of accessing your archived data.</p>
</li>
</ol>
<p>These storage services provide different features and capabilities to meet various storage requirements. Whether you need simple object storage, block storage for your virtual servers, file storage for shared access, or long-term archiving, AWS offers scalable and reliable storage solutions to help you store, manage, and protect your data in the cloud.</p>
<h3 id="heading-aws-monitoring-and-logging-service">AWS Monitoring and Logging Service:</h3>
<p>AWS provides monitoring and logging services that help you gain insights into the performance, health, and security of your applications and infrastructure in the cloud. Let's explore these services in simple terms:</p>
<ol>
<li><p>Amazon CloudWatch: CloudWatch is a monitoring and observability service that collects and tracks metrics, logs, and events from various AWS resources and applications. It provides a unified view of your AWS infrastructure and applications' operational health. You can monitor metrics, set alarms to be notified of certain conditions, and gain visibility into resource utilization, application performance, and overall system health.</p>
</li>
<li><p>AWS CloudTrail: CloudTrail is a service that enables governance, compliance, and operational auditing of your AWS account. It captures and records all API calls and actions taken within your AWS environment. CloudTrail provides a history of events, including who made the API calls, the source IP address, and the actions performed. It helps with security analysis, compliance audits, and troubleshooting.</p>
</li>
<li><p>AWS X-Ray: X-Ray is a service that helps you analyze and debug distributed applications. It provides an end-to-end view of requests as they flow through your application, allowing you to identify bottlenecks and performance issues. X-Ray provides insights into how services are interconnected and helps you pinpoint areas for optimization and troubleshooting.</p>
</li>
<li><p>AWS CloudWatch Logs: CloudWatch Logs is a fully managed service for collecting, analyzing, and storing logs generated by your applications and AWS resources. It allows you to centralize logs in a single location, making it easier to search, monitor, and troubleshoot issues. CloudWatch Logs can receive logs from various sources, including EC2 instances, Lambda functions, and custom applications.</p>
</li>
<li><p>AWS Personal Health Dashboard: The Personal Health Dashboard provides information and notifications about the health of your AWS resources. It alerts you to any scheduled or unplanned events that may impact the availability of your resources. The dashboard offers proactive notifications, guidance, and remediation steps to help you keep your applications running smoothly.</p>
</li>
</ol>
<p>These monitoring and logging services help you gain visibility into your AWS environment, understand the performance and health of your applications, and detect and troubleshoot issues effectively. By leveraging these services, you can ensure the availability, performance, and security of your applications and infrastructure in the cloud.</p>
<h3 id="heading-aws-devops-services">AWS DevOps Services :</h3>
<p>AWS provides a range of services that support DevOps practices and enable organizations to implement efficient and streamlined software development and operations processes. Let's explore some of these AWS DevOps services in simple terms:</p>
<ol>
<li><p>AWS CodeCommit: CodeCommit is a fully managed source code control service. It provides a secure and scalable repository for storing your source code and version control. CodeCommit integrates with other AWS DevOps services, making it easy to collaborate on code, manage branches, and track changes to your codebase.</p>
</li>
<li><p>AWS CodeBuild: CodeBuild is a fully managed build service that compiles source code, runs tests, and produces software artifacts. It automates the build process and scales to meet your needs. CodeBuild integrates with popular development tools and services, allowing you to build and test your code quickly and reliably.</p>
</li>
<li><p>AWS CodeDeploy: CodeDeploy automates the deployment of applications to various computing environments, including Amazon EC2 instances, Lambda functions, and on-premises servers. It simplifies the process of releasing new features and updates by providing flexible deployment options and allowing you to define deployment strategies.</p>
</li>
<li><p>AWS CodePipeline: CodePipeline is a fully managed continuous integration and continuous delivery (CI/CD) service. It enables you to create and automate end-to-end software release pipelines. CodePipeline integrates with other AWS DevOps services, allowing you to build, test, and deploy your applications seamlessly.</p>
</li>
<li><p>AWS Elastic Beanstalk: Elastic Beanstalk provides a platform-as-a-service (PaaS) offering that simplifies the deployment and management of your applications. It automatically handles the underlying infrastructure, such as capacity provisioning, load balancing, and scaling, allowing you to focus on writing code. Elastic Beanstalk supports a variety of programming languages and frameworks.</p>
</li>
<li><p>AWS CloudFormation: CloudFormation allows you to define and provision your AWS infrastructure as code. It uses templates to describe the resources and dependencies required for your application. With CloudFormation, you can create, update, and delete resources in a controlled and automated manner, ensuring consistency and reproducibility of your infrastructure.</p>
</li>
<li><p>AWS OpsWorks: OpsWorks provides a configuration management service that helps you automate operational tasks and manage your infrastructure. It supports both Chef and Puppet, popular configuration management frameworks. OpsWorks simplifies the provisioning, configuration, and lifecycle management of your applications and resources.</p>
</li>
</ol>
<p>These AWS DevOps services work together to provide a comprehensive toolkit for implementing and managing DevOps practices. They enable organizations to automate the software development lifecycle, increase deployment speed and frequency, improve collaboration, and maintain infrastructure consistency. By leveraging these services, teams can achieve more efficient and reliable software delivery in the cloud.</p>
<h1 id="heading-aws-infrastructure">AWS Infrastructure :</h1>
<h2 id="heading-cloudformation">CloudFormation :</h2>
<p>AWS CloudFormation is a service provided by Amazon Web Services (AWS) that allows you to define and provision your infrastructure and applications as code. In simple terms, CloudFormation enables you to create, update, and manage your AWS resources in a controlled and automated manner.</p>
<p>CloudFormation uses a declarative language called AWS CloudFormation templates, which are written in YAML or JSON format. These templates describe the desired state of your infrastructure, including the AWS resources you want to provision, their configuration settings, and any dependencies between them.</p>
<p>When you create a CloudFormation stack, you provide the template that defines your infrastructure. CloudFormation then takes care of provisioning and configuring the specified resources, such as EC2 instances, databases, load balancers, and networking components, according to the template's instructions.</p>
<p>CloudFormation ensures that your resources are created in the right order and that their dependencies are properly managed. It also handles updates and deletes of resources, making it easy to make changes to your infrastructure while maintaining consistency and minimizing downtime.</p>
<p>The benefits of using CloudFormation include:</p>
<ol>
<li><p>Infrastructure as Code: CloudFormation allows you to treat your infrastructure as code, enabling version control, automated deployments, and reproducibility.</p>
</li>
<li><p>Automation and Consistency: CloudFormation automates the provisioning and configuration of your resources, ensuring consistent setups across different environments.</p>
</li>
<li><p>Scalability and Flexibility: CloudFormation supports scaling your infrastructure up or down based on demand, allowing you to adapt to changing needs easily.</p>
</li>
<li><p>Simplified Management: With CloudFormation, you can manage your entire stack of AWS resources as a single entity, making it easier to track and manage your infrastructure.</p>
</li>
<li><p>Integration with other AWS Services: CloudFormation integrates with other AWS services, allowing you to include additional configurations, such as security groups, IAM roles, and notifications.</p>
</li>
</ol>
<p>Overall, CloudFormation simplifies the process of provisioning and managing your AWS infrastructure. It provides a reliable and efficient way to create and maintain your resources in a consistent and automated manner, promoting infrastructure scalability, agility, and repeatability.</p>
<h2 id="heading-aws-networking-services">AWS Networking Services</h2>
<p>AWS offers a range of networking services that help you build and manage your network infrastructure in the cloud. These services enable you to establish secure and scalable network connections, route traffic, and optimize network performance. Let's explore some key AWS networking services in simple terms:</p>
<ol>
<li><p>Amazon Virtual Private Cloud (VPC): VPC allows you to create a virtual network in the AWS cloud. It provides you with control over your network environment, including IP address ranges, subnets, routing tables, and network gateways. VPC enables you to isolate and secure your resources, control inbound and outbound network traffic, and establish connectivity with your on-premises infrastructure or other VPCs.</p>
</li>
<li><p>Elastic Load Balancing (ELB): ELB automatically distributes incoming application traffic across multiple EC2 instances, containers, or IP addresses. It helps improve the availability and scalability of your applications by evenly distributing the load and providing fault tolerance. ELB supports three types of load balancers: Application Load Balancer (ALB), Network Load Balancer (NLB), and Classic Load Balancer (CLB), each with its own features and use cases.</p>
</li>
<li><p>Amazon Route 53: Route 53 is a scalable domain name system (DNS) web service that allows you to register and manage domain names. It routes incoming requests to your resources based on configurable rules, such as geolocation or latency-based routing. Route 53 also provides health checks and automatic failover, enabling high availability and reliable access to your applications.</p>
</li>
<li><p>AWS Direct Connect: Direct Connect establishes a dedicated network connection between your on-premises data center and the AWS cloud. It bypasses the public internet and provides a private and secure connection for your data transfer. Direct Connect can help reduce network costs, increase bandwidth, and improve network performance for hybrid cloud deployments or large data transfers.</p>
</li>
<li><p>AWS Transit Gateway: Transit Gateway is a networking hub that simplifies the connectivity and routing between multiple VPCs and on-premises networks. It allows you to centralize network management and control the flow of traffic across your network infrastructure. Transit Gateway supports a hub-and-spoke architecture, making it easier to scale and manage your network as your organization grows.</p>
</li>
<li><p>AWS VPN: AWS VPN enables you to establish secure and encrypted connections between your on-premises network and your VPCs. It allows remote access to your VPCs or establishes site-to-site connectivity, providing secure communication over the public internet. AWS VPN supports various types of VPN connections, including IPsec and OpenVPN, and integrates with Direct Connect for hybrid network scenarios.</p>
</li>
</ol>
<p>These AWS networking services provide the building blocks to create and manage your network infrastructure in the cloud. They offer features for security, scalability, availability, and connectivity, helping you design and implement a robust and efficient network architecture that meets your specific requirements.</p>
]]></content:encoded></item><item><title><![CDATA[From Commit to Deploy; An Overview of CI/CD Pipeline]]></title><description><![CDATA[What is Continuous Integration in DevOps?

In DevOps, Continuous Integration (CI) involves automating the process of building and deploying code every time a developer in a team commits code to version control. Developers share code by merging all ch...]]></description><link>https://blogs.praneshpyarashrestha.com.np/cicd-pipeline</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/cicd-pipeline</guid><category><![CDATA[ci-cd]]></category><category><![CDATA[Devops]]></category><category><![CDATA[gitops]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Continuous Integration]]></category><category><![CDATA[continuous deployment]]></category><category><![CDATA[continuous delivery]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Mon, 05 Feb 2024 12:08:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707134716684/c67b318d-7bc8-40bb-b921-e7f928468f57.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-continuous-integration-in-devops"><strong>What is Continuous Integration in DevOps?</strong></h2>
<p><img src="https://assets-global.website-files.com/622642781cd7e96ac1f66807/62d0eee28b8758b46548880e_042021-Harness-Blogpost-SEOBLOG-DeploymentPipelinePatterns-Header.png" alt="Pipeline Patterns for CI/CD Pipelines | Harness" /></p>
<p>In DevOps, Continuous Integration (CI) involves automating the process of building and deploying code every time a developer in a team commits code to version control. Developers share code by merging all changes to a shared repository, including the smallest of changes. Every time code is committed, it initiates an automated pipeline that retrieves that latest code and proceeds to build, test and validate the main or trunk branch.</p>
<p>CI was imagined and implemented as a best practice to tackle a specific problem. When coder worked in isolation and had to integrate changes with the team’s codebase at the end of days or weeks, they found it led to frequent merge conflicts, frustrating bugs, incompatible coding strategies and duplications.</p>
<p>With consistent code commits to a shared branch, these problems were significantly lessened. Code is tested to iron out bugs early on, and inconsistencies with the larger body of code are identified early on.</p>
<h2 id="heading-benefits-of-continuous-integration-in-devops"><strong>Benefits of Continuous Integration in DevOps</strong></h2>
<h3 id="heading-smaller-and-easier-code-changes"><strong>Smaller and Easier Code Changes</strong></h3>
<p><strong>‍</strong>With every code change being pushed to version control immediately, the CI/CD pipeline has to deal with smaller code changes and integrations at a time. Obviously, such changes are easier to handle, test and debug than larger scripts that may contain multiple, hard-to-detect errors. The idea is to break down features and new development into byte-sized pieces that are fast to write.<strong>‍</strong></p>
<h3 id="heading-easier-debugging"><strong>Easier Debugging‍</strong></h3>
<p>A CI-based pipeline facilitates fault isolation AKA the practice of formulating systems in which errors lead to limited negative consequences. This protects a systems against major damage and makes for easier maintenance.</p>
<p>Fault isolation is facilitated because smaller code changes make it easier to find bugs and resolve them before they can adversely affect the entire ecosystem - something not easily achieved with CI in place.<br />‍<strong>‍</strong></p>
<h3 id="heading-faster-product-releases"><strong>Faster Product Releases</strong></h3>
<p><strong>‍</strong>A CI-powered pipeline is a continuously moving system in which failures are detected and debugged faster. This invariably leads to faster and more frequent releases which translates to happier customers and a positive edge over competitors. <strong>‍</strong></p>
<h3 id="heading-lighter-backlog"><strong>Lighter Backlog</strong></h3>
<p><strong>‍</strong>As explained above, CI enables quicker bug identification and debugging, all within the early stages of code changes and integration. With small defects quickly fixed in pre-production, developers have a lighter backlog of avoidable, non-critical bugs to fix. They can devote that time to focus on larger problems, write better code and keep updating the systems for greater efficiency.<br />Needless to say, lesser errors result in lower costs, easier maintenance, better quality code and increased ROI. <strong>‍</strong></p>
<h3 id="heading-increased-transparency-and-accountability"><strong>Increased Transparency and Accountability</strong></h3>
<p><strong>‍</strong>Frequent code commits lead to immediate and frequent feedback from the automated system as well as the team. This keeps problems visible and transparent to the team, keeps everyone on the same page.</p>
<p>Feedback from the CI stage has direct effects on build issues, merging conflicts, larger architectural snags, etc. Thus, it doesn’t just keep the developer's conscious of what they and their teammates are doing, but also of the health of the system they are operating in.<br />‍</p>
<p>Of course, CI alone cannot implement the seamless operability required to create software quickly and with minimal flaws. Neither can it, by itself, establish DevOps principles within a software engineering team or organization. For that, the pipeline needs CD - Continuous Delivery/Continuous Deployment</p>
<h2 id="heading-continuous-delivery"><strong>Continuous Delivery</strong></h2>
<p>In DevOps, Continuous Delivery (CD) is a practice in which all code changes are automatically tested and readied for release. Once Continuous Integration takes care of code build and integration, delivery pushes changes to the testing environment and then keeps it prepared for production. Essentially, with CD in place, a team will always have a deployment-ready product that has been tested and cleared for public release.</p>
<p>Continuous Delivery takes the code beyond simple unit tests that are run in the CI stage. It allows the software to be run through multiple evaluation layers so as to verify functionality from all dimensions. This can include integration tests, UI tests, load tests, end-to-end tests, API tests, regression tests, security tests, etc. It allows developers to validate the product more comprehensively and weed out issues before it reaches customer hands.</p>
<h2 id="heading-continuous-deployment"><strong>Continuous Deployment</strong></h2>
<p>CD can sometimes also refer to Continuous Deployment - a practice that is the next stage from Continuous Delivery. Once code has been made release-ready, Continuous Deployment is the process of automatically pushing it to the production environments.</p>
<p>Automation, in this case, is conditional on a series of preconceived and pre-established tests in the pipeline. Code changes pass through these tests, and if all goes well, the pipeline triggers their release directly to production. No human intervention or approval required.</p>
<h2 id="heading-continuous-delivery-vs-continuous-deployment">Continuous Delivery vs Continuous Deployment</h2>
<p><strong>Continuous Deployment</strong> essentially adds an extra step to <strong>Continuous Delivery</strong>. The former pushes every code to production automatically, without explicit approval from a human supervisor. The pipeline takes the code from the repository, pulls the appropriate configurations, builds VMs, containers, etc. on the fly, and deploys the code, all in one fell swoop.</p>
<p>In case of <strong>Continuous Delivery</strong>, the code is built, integrated and tested to be production ready. However, it requires a developer, product manager or Team Lead’s approval to actually be released to the production environment.</p>
<p>The question of - <strong>which continuous model to use?</strong> - depends on an organization’s goals, the skill level of their employees as well as the resources they can devote to acquiring the right CI/CD tools. Implementing CI/CD in <strong>DevOps</strong> is to have the proper tools and checks in place to manage configurations and rollback in the event of errors or failures.</p>
<h2 id="heading-what-is-a-cicd-pipeline-in-devops"><strong>What is a CI/CD pipeline in DevOps?</strong></h2>
<p><img src="https://www.perfecto.io/sites/perfecto.io/files/image/2019-12/image-blog-keys-strong-ci-cd-pipeline.png" alt="CI/CD Pipeline | Introduction, Benefits, How to | Perfecto" /></p>
<p>A CI/CD pipeline comprises a number of serial processes that are executed to deliver a new version of software (website/app). CI/CD aims to accelerate and improve software delivery by utilizing DevOps principles and leveraging automation at every step.</p>
<p>Consistent automation and monitoring is incorporated into the CI/CD pipeline so as to make development more efficient while consuming less resources (time, money, effort). Every step in the pipeline is automated - from the moment code is pushed to the repository it is built, integrated, tested, deployed and monitored via automated mechanisms.</p>
<p>Needless to say, the business benefits of CI/CD pipelines are many. They accelerate development and reduce the likelihood of errors. Essentially, it enables enterprises to release software multiple times a day with minimum human involvement.</p>
<h2 id="heading-best-practices-for-cicd-pipeline"><strong>Best Practices for CI/CD pipeline</strong></h2>
<h3 id="heading-commit-early-and-often"><strong>Commit early and often</strong></h3>
<p>Every time a dev commits code, they initiate a series of automated tests that provide feedback and inform the team that a change has occurred. Regular code commits ensure that the whole team remains on the same page which enables better collaboration. It also lowers the likelihood of frustrating merge conflicts that usually show up when integrating larger code changes.</p>
<p>By sharing all changes with the entire team (through code pushes to the main branch), everyone stays updated and can modify their own work to match the best and latest version of software. It is wise to commit code at least once a day, though most major companies commit far more.</p>
<h3 id="heading-stick-to-one-build"><strong>Stick to one build</strong></h3>
<p>Don’t create a new building for each stage of the pipeline. Doing so in different environments can introduce inconsistencies in the software, which means that you cannot depend on previous test results. Instead, one build artifact should be travelling through each stage and finally, released to production.</p>
<h3 id="heading-keep-environments-pristine"><strong>Keep environments pristine</strong></h3>
<p>To achieve accurate test results, clean the pre-prod environment between deployments. If environments run for a long time, teams have to deal with multiple configurational changes and updates, which are hard to track.</p>
<p>With returning them to a pristine state, tests that pass in one environment might fail in another. To prevent this, use containers to host environments and run tests. This makes it easier to tear down the environment after a deployment.</p>
<h3 id="heading-monitor-and-measure"><strong>Monitor and Measure</strong></h3>
<p><strong>‍</strong> Most teams will set up monitoring mechanisms for the production environment so as to detect any errors or anomalies quickly. Similarly, a CI/CD pipeline must be equipped with metrics for monitoring and evaluation. By analyzing these metrics, developers and team managers can narrow down potential bugs and handle them before they metastasize. They can also detect modules for improvement.<br />‍<strong>‍</strong></p>
<h3 id="heading-streamline-tests"><strong>Streamline tests</strong></h3>
<p>Don’t expect to automate every test from the very beginning. Start with tests that run the fastest (unit tests), run them early to get an initial layer of feedback. Once these are complete and you have some idea of the build stability, move onto longer and more complex tests.</p>
<p>Manual tests take longer and are dependent on availability of the right personnel. Therefore, keep them minimal (you’ll never be able to eliminate them completely) and leave them for after the completion of automated tests. Instead, ensure that testers focus on creating mature, comprehensive automated test scripts that get the job done.</p>
<h2 id="heading-cicd-pipeline-stages-a-breakdown"><strong>CI/CD pipeline stages: A breakdown</strong></h2>
<p><img src="https://assets-global.website-files.com/622642781cd7e96ac1f66807/6232b5f8517e5e811017f9e9_image-55.png" alt="CI/CD Pipeline: Everything You Need to Know | Harness" /></p>
<p>To define CI/CD pipelines, look at the basic steps:  <strong>Develop → Build → Test → Deploy. ‍</strong>‍</p>
<p>As we expand the pipeline, we also have Monitoring → Feedback → Operations. A continuous orchestration platform can help you design such a pipeline, this is where DevOps Engineers play their role.</p>
<h3 id="heading-develop"><strong>Develop</strong></h3>
<p>Here we are writing the code, meaning that we need a repository for storing and checking out code.</p>
<h3 id="heading-build"><strong>Build‍</strong></h3>
<p>When code is checked-in to the repository, that code is integrated into the master branch. Here is where version control is necessary. In older waterfall style workflows, integration/build would only occur after the completion of a major feature set or large volume code changes. When working in a more agile, continuous model, code is integrated into the feature times per day. Code is broken down into smaller working functions, allowing for iterative improvements and fast integration results.</p>
<h3 id="heading-testquality"><strong>Test/Quality‍</strong></h3>
<p>Once the code is built, the resulting application must be tested for errors, functional failures, and quality. These tests can and should be automated using any number of purpose-built tools. By testing at every build, feedback is received quickly and corrections can be implemented swiftly.</p>
<h3 id="heading-security-scan"><strong>Security Scan‍</strong></h3>
<p>As part of our transition away from bolt-on and after-the-fact auditing, security scanning is a critical part of the continuous loop. Security scans can automatically detect vulnerabilities and insecure implementations before being released into the wild and exploited by bad actors. It is essential to include this step in the testing portion of your pipeline - as they say, “an ounce of prevention is worth a pound of cure.”</p>
<h3 id="heading-deploy"><strong>Deploy‍</strong></h3>
<p>The code is built, testing has provided the green light, and it’s time to push our changes to an environment, whether pre-production or production. With continuous deployment, regular automated push to non-production environments gives clear feedback and metrics for how the code will perform when released to a customer-facing environment. After passing the appropriate tests in pre-production, code can be automatically released to production using whatever method or model meets your requirements.</p>
<h2 id="heading-cicd-tools-in-devops"><strong>CI/CD tools in DevOps</strong></h2>
<p>There are a large number of tools for facilitating CI/CD processes in DevOps-based teams. Some of the most popular ones include:</p>
<p><strong>Configuration Management</strong> - Ansible, Puppet, Chef</p>
<p><strong>Code Management</strong> - GitHub, GitLab, BitBucket</p>
<p><strong>Build</strong> - Jenkins, Bamboo, TeamCity</p>
<p><strong>Testing</strong> - Selenium, JUnit, SonarQube</p>
<p><strong>Deployment</strong> - Argo, Spinnaker, Octopus Deploy</p>
<p>I tried to break-down the building blocks involved in CI/CD pipeline. Have a nice day :)</p>
]]></content:encoded></item><item><title><![CDATA[Bridge Networking in Docker: An Overview of Network Isolation in a Container Environment]]></title><description><![CDATA[In the world of Docker, deploying a container is not simple; properly configuring a container architecture requires strong networking capabilities. A web application with a cluster of databases, applications, and load balancers spanning numerous cont...]]></description><link>https://blogs.praneshpyarashrestha.com.np/bridge-networking</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/bridge-networking</guid><category><![CDATA[Docker]]></category><category><![CDATA[docker-network]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Tue, 23 Jan 2024 11:02:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706007276723/98087f39-332c-4259-afc9-83991b9bc955.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the world of Docker, deploying a container is not simple; properly configuring a container architecture requires strong networking capabilities. A web application with a cluster of databases, applications, and load balancers spanning numerous containers that need to communicate with one another would have a different network architecture than one designed to run on a single Docker container.</p>
<p>Networking allows containers to communicate with each other and with the host system. Containers run isolated from the host system and need a way to communicate with each other and with the host system.</p>
<h2 id="heading-dockers-default-networkshttpsrefinedevblogdocker-networkingnone"><strong>Docker's Default Networks</strong><a target="_blank" href="https://refine.dev/blog/docker-networking/#none"><strong>​</strong></a></h2>
<p>Three network drivers/inte<a target="_blank" href="https://refine.dev/blog/docker-networking/#none">r</a>faces with different use cases are automatically created for you when you install Docker:</p>
<p><img src="https://bogotobogo.com/DevOps/Docker/images/Docker-Network/docker0-bridge.png" alt="Docker Networks - Bridge driver network - 2020" /></p>
<h3 id="heading-bridge-docker0httpsrefinedevblogdocker-networkingbridge-docker0"><strong>Bridge (docker0)</strong><a target="_blank" href="https://refine.dev/blog/docker-networking/#bridge-docker0"><strong>​</strong></a></h3>
<p>A conta<a target="_blank" href="https://refine.dev/blog/docker-networking/#none">i</a>ner connects to this network when it starts running without specifying a network. Containers connected to the bridge network are given an internal IP address to communicate with each other.</p>
<h3 id="heading-hosthttpsrefinedevblogdocker-networkinghost"><strong>Host</strong><a target="_blank" href="https://refine.dev/blog/docker-networking/#host"><strong>​</strong></a></h3>
<p>A container shares the networking namespace of the host when using the host network mode. As a result, the host's IP address and port will be used by the container to isolate and execute the process directly on the host.</p>
<h3 id="heading-nonehttpsrefinedevblogdocker-networkingnone"><strong>None</strong><a target="_blank" href="https://refine.dev/blog/docker-networking/#none"><strong>​</strong></a></h3>
<p>As the name indicates, this mode disables the networking stack of the container. The host, other containers, and external systems are all inaccessible to containers running without network. It becomes useful when you do not require any network connectivity or complete isolation.</p>
<p>To view all networks, including the default ones, you can use the command:</p>
<pre><code class="lang-bash">docker network ls
</code></pre>
<p>The output is as:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706005449597/672af02c-356e-491d-a151-691f42d330e8.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-bridge-networking-an-interactive-demo">Bridge Networking; An interactive demo</h3>
<p>The default network mode in Docker. It creates a private network between the host and containers, allowing containers to communicate with each other and with the host system.</p>
<p><img src="https://user-images.githubusercontent.com/43399466/217745543-f40e5614-ac34-4b78-85a9-91b24512388d.png" alt="image" /></p>
<p>If you want to secure your containers and isolate them from the default bridge network, you can also create your own bridge network.</p>
<pre><code class="lang-bash">docker network create -d bridge &lt;my_bridge_name&gt;
</code></pre>
<p>Now, if you list the available networks, the new bridge is added.</p>
<pre><code class="lang-bash">docker network ls

NETWORK ID          NAME                DRIVER
xxxxxxxxxxxx        bridge              bridge
xxxxxxxxxxxx        my_bridge_name      bridge
xxxxxxxxxxxx        none                null
xxxxxxxxxxxx        host                host
</code></pre>
<p>Now, if you want to see containers' details in the bridge network, you can use the following command:</p>
<pre><code class="lang-bash">docker network inspect bridge
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706005764661/7986e1e7-8a67-48f2-a8aa-84da4a617968.png" alt class="image--center mx-auto" /></p>
<p>For a demo, we run two containers named viz. login and logout using command:</p>
<pre><code class="lang-bash">docker run -d --name login nginx:latest
docker run -d --name <span class="hljs-built_in">logout</span> nginx:latest
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706006131262/214d17f8-40db-47b3-9f8d-0d2f0820cbe5.png" alt class="image--center mx-auto" /></p>
<p>Now, if we hop in to the running login container using command:</p>
<pre><code class="lang-bash">docker <span class="hljs-built_in">exec</span> -it login /bin/bash
</code></pre>
<p>Currently the running containers are:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706006264717/9b2936df-da80-48ad-8a99-ba27559c701d.png" alt class="image--center mx-auto" /></p>
<p>Now, if we run the command</p>
<pre><code class="lang-bash">docker inspect <span class="hljs-built_in">logout</span>
</code></pre>
<p>We see that its IP address is 172.17.0.1</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706006345203/fda77b12-caf9-4ced-8db8-1e0349f51b0f.png" alt class="image--center mx-auto" /></p>
<p>Now returning back to the interactive bash of login, if we ping the IP address of logut (172.17.0.1), we get:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706006463897/52c3f9c0-3369-44a1-970f-6dafd0849ced.png" alt class="image--center mx-auto" /></p>
<p>This means that, both the login and logout are now connected via a bridge network.</p>
<p>Now, we create a new network named secure-network using the command:</p>
<pre><code class="lang-bash">docker network create secure-network
</code></pre>
<p>Now, in this network, we isolate a new container named finance.</p>
<p>We run a new named container named finance under this network using the command:</p>
<pre><code class="lang-bash">docker run -d --name finance --network=secure-network nginx:latest
</code></pre>
<p>Now, if we inspect the info of this container using command:</p>
<pre><code class="lang-bash">docker inspect finance
</code></pre>
<p>We see that the IP of this container is in new subnet, which in our case is 172.19.0.1</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706006770648/96a46fba-5056-42be-b78d-3298ebc6370c.png" alt class="image--center mx-auto" /></p>
<p>Moreover, the network is also secure-network (for previous one, it was bridge).</p>
<p>Now, if we ping this from the login interactive bash, we cannot get any info of this container. This implies that our container is isolated from the other two. This enhances the security too.</p>
<p>In this way, we created the three containers, among which two were in same subnet and one was isolated from the other two.</p>
]]></content:encoded></item><item><title><![CDATA[Proxy Server vs Reverse Proxy Server | Explained with real-life example]]></title><description><![CDATA[Proxy and reverse proxy servers are common terms in backend engineering and computer networking. You may have heard of them before, but do you know what they mean and how they differ?
In this article, I will use a simple real-life example to explain ...]]></description><link>https://blogs.praneshpyarashrestha.com.np/proxy</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/proxy</guid><category><![CDATA[proxy]]></category><category><![CDATA[Reverse Proxy]]></category><category><![CDATA[Proxy Server]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Wed, 03 Jan 2024 17:10:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1704301724565/ab92a2c8-6565-45f7-b8a2-4084ecf9eb79.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Proxy and reverse proxy servers are common terms in backend engineering and computer networking. You may have heard of them before, but do you know what they mean and how they differ?</p>
<p>In this article, I will use a simple real-life example to explain the concept of proxy in the simplest way possible.</p>
<h3 id="heading-analogy">Analogy</h3>
<p>In our childhood, whenever we wanted anything, we always went to our parents and asked for it. And then it was up to parents to decide if it was a legitimate request to be fulfilled or not.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1616433284797/9cNbuqDHE.png?auto=compress,format&amp;format=webp" alt="Storyboard Brainstorm Presentation (2).png" /></p>
<p>Suppose you wanted a toy. You always thought that your parents are the one who will fulfil your request. That was actually true, as your parents went outside (to market) to get the stuff. They never let the outside world come in contact with you because you were too small. Thats how our parents shielded us from the outside world till the time we were matured enough to handle it by ourselves.</p>
<p>Simply, just correlate this example with a proxy server.</p>
<p>In simple words, proxy is an act that someone else does on your behalf. (Eg - Proxy attendance in college). Proxy is an interface between you and the outside world.</p>
<h3 id="heading-proxy-server">Proxy Server</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1616432849097/C6AWCXVzO.png?auto=compress,format&amp;format=webp" alt="proxy-server-1024x649.png" /></p>
<p>So basically, proxy works for the safety of the client. Whenever we are making any request from our local machine to hit a server which is present outside the network (from intranet to internet), proxy it the interface through which we send the request and it fetches the data from the internet on our behalf.</p>
<p><strong>Use cases of Proxy</strong></p>
<ol>
<li><p><strong>Caching</strong> - It is a very popular use case of proxy server. It saves bandwidth by caching the content and serving it back to the client instead of going to the internet every time.</p>
</li>
<li><p><strong>Anonymity</strong> - Proxy talks to the server so the final destination (server) does not know from where the request is actually coming from.</p>
</li>
<li><p><strong>Security</strong> - It acts as a firewall. Multiple client machines can talk to a centralized proxy server. It helps organizations and ISPs, block or filter the bad requests which could impact client machines sitting inside the network.</p>
</li>
<li><p><strong>Encryption &amp; Decryption</strong> - Proxy can encrypt and hide (mask) IP address and sensitive data going through the request. It only sends it in a way where you can not be discovered back.</p>
</li>
<li><p><strong>Logging</strong> - Logging can help caching the pages which are being visited often.</p>
</li>
<li><p><strong>Microservices</strong> - This is one of the latest and very interesting use case of proxy. There are several types of proxy such as sidecar proxy, HTTP proxy, TCP proxy etc. We can deploy proxy next to our application and it can take care of all the networking stuff.</p>
</li>
</ol>
<p>For example, we are sending a HTTP request from our microservice, and our sidecar proxy can upgrade it to a newer protocol as HTTP2 or HTTP3.</p>
<h3 id="heading-reverse-proxy-server">Reverse Proxy Server</h3>
<p>As the name says, its just reverse of proxy and that's why it's very confusing. The main concept and the difference is that, instead of doing it from the client side (as it was in proxy), it does it from the server side.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1616432861122/f2_Naj31I.jpeg?auto=compress,format&amp;format=webp" alt="FreeReverseProxy.jpg" /></p>
<p>A reverse proxy server does the opposite of a regular proxy server. It protects the server instead of the client. When an internet request wants to access a server in our network, it goes through the reverse proxy server first. The reverse proxy server then decides which server to forward the request to, without exposing our servers.</p>
<p>Picture a reverse proxy as your trusted friend navigating the busy streets of Kathmandu for you. You're craving momo from your favorite spot, but instead of braving the traffic and crowds yourself, your friend goes, places the order, and brings the delicious dumplings right to your doorstep. In the online world, a reverse proxy does something similar for websites—it handles the complex stuff, like managing traffic and securing connections, so the website can focus on delivering content without getting overwhelmed. It's like having a reliable friend making sure you get what you want, hassle-free!</p>
<p><strong>Advantages of Reverse Proxy server -</strong></p>
<p>Almost all the benefits we have from proxy server including caching, security etc, all are there in reverse proxy too. Here we have some additional benefits.</p>
<ol>
<li><p><strong>Load balancing</strong> A reverse proxy can distribute the load among multiple servers and compress the request size, which improves the overall performance.</p>
</li>
<li><p><strong>Ingress</strong> - Kubernetes and microservice architecture use a request-based routing mechanism. This means that each request is directed to the specific service that can handle it. For example, if a request comes for a picture API, it is routed to the corresponding service. In this way, Kubernetes and microservice architecture act as routers.</p>
</li>
<li><p><strong>Canary Development</strong>: A canary deployment is a way of testing a new feature on a small subset of users before rolling it out to everyone. For example, YouTube might want to try showing a randomly generated thumbnail for 10% of its requests. This can be achieved by using a reverse proxy that redirects some traffic to the new version of the service.</p>
</li>
</ol>
<p>Thanks for reading!</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Docker: Exploring Containers vs. Virtual Machines]]></title><description><![CDATA[Docker is nothing but a Container technology. It's a tool for creating and managing containers. You might be wondering what a container is. Let me explain it to you!
A Container is a package of code and all the dependencies  that our project needs. A...]]></description><link>https://blogs.praneshpyarashrestha.com.np/docker-vs-vm</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/docker-vs-vm</guid><category><![CDATA[Docker]]></category><category><![CDATA[virtual machine]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Sat, 16 Dec 2023 10:43:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702723893110/3599ed84-d205-4487-865e-692588c17a14.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Docker</strong> is nothing but a Container technology. It's a tool for creating and managing containers. You might be wondering what a container is. Let me explain it to you!</p>
<p>A Container is a <mark>package of code</mark> and all the <mark>dependencies </mark> that our project needs. And the same container <mark>always yields the same application</mark> and execution behavior. <mark>No matter where it is executed</mark>.</p>
<h3 id="heading-why-containers">Why Containers?</h3>
<p>There are several reasons for using containers:</p>
<ul>
<li><p>We want to have the exact same environment for development and production as well. This will ensure that our application works exactly the same in production as it did in development.</p>
</li>
<li><p>Every team member should have the same environment when working on a project.</p>
</li>
<li><p>When switching between projects, tools used in Project X should not clash with those of Project Y. Say, your X project needs Nodejs 14 and Y needs Nodejs 16. No worries. Docker has your back!</p>
</li>
</ul>
<p>Mind you, a container is a running unit of software, but first, we always create a template/blueprint for it which is called an <mark>Image</mark>. Multiple containers can be created from a single Image.</p>
<h3 id="heading-virtual-machines">Virtual Machines</h3>
<p><em>A VM is an isolated computing environment created by abstracting resources from a physical machine</em>. It may look the same as a Docker container at first.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699252461738/b29c8d14-49ab-4f50-9ae6-9e06ae22cbe6.png?auto=compress,format&amp;format=webp" alt /></p>
<p>This is a simplified architecture of a Virtual Machine. As you can see clearly, each VM instance has its own guest OS.</p>
<p>VM is more like an <mark>overhead</mark> because it eats up much <mark>memory and CPU</mark>. It wastes a lot of space and tends to be slow. Most importantly, there is no single config file that you can share if you want to replicate the same environment on some other colleague's computer (In Docker, you can share the image easily, but we'll look at it afterward). Though you can reproduce the same environment on other computers, it is very tricky.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699253040956/80fa808b-e5af-4240-b500-5fc31c41d5c8.jpeg?auto=compress,format&amp;format=webp" alt /></p>
<p>Unlike VMs, containers do not have their own guest OS, rather they run on top of the host Operating System. Containers have a very low impact on OS, they tend to be very fast and also require minimal disk space usage. And <mark>sharing and rebuilding them is easy</mark>. You just need to share the images (we'll see what images are later!), and you can reproduce the container within a matter of seconds!</p>
<h2 id="heading-containerization-vs-virtualization">Containerization vs. Virtualization</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1702722732295/7c22e396-5b1d-4908-918c-0f9cf01fa14f.png" alt class="image--center mx-auto" /></p>
<p>Basically, an OS has two layers viz. OS Kernel and Application. Docker(a form of containerization) utilizes the application layer whereas Virtual Machines(VM) utiizes the OS kernel and application layer. So it might be clear that Docker images have less overhead and are much smaller in size(usually in MegaBytes). However, VMs are usually in GigaBytes. Also, Docker containers start and run faster. A VM lets you run a virtual machine on any hardware. Docker lets you run an application on any operating system. It uses isolated user-space instances known as containers. Docker containers have their own file system, dependency structure, processes, and network capabilities.</p>
<p>These are the choices why containers have become a go-to choice for software development. There is much to Docker: images, volumes, networks, multi-container applications, docker-compose and much more. I'll surely be writing about them as well very soon!</p>
<p>This foundation was necessary, and now we can explore Docker further!</p>
]]></content:encoded></item><item><title><![CDATA[Dive Deep into Kubernetes Architecture and Critical Components for Seamless Container Orchestration]]></title><description><![CDATA[Kubernetes, often abbreviated as K8s, has become the de facto standard for container orchestration, enabling organizations to deploy, scale, and manage containerized applications seamlessly. In this blog, we'll delve into the fundamental aspects of K...]]></description><link>https://blogs.praneshpyarashrestha.com.np/kubernetes</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/kubernetes</guid><category><![CDATA[Kubernetes]]></category><category><![CDATA[Devops]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Sat, 02 Dec 2023 16:02:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1701532844022/b7779ad5-ab32-4c59-a19f-17bd4660dedf.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Kubernetes, often abbreviated as K8s, has become the de facto standard for container orchestration, enabling organizations to deploy, scale, and manage containerized applications seamlessly. In this blog, we'll delve into the fundamental aspects of Kubernetes architecture and explore its key components that make it a powerful and versatile container orchestration platform.</p>
<p>Take a closer look at the below diagram (especially the arrows &amp; lines). We'll take a closer look at what these arrows represent, what is an API server, what is the line that is pointing to the API server from Kubelet, what is the difference between the control plane &amp; worker node, why is there a need for a control plane and many more such questions shall be entirely answered by the end of this blog.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673682551681/a65c7c62-463b-49dc-8783-47babbbcef4e.png?auto=compress,format&amp;format=webp" alt /></p>
<p>Before understanding the architecture, let's first look at the terminologies used widely in the Kubernetes ecosystem.</p>
<ol>
<li><p><strong>Node:</strong> A Node in Kubernetes is a representation of a single machine in your Kubernetes cluster. In production, a node will most likely be a physical machine at a data center or a virtual machine hosted on the cloud.</p>
</li>
<li><p><strong>Pods:</strong> Kubernetes does not run containers directly. Instead, it runs containers inside a spherical body called Pods.</p>
</li>
</ol>
<ul>
<li><p>Inside your Node, runs the pod. Inside your Pod, runs the containers. Inside your container, runs the application.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673769672363/0e2a2c8a-e26e-4fd3-8965-f0d53907c441.png?auto=compress,format&amp;format=webp" alt /></p>
</li>
</ul>
<p><strong>Cluster:</strong> It is a group of nodes, both physical &amp; virtual, which is used to run the containerized application.</p>
<ul>
<li><p>Let's suppose I've 3 nodes that are used to run a containerized application. The grouping of all these nodes to create a more powerful machine is what we call a cluster.</p>
<hr />
</li>
</ul>
<p>Let's try to understand the architecture of Kubernetes - what is happening behind the scenes?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673682551681/a65c7c62-463b-49dc-8783-47babbbcef4e.png" alt /></p>
<p>Look at the above image carefully. We've grouped three nodes (1 Control plane &amp; 2 worker nodes) which is called a Kubernetes cluster. You can create as many nodes as you wish, depending on the application requirement.</p>
<p>In any Kubernetes cluster, two types of nodes are present:</p>
<ol>
<li><p>One or more <strong>Control Plane nodes</strong> (also called a Master node)</p>
</li>
<li><p>One or more <strong>Worker nodes</strong></p>
</li>
</ol>
<p>Now if you look above, you'll find that each node has some components associated with it. The Control Plane node has some components such as API server, Scheduler, etc. whereas Worker nodes have some components such as kubelet, kube-proxy, etc. We'll take a look at the role of each component in a specific node.</p>
<p>The worker nodes are responsible for running your application (as you can see pods are present inside the worker node) whereas the control plane node is responsible for managing your cluster operations such as starting the cluster, adding new nodes to the cluster, removing pods, scaling pods and much more.</p>
<p>Hence without a control plane node, your Kubernetes cluster won't work. It is important to keep the control plane running at all costs.</p>
<p>Let's understand the usage of each component of the control plane</p>
<ol>
<li><p><strong>API Server:</strong> This is the brain behind all the operations in a Kubernetes cluster. To interact with the cluster, all the requests are sent to the API server. The API Server intercepts RESTful calls from users, administrators, developers, operators, and external agents, then validates and processes them. Whenever a request has been sent to the API server by the user, the API server performs three tasks:</p>
<ul>
<li><p>Authentication: Authenticates the user</p>
</li>
<li><p>Authorization: Authorizes the request made by the authenticated user (using RBAC)</p>
</li>
<li><p>Admission control policy: applies certain rules on Pods to run</p>
</li>
</ul>
</li>
<li><p><strong>Scheduler:</strong> The main role of the scheduler is to assign the pods to the nodes. Let's suppose, you request the API server via the command line mentioning running a pod (or a container). That request will be received and forwarded to the scheduler after authentication, authorization &amp; admission control policy so that the scheduler can find the best node (worker node) to run a pod inside of it.</p>
<p> The scheduler determines the valid nodes for the placement of a node in the scheduling queue, ranks each node based on resources available and required, and then binds the pod to a specific node.</p>
</li>
<li><p><strong>Controller Manager:</strong> The controller manager is the component of the Kubernetes control plane node that regulates the state of the Kubernetes cluster by running controllers or operators. Controllers are watch-loop processes that compare the cluster's desired state with the cluster's actual state. But where does this actual state being stored? Etcd store.</p>
</li>
</ol>
<p><strong>Key-Value data store(etcd):</strong> All the cluster-related information is stored inside <a target="_blank" href="https://etcd.io/"><strong>etcd</strong></a>. It is important to note that the application data is not stored in the etcd store. New data is written in the etcd store by appending and not by overriding. Obsolete data (incorrect data) is compacted (or shredded) periodically to minimize the size of the data store. etcd is based on <a target="_blank" href="https://en.wikipedia.org/wiki/Raft_(algorithm)"><strong><em>Raft Consensus Algorithm</em></strong></a>. Remember, when we discussed above, that the scheduler selects a node to run a pod inside of it? Here's the actual process that happens:</p>
<ul>
<li><p>A request is sent by the client to the API server to run a pod</p>
</li>
<li><p>API server validates the user &amp; request</p>
</li>
<li><p>The request is passed to the scheduler to select a node.</p>
</li>
<li><p>After receiving the request, the scheduler sends a request to the API server to get the cluster-related information like resources available etc.</p>
</li>
<li><p><strong>API server is the only component that can read and write data in the etcd store. No other component can connect directly with the etcd store.</strong></p>
</li>
<li><p>API server after receiving the information informs the scheduler</p>
</li>
<li><p>Based on the information received by the API server, scheduler binds the pod to a node.</p>
</li>
</ul>
<p>Now you might ask me, "Does this mean that pod is running?"</p>
<p>The answer is No.</p>
<p>Till this time, the correct node has been selected on which a pod should run but a Pod is not running yet.</p>
<ol>
<li><strong>Cloud Controller Manager(CCM):</strong> The CCM is responsible for running the controllers or operators to interact with the underlying infrastructure of a cloud host provider when nodes become unavailable.</li>
</ol>
<p>Now try to go through these control plane components once again and then move forward.</p>
<p>It's time to understand the usage of each component on the worker node:</p>
<p>A worker node provides an environment to run a containerized application. The components present inside the worker node are:</p>
<ul>
<li><p>Kubelet</p>
</li>
<li><p>kube-proxy</p>
</li>
<li><p>container runtime</p>
</li>
<li><p>Addons or DNS</p>
</li>
</ul>
<ol>
<li><p><strong>Container runtime:</strong> Although Kubernetes is regarded as a “container orchestrating tool” it cannot run containers directly. Hence, a container runtime is needed on a node where a pod is scheduled to manage a container's lifecycle. It is important to note that <strong>container runtime are present on both nodes - the</strong> <strong>control plane and worker.</strong> Kubernetes supports several container runtimes, which are mentioned below:</p>
<ul>
<li><p>CRI-O</p>
</li>
<li><p>containerd</p>
</li>
<li><p>Docker</p>
</li>
<li><p>Mirantis Container Runtime</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673777110781/7cd73c27-8fc2-4286-abe8-e2e45565a251.png?auto=compress,format&amp;format=webp" alt /></p>
</li>
</ul>
</li>
<li><p><strong>Kubelet:</strong> Like container runtime, kubelet is present on both the nodes - the control plane and the worker node. To run a pod that is present on a worker node, there should be some component that must communicate with the control plane to run a pod. Kubelet is that component. The Kubelet of each node interacts with the control plane and waits for the order from the API server to run a Pod. Once the kubelet of a node receives the orders from the API server, it interacts with the container runtime of its node through a plugin-based interface (CRI shim). Hence, a pod starts running now.</p>
</li>
</ol>
<p>In case you got confused, here's the summary of the internal working of Kubernetes components: <strong>Don't miss this!</strong></p>
<ul>
<li><p>The user sends a request to the API server to start a Pod</p>
<pre><code class="lang-bash">    kubectl run &lt;pod-name&gt; --image=&lt;image-name&gt;
</code></pre>
</li>
<li><p>This request is now being validated by the API server.</p>
</li>
<li><p>API server forwards this request to the scheduler on the control plane.</p>
</li>
<li><p>In return, Scheduler requests cluster-related information from the API server since API server is the only component that can interact with etcd store.</p>
</li>
<li><p>API after receiving this request from the scheduler reads the data from the etcd store and provides it to the scheduler.</p>
</li>
<li><p>The scheduler after receiving the information assigns a pod to a node based on the information and conveys this message to the API server.</p>
<p>  <em>"Hey API server, the pod should run on node-01"</em></p>
<p>  <em>- scheduler</em></p>
</li>
<li><p>API server assigns a specific node's kubelet to start a pod.</p>
</li>
<li><p>On receiving the orders from the API server, kubelet of that node interacts with the container runtime via CRI shim and now a pod has started running on a specific node. While the Pod is running, the controller manager checks whether the desired state of the cluster is in matches the actual state of the Kubernetes cluster.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1673778510549/aa7ba8d4-9803-404f-8a77-3112f03fba25.png?auto=compress,format&amp;format=webp" alt /></p>
</li>
</ul>
<hr />
<p>Now, you might ask me what is the role of kube-proxy &amp; addons?</p>
<p><strong>Kube-proxy</strong> (runs on each node) is responsible for networking rules in a cluster. For eg.</p>
<ul>
<li><p>Container-to-container communication inside Pods</p>
</li>
<li><p>Pod-to-Pod communication on the same node and across cluster nodes</p>
</li>
<li><p>Pod-to-Service communication within the same namespace and across cluster namespaces</p>
</li>
<li><p>External-to-Service communication for clients to access applications in a cluster.</p>
</li>
</ul>
<p><strong>Addons</strong> are cluster features that are implemented through 3rd-party pods and services. For eg., a Dashboard is a general-purpose user interface for cluster management via web UI.</p>
<p>Finally, look at the arrows in the topmost image and let me know if you understood what they were referring to.</p>
<p>If you've read up to here, Congratulations!</p>
<p>Understanding Kubernetes architecture and its components is essential for efficiently deploying and managing containerized applications. This blog provides a foundational overview, but Kubernetes is a vast ecosystem with many additional features and components to explore. As you embark on your Kubernetes journey, remember that it's a powerful tool that can significantly simplify the deployment and scaling of containerized applications.</p>
]]></content:encoded></item><item><title><![CDATA[Dockerizing Node.js Applications: A Practical Step-by-Step Walkthrough]]></title><description><![CDATA[Intro
In the world of modern software development, containerization has become a crucial technology for building, deploying, and scaling applications. Docker, a popular containerization platform, provides a standardized way to package applications an...]]></description><link>https://blogs.praneshpyarashrestha.com.np/dockerizing-nodejs-applications-a-practical-step-by-step-walkthrough</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/dockerizing-nodejs-applications-a-practical-step-by-step-walkthrough</guid><category><![CDATA[Docker]]></category><category><![CDATA[Node.js]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Wed, 22 Nov 2023 04:27:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1700627125405/89c4e008-58f8-4a4a-8347-0802c010b6ff.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-intro">Intro</h2>
<p>In the world of modern software development, containerization has become a crucial technology for building, deploying, and scaling applications. Docker, a popular containerization platform, provides a standardized way to package applications and their dependencies into containers. In this blog post, we will guide you through the process of Dockerizing a Node.js application, allowing you to achieve consistency and portability across different environments.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Title: Dockerizing a Node.js App: A Step-by-Step Guide</p>
<p>Introduction:</p>
<p>In the world of modern software development, containerization has become a crucial technology for building, deploying, and scaling applications. Docker, a popular containerization platform, provides a standardized way to package applications and their dependencies into containers. In this blog post, we will guide you through the process of Dockerizing a Node.js application, allowing you to achieve consistency and portability across different environments.</p>
<p>Prerequisites:</p>
<p>Before we begin, make sure you have the following installed on your machine:</p>
<ol>
<li><p>Docker: Download and install Docker from the official website (<a target="_blank" href="https://www.docker.com/get-started">https://www.docker.com/get-started</a>).</p>
</li>
<li><p>Node.js: Ensure Node.js is installed on your machine. You can download it from the official website (<a target="_blank" href="https://www.docker.com/get-started">https://nodejs.org/</a>).</p>
</li>
</ol>
<p><img src="https://i1.wp.com/learncode24h.com/wp-content/uploads/2021/08/docker-nodejs.jpg?w=825&amp;ssl=1" alt="Docker tutorial - Build Docker image for Nodejs application and deploy ..." /></p>
<h3 id="heading-step-1-setup-for-nodejs-app">Step 1: Setup for Node.js app</h3>
<p>First, create a node.js application:</p>
<p>If you don't already have a Node.js application, create a simple one for the purpose of this demonstration. Use the following commands:</p>
<pre><code class="lang-bash">mkdir nodejs-app
<span class="hljs-built_in">cd</span> nodejs-app
npm init -y
npm install express
</code></pre>
<p>We have made a directory named nodejs-app. After that, we start by npm init, it initializes all the requirements. For simplicity, we have also installed express library.</p>
<p>Now create a file named "index.js" with following content.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> app = express();
<span class="hljs-keyword">const</span> port = <span class="hljs-number">3000</span>;

app.get(<span class="hljs-string">'/'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.send(<span class="hljs-string">'Hello, Dockerized Node.js App!'</span>);
});

app.listen(port, <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`App listening at http://localhost:<span class="hljs-subst">${port}</span>`</span>);
});
</code></pre>
<h3 id="heading-step-3-dockerfile">Step 3: Dockerfile</h3>
<p>This is the most crucial part of the dockerization process. Create a file named <code>Dockerfile</code> in the project root. This file contains instructions for building a Docker image for your Node.js application.</p>
<pre><code class="lang-dockerfile"><span class="hljs-comment"># Use an official Node.js runtime as a base image</span>
<span class="hljs-keyword">FROM</span> node:<span class="hljs-number">16</span>-alpine

<span class="hljs-comment"># Set the working directory in the container</span>
<span class="hljs-keyword">WORKDIR</span><span class="bash"> /usr/src/app</span>

<span class="hljs-comment"># Copy package.json and package-lock.json to the working directory</span>
<span class="hljs-keyword">COPY</span><span class="bash"> package*.json ./</span>

<span class="hljs-comment"># Install app dependencies</span>
<span class="hljs-keyword">RUN</span><span class="bash"> npm install</span>

<span class="hljs-comment"># Copy the application files to the working directory</span>
<span class="hljs-keyword">COPY</span><span class="bash"> . .</span>

<span class="hljs-comment"># Expose the port the app will run on</span>
<span class="hljs-keyword">EXPOSE</span> <span class="hljs-number">3000</span>

<span class="hljs-comment"># Define the command to run your application</span>
<span class="hljs-keyword">CMD</span><span class="bash"> [<span class="hljs-string">"node"</span>, <span class="hljs-string">"index.js"</span>]</span>
</code></pre>
<h3 id="heading-step-3-build-the-docker-image">Step 3: Build the Docker Image</h3>
<p>Open a terminal, navigate to the project root directory, and run the following command to build the Docker image:</p>
<pre><code class="lang-bash">docker build -t image-name .
</code></pre>
<p>Replace the image-name with the appropriate image of my Docker image.</p>
<h3 id="heading-step-4-run-the-docker-container">Step 4: Run the Docker container</h3>
<p>Once the image is built, you can run a Docker container based on that image using the following command:</p>
<pre><code class="lang-bash">docker run -p 8080:3000 -d your-image-name
</code></pre>
<p>Here, <code>-p 8080:3000</code> maps port 3000 inside the container to port 8080 on your machine. This is known as port-mapping. Adjust the port numbers as needed.</p>
<h3 id="heading-step-5-access-your-dockerized-nodejs-app">Step 5: Access your Dockerized Node.js app</h3>
<p>Open a web browser and go to <a target="_blank" href="http://localhost:8080/">http://localhost:8080</a>. You should see the message "Hello, Dockerized Node.js App!"</p>
<h2 id="heading-wrap-up">Wrap Up</h2>
<p>Congratulations! You have successfully Dockerized a Node.js application. Containerization brings several benefits, such as isolation, portability, and scalability, making it easier to manage and deploy your applications across different environments. Feel free to explore more Docker features and optimize your Dockerfile based on the specific requirements of your Node.js application.</p>
]]></content:encoded></item><item><title><![CDATA[Implementing CI/CD for Flutter apps Using GitHub Actions]]></title><description><![CDATA[Continuous Integration and Continuous Deployment (CI/CD) is a crucial part of the software development process. It helps automate the build, testing, and deployment of your application, ensuring that code changes are integrated and deployed smoothly....]]></description><link>https://blogs.praneshpyarashrestha.com.np/ci-cdflutter</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/ci-cdflutter</guid><category><![CDATA[Flutter]]></category><category><![CDATA[ci-cd]]></category><category><![CDATA[Devops]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[github-actions]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Wed, 08 Nov 2023 14:33:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1699454381239/2383ec69-13db-49ca-9f38-a66e16942367.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Continuous Integration and Continuous Deployment (CI/CD) is a crucial part of the software development process. It helps automate the build, testing, and deployment of your application, ensuring that code changes are integrated and deployed smoothly. In this blog post, I'll walk you through setting up CI/CD for a Flutter application using GitHub Actions.</p>
<h3 id="heading-prerequisites">Prerequisites</h3>
<p>Before you start, ensure that you have the following prerequisites in place:</p>
<ol>
<li><p>A Flutter project hosted on GitHub.</p>
</li>
<li><p>Flutter installed on your development machine.</p>
</li>
<li><p>A basic understanding of GitHub Actions.</p>
</li>
</ol>
<h3 id="heading-github-actions-workflow">GitHub Actions Workflow</h3>
<p>GitHub Actions uses YAML files to define workflows. In this example, we've defined a workflow named "Build &amp; Release" that runs when pull requests are created or pushed to the <code>main</code>, <code>master</code>, or <code>develop</code> branches.</p>
<pre><code class="lang-yaml"><span class="hljs-attr">on:</span>
  <span class="hljs-attr">pull_request:</span>
    <span class="hljs-attr">branches:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">main</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">master</span>
  <span class="hljs-attr">push:</span>
    <span class="hljs-attr">branches:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">main</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">master</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">develop</span>
<span class="hljs-attr">name:</span> <span class="hljs-string">"Build &amp; Release"</span>
</code></pre>
<p>This workflow is triggered both on pull requests and direct pushes to specific branches.</p>
<h3 id="heading-workflow-steps">Workflow Steps</h3>
<p>A sample of the workflow is shown below which basically performs all the continuous integration(CI) part.</p>
<pre><code class="lang-yaml"><span class="hljs-attr">on:</span>
  <span class="hljs-attr">pull_request:</span>
    <span class="hljs-attr">branches:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">main</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">master</span>
  <span class="hljs-attr">push:</span>
    <span class="hljs-attr">branches:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">main</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">master</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">develop</span>
<span class="hljs-attr">name:</span> <span class="hljs-string">"Build &amp; Release"</span>
<span class="hljs-attr">jobs:</span>
  <span class="hljs-attr">build:</span>
    <span class="hljs-attr">name:</span> <span class="hljs-string">Build</span> <span class="hljs-string">&amp;</span> <span class="hljs-string">Release</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">macos-latest</span>
    <span class="hljs-attr">steps:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v1</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/setup-java@v1</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">java-version:</span> <span class="hljs-string">'12.x'</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">subosito/flutter-action@v1</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">flutter-version:</span> <span class="hljs-string">'3.13.9'</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">flutter</span> <span class="hljs-string">pub</span> <span class="hljs-string">get</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">flutter</span> <span class="hljs-string">test</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">flutter</span> <span class="hljs-string">build</span> <span class="hljs-string">apk</span> <span class="hljs-string">--debug</span> <span class="hljs-string">--split-per-abi</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">|
          flutter build ios --no-codesign
          cd build/ios/iphoneos
          mkdir Payload
          cd Payload
          ln -s ../Runner.app
          cd ..
          zip -r app.ipa Payload
</span>      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Push</span> <span class="hljs-string">to</span> <span class="hljs-string">Releases</span>
        <span class="hljs-attr">uses:</span> <span class="hljs-string">ncipollo/release-action@v1</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">artifacts:</span> <span class="hljs-string">"build/app/outputs/apk/debug/*,build/ios/iphoneos/app.ipa"</span>
          <span class="hljs-attr">tag:</span> <span class="hljs-string">v1.0.${{</span> <span class="hljs-string">github.run_number</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">token:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.TOKEN</span> <span class="hljs-string">}}</span>
</code></pre>
<p>Let's break down the individual steps in our CI/CD workflow:</p>
<ol>
<li><p>Check Out the Code</p>
<p> The <code>actions/checkout</code> action is used to clone your repository into the runner's workspace.</p>
<pre><code class="lang-yaml"> <span class="hljs-attr">jobs:</span>
   <span class="hljs-attr">build:</span>
     <span class="hljs-attr">steps:</span>
       <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v1</span>
</code></pre>
</li>
<li><p>Set up Java</p>
<pre><code class="lang-yaml">       <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/setup-java@v1</span>
         <span class="hljs-attr">with:</span>
           <span class="hljs-attr">java-version:</span> <span class="hljs-string">'12.x'</span>
</code></pre>
</li>
<li><p>Set up Flutter</p>
<p> Next, we use the <code>subosito/flutter-action</code> action to install the specified Flutter version.</p>
<pre><code class="lang-yaml">       <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">subosito/flutter-action@v1</span>
         <span class="hljs-attr">with:</span>
           <span class="hljs-attr">flutter-version:</span> <span class="hljs-string">'3.13.9'</span>
</code></pre>
</li>
<li><p>Get Dependencies &amp; Run Tests</p>
<p> Use the following steps to fetch dependencies and run tests:</p>
<pre><code class="lang-yaml">       <span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">flutter</span> <span class="hljs-string">pub</span> <span class="hljs-string">get</span>
       <span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">flutter</span> <span class="hljs-string">test</span>
</code></pre>
</li>
<li><p>Build the Android APK</p>
<p> Build the Android APK for your Flutter application in debug mode:</p>
<pre><code class="lang-yaml">       <span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">flutter</span> <span class="hljs-string">build</span> <span class="hljs-string">apk</span> <span class="hljs-string">--debug</span> <span class="hljs-string">--split-per-abi</span>
</code></pre>
</li>
<li><p>Build the iOS IPA</p>
<p> For iOS, we generate IPA as following:</p>
<pre><code class="lang-yaml">       <span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">|
           flutter build ios --no-codesign
           cd build/ios/iphoneos
           mkdir Payload
           cd Payload
           ln -s ../Runner.app
           cd ..
           zip -r app.ipa Payload</span>
</code></pre>
</li>
</ol>
<p>Push the artifacts to GitHub releases</p>
<p>Finally, we use the <code>ncipollo/release-action</code> action to package the built artifacts (APK and IPA) and create a GitHub release. It will also tag the release with a version number.</p>
<pre><code class="lang-yaml">      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Push</span> <span class="hljs-string">to</span> <span class="hljs-string">Releases</span>
        <span class="hljs-attr">uses:</span> <span class="hljs-string">ncipollo/release-action@v1</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">artifacts:</span> <span class="hljs-string">"build/app/outputs/apk/debug/*,build/ios/iphoneos/app.ipa"</span>
          <span class="hljs-attr">tag:</span> <span class="hljs-string">v1.0.${{</span> <span class="hljs-string">github.run_number</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">token:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.TOKEN</span> <span class="hljs-string">}}</span>
</code></pre>
<p>The <code>TOKEN</code> secret should be set up in your repository's settings with appropriate permissions to create releases.</p>
<h3 id="heading-pipeline-overview">Pipeline overview</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699437471108/ccfe2b56-a891-42b8-b6a8-46815e48dbae.png" alt class="image--center mx-auto" /></p>
<p>We can view the pipeline in the actions tab of the GitHub repo. After successful completion, it should look something as shown above. And, the release section becomes:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699452763498/254f4908-01b2-4b6b-ad22-17a502e0f10f.png" alt class="image--center mx-auto" /></p>
<p>And when you click on the particular release, you get to the artifacts.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699452837779/52ef53ef-896f-424e-905d-f1d53fbcf3ef.png" alt class="image--center mx-auto" /></p>
<p>This is how the CI/CD pipeline is implemented for Flutter app using GitHub actions.</p>
<p>This article mainly focused on the Continuous Integration(CI) part, the Continuous Delivery(CD) part can be implemented using Fastlane for Appstore and Playstore, which will be discussed in future articles.</p>
]]></content:encoded></item><item><title><![CDATA[Navigating the Cloud: Unpacking the Power of Amazon EC2]]></title><description><![CDATA[Intro to Amazon EC2

In the realm of cloud computing, Amazon Web Services (AWS) stands tall as an undisputed giant, offering a vast array of services designed to empower businesses of all sizes. At the core of this technological juggernaut lies Amazo...]]></description><link>https://blogs.praneshpyarashrestha.com.np/navigating-the-cloud-unpacking-the-power-of-amazon-ec2</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/navigating-the-cloud-unpacking-the-power-of-amazon-ec2</guid><category><![CDATA[AWS]]></category><category><![CDATA[ec2]]></category><category><![CDATA[AWS Certified Solutions Architect Associate]]></category><category><![CDATA[EC2 instance]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Sat, 21 Oct 2023 04:35:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1697862755693/a32a929a-6691-4d26-9fb7-6897759293bb.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-intro-to-amazon-ec2">Intro to Amazon EC2</h1>
<p><img src="https://digitalcloud.training/wp-content/uploads/2022/01/Amazon-EC2.jpg" alt="Amazon EC2 | AWS Cheat Sheet" /></p>
<p>In the realm of cloud computing, Amazon Web Services (AWS) stands tall as an undisputed giant, offering a vast array of services designed to empower businesses of all sizes. At the core of this technological juggernaut lies Amazon Elastic Compute Cloud (EC2), a versatile and robust infrastructure-as-a-service (IaaS) offering. In this blog post, we will dive into the depths of Amazon EC2, uncovering the fascinating capabilities and benefits it brings to the table. Buckle up; we're about to embark on a cloud adventure like no other!</p>
<h2 id="heading-amazon-ec2-the-clouds-workhorse">Amazon EC2: The Cloud's Workhorse</h2>
<p><img src="https://www.eginnovations.com/blog/wp-content/uploads/2021/09/Amazon-AWS-Cloud-Topimage-1.jpg" alt="Select the right AWS EC2 instance type for optimal monitoring" /></p>
<p>Amazon Elastic Compute Cloud (EC2) is often referred to as the workhorse of Amazon Web Services (AWS), and it serves as the entry point for many organizations into the world of cloud computing. This chapter is the foundation of our journey into understanding the power of EC2.</p>
<p><strong>Understanding the Role of EC2:</strong></p>
<p>EC2 is the core compute service within AWS, providing users with virtual machines, or EC2 instances, in the cloud. These instances can be thought of as versatile computing resources that can be configured to meet various computing needs. Whether you need a single virtual machine to run a web server or an entire fleet of instances to power a complex application, EC2 can accommodate.</p>
<p><strong>Virtual Machines (EC2 Instances):</strong></p>
<p>EC2 instances are the heart of the service. They are like virtual servers, allowing users to choose the type, size, and configuration of the computing resources they need. You can think of EC2 instances as the building blocks upon which you construct your cloud infrastructure.</p>
<p><strong>Configurations and Flexibility:</strong></p>
<p>What makes EC2 truly remarkable is its flexibility. Users can select from a wide range of instance types, each designed for specific use cases. You can choose instances optimized for compute-intensive tasks, memory-intensive workloads, or storage-heavy applications. Additionally, users have the freedom to select the operating system, configure network settings, and even choose how their instances are launched and stopped.</p>
<p><strong>Choosing Your Adventure:</strong></p>
<p>The part likens working with EC2 to choosing your own adventure. It's about tailoring your cloud resources to match your unique needs. Are you launching a web application, performing data analysis, or testing new software? EC2 offers the options and configurations to make it happen. This adaptability ensures that whether you're a startup, a mid-sized enterprise, or a global corporation, EC2 can fit seamlessly into your cloud strategy.</p>
<h2 id="heading-simplicity-amp-scalability-amazon-ec2s-secret-sauce">Simplicity &amp; Scalability: Amazon EC2's Secret Sauce</h2>
<p><img src="https://www.significantinfotech.com/wp-content/uploads/2021/02/amazon-aws-web-development.webp" alt="Amazon AWS | Amazon Cloud Services Surat, India | Significant Infotech" /></p>
<p>Amazon EC2's strength lies in its simplicity and scalability.</p>
<p><strong>User-Friendly Interface:</strong></p>
<p>EC2 offers a user-friendly web console for hassle-free instance management. Launching, configuring, and managing instances is intuitive, accommodating both newcomers and experienced users.</p>
<p><strong>Flexibility and Scalability:</strong></p>
<p>EC2's versatility shines through its various instance types tailored for specific use cases. Its elasticity allows effortless scaling up or down in response to changing workloads, optimizing costs and performance.</p>
<p><strong>Availability and Redundancy:</strong></p>
<p>High availability is achieved by distributing instances across multiple Availability Zones. This redundancy minimizes downtime and enhances application reliability.</p>
<p><strong>APIs and Automation:</strong></p>
<p>EC2's APIs empower automation and integration with other services, simplifying management and configuration tasks. This automation ensures consistency and efficiency.</p>
<h2 id="heading-security-in-the-cloud-how-amazon-ec2-keeps-you-fortified"><strong>Security in the Cloud: How Amazon EC2 Keeps You Fortified</strong></h2>
<p><img src="https://d1.awsstatic.com/Compliance%20V2/security-images/security-illustrations/Page-Illo_Prevent.9a440a3b5794ae42ee42d76dd98f30a7e152629e.png" alt="Cloud Security – Amazon Web Services (AWS)" /></p>
<p>In this section, we'll uncover the essential security features that make Amazon EC2 a trusted choice for safeguarding data and applications in the cloud.</p>
<p><strong>Securing Your Assets:</strong></p>
<p>Security is paramount in the cloud, and EC2 provides a robust suite of features to fortify your digital assets and infrastructure. Understanding these security provisions is essential in maintaining data integrity and protecting against threats.</p>
<p><strong>Virtual Private Cloud (VPC):</strong></p>
<p>A fundamental layer of security in EC2 is the Virtual Private Cloud (VPC). VPC allows you to create isolated network environments, controlling inbound and outbound traffic with precision. This ensures that your instances are shielded from unauthorized access, setting the stage for a secure network architecture.</p>
<p><strong>Security Groups:</strong></p>
<p>Security Groups are your virtual security guards within EC2. They act as firewalls for your instances, regulating inbound and outbound traffic. You can define rules to dictate who can access your instances and what services can be utilized, creating a strong security perimeter.</p>
<p><strong>Identity and Access Management (IAM):</strong></p>
<p>Managing user access is a pivotal component of EC2's security framework. IAM enables you to grant granular permissions to individuals and entities, ensuring that only authorized users can access and modify resources. This is a vital element in preventing unauthorized data breaches and malicious activity.</p>
<p><strong>Key Pairs and Encryption:</strong></p>
<p>EC2 emphasizes data encryption as an additional layer of defense. Key Pairs are used for secure instance access, and EC2 offers the ability to encrypt data at rest and in transit, guaranteeing the confidentiality and integrity of sensitive information.</p>
<p><strong>Monitoring and Auditing:</strong></p>
<p>Security isn't just about prevention; it's also about detection and response. EC2 provides tools for monitoring instances and network traffic, as well as the ability to audit actions and access logs, ensuring that security incidents can be swiftly identified and addressed.</p>
<h2 id="heading-types-of-aws-compute-services">Types of AWS Compute Services</h2>
<p><img src="https://jayendrapatil.com/wp-content/uploads/2017/02/aws-compute-services.png" alt="AWS Compute Services Cheat Sheet" /></p>
<p>Below is a simplified textual representation of the AWS compute services:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Service Name</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td>Amazon Elastic Compute Cloud (EC2)</td><td>Virtual servers for various workloads.</td></tr>
<tr>
<td>Amazon Elastic Container Service (ECS)</td><td>Container orchestration for Docker containers.</td></tr>
<tr>
<td>Amazon Elastic Kubernetes Service (EKS)</td><td>Managed Kubernetes for containerized applications.</td></tr>
<tr>
<td>AWS Lambda</td><td>Serverless compute for event-driven workloads.</td></tr>
<tr>
<td>AWS Batch</td><td>Managed batch processing for large-scale jobs.</td></tr>
<tr>
<td>Amazon Lightsail</td><td>Simple virtual private servers with templates.</td></tr>
<tr>
<td>AWS Fargate</td><td>Serverless compute for containerized applications.</td></tr>
<tr>
<td>Amazon App Runner</td><td>Simplified containerized application deployment.</td></tr>
<tr>
<td>AWS Outposts</td><td>Extends AWS infrastructure to on-premises locations.</td></tr>
<tr>
<td>AWS Serverless Application Repository</td><td>Discover and deploy pre-built serverless apps.</td></tr>
</tbody>
</table>
</div><p>This chart provides a basic overview of each AWS compute service and its primary function.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In our journey through the above article, we've discovered the foundational strengths of Amazon EC2 within the world of cloud computing. EC2 serves as the gateway to the cloud, offering unparalleled versatility and adaptability through customizable instances to suit a range of computing needs, whether you're a startup or a global enterprise. Its secret sauce lies in its user-friendly interface, scalability, and robust security provisions, ensuring not only ease of use but also resilience and fortification in the cloud. As we proceed in our exploration, we'll delve deeper into the advanced capabilities, cost-efficiency, and real-world applications that make EC2 a linchpin in the AWS ecosystem, supporting businesses in their journey to harness the power of the cloud.</p>
]]></content:encoded></item><item><title><![CDATA[Containerization with Docker]]></title><description><![CDATA[Before Containers
Let us dial back the clock. Back when computers were a novelty, and companies wanted to run their applications, they would have had to buy a server for doing so. However, this came with a caveat: you could only run one application p...]]></description><link>https://blogs.praneshpyarashrestha.com.np/containerization-with-docker</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/containerization-with-docker</guid><category><![CDATA[Docker]]></category><category><![CDATA[containerization]]></category><category><![CDATA[docker-engine]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Wed, 25 Jan 2023 10:12:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674645462532/427318ee-b0b9-4432-9b28-ae41a2120ff5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-before-containers">Before Containers</h3>
<p>Let us dial back the clock. Back when computers were a novelty, and companies wanted to run their applications, they would have had to buy a server for doing so. However, this came with a caveat: you could only run one application per server. If you wanted to run multiple applications, you would have to buy as many servers. As costs would skyrocket, this was a problem, for both the company and the environment on a larger scale</p>
<p>IBM fixed this issue by introducing the concept of <em>virtual machines</em> into the game. With them, we could run multiple applications on the same server. You may have heard of / done dual booting on your PC; like installing windows on your Mac device or Ubuntu on Windows. These are virtual machines. However, they had a problem as well. They needed their own operating system, which tended to take up a lot of memory and storage on your hard disk. This made them slow and not so efficient.</p>
<h3 id="heading-containerization-advent">Containerization Advent</h3>
<p>Imagine you are moving to Kathmandu from Dharan (or swap those two cities with any two). Would it make sense to send your belongings one by one, or would you rather put them all in one giant box and ship the box directly? Obviously the latter, right?</p>
<p>That big box is, in simple terms, a container.</p>
<p>Let’s say you built a website that works well on your system but your friend runs into some problems with it when they try using it on their computer. To avoid such hassles, you can use a container, which would ship the entire website along with its dependencies, such as the web database, front end, back end, source code, etc. This would ensure that the website runs smoothly.</p>
<p>In computing terms, containerization is an efficient method for running, deploying and scaling applications.</p>
<h3 id="heading-containers-vs-virtual-machines">Containers vs. Virtual Machines</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1646204474854/upX_jHWi2.png?auto=compress,format&amp;format=webp" alt="CONT.png" /></p>
<p>Any application which runs on a VM will require a guest OS to run, which would require a hypervisor. A hypervisor manages the virtual machines and is used to create multiple machines on the host operating system. As you can see from the above picture, every OS would require a dedicated amount of space in the hardware, which is virtually divided.</p>
<p>In the case of containers, you need have only one operating system, and on top of that, you have a container engine, on which you run applications. They use the idea of isolating your application from the main operating system.</p>
<p>To sum it up succinctly, virtual machines use multiple operating systems to run multiple applications whereas containers use only the host operating system to run applications via the container engine.</p>
<p>In actuality, however, containers run on top of virtual machines. You can say they are a lightweight alternative.</p>
<h3 id="heading-okay-but-docker">Okay, but Docker.. ??</h3>
<p>Before diving into Docker, let's take a brief tour of some of the cloud-based services that most of us are familiar with. So understanding Docker will be a cakewalk.</p>
<p>You are probably familiar with Google Photos, Google Drive, GitHub, etc. These are examples of cloud-based services. In these services, you can upload your photos and code to the cloud, making them accessible from any device and not just limited to your local device.</p>
<p>Docker, on the other hand, is a platform that allows for the creation, deployment, and management of containers. Simply put, you can understand that Docker is like a ship on which containers are loaded and deployed on the cloud, allowing you to access them from anywhere. The logo of Docker visualizes what I mean.</p>
<p><img src="https://miro.medium.com/max/1200/1*dYwZLokBI4pegOVqypoSvQ.jpeg" alt="Running GUI Applications in Docker Container | by Ankush Chavan | Medium" /></p>
<p>In recent years, containerization has taken the software development and deployment world by storm, and Docker has emerged as one of the most popular and widely-used containerization platforms. Docker is one among many container platforms that allows you to build such containers to test, build and scale applications rapidly and easily by running them in isolated environments. One of the key perks of containerization with Docker is the ability to achieve consistency and portability across different environments.</p>
<p>There are various terminologies involved in Docker. Some of them are:</p>
<p><img src="https://www.edureka.co/blog/wp-content/uploads/2019/09/Picture1-15.png" alt="Docker Architecture | How Docker Works? | Edureka" /></p>
<ul>
<li><p>Docker Runtime</p>
<p>  Docker Runtime refers to the environment in which Docker containers are executed. It includes the Docker daemon, the Docker client, and the underlying operating system and system libraries.</p>
</li>
<li><p>Docker Daemon</p>
<p>  It is the heart of the Docker architecture, which does the crucial work of building, running, and distributing the containers. It also manages the Docker images and the containers.</p>
</li>
<li><p>Docker Client</p>
<p>  The Docker client is used to interact with the daemon and issue commands to create, start, stop and manage containers.</p>
</li>
<li><p>Docker CLI</p>
<p>  It allows users to issue commands to the Docker Daemon. Docker uses a client-server architecture.</p>
</li>
<li><p>Docker Engine</p>
<p>  Docker Engine is the underlying technology that runs the Docker platform. It is the component responsible for creating and managing Docker containers. The Docker Engine is made up of several components, including the Docker daemon, the Docker client, and the Docker API.</p>
</li>
<li><p>Docker Image</p>
<p>  The file that contains the source code, OS files to run the application along with its other dependencies inside the container is called Docker image. A containerized application is the running instance of an image. Docker images are immutable.</p>
</li>
<li><p>Dockerfile</p>
<p>  A Dockerfile is a script that contains instructions for building a Docker image. It is used to create an automated build that can be used to create a container image. A Dockerfile is a simple text file that contains a set of commands that are executed to build the image.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674641319134/c66f445e-1d1b-4fa7-8be0-4f43dc79b9fb.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>In conclusion, containerization with Docker is a game-changer in application development and deployment. It allows for consistency and portability across different environments, increases the utilization of resources, and enables collaboration and automation. If you're not yet using Docker and containers in your development and deployment process, it's definitely worth considering.</p>
]]></content:encoded></item><item><title><![CDATA[[DevOps] Configuration Management with Chef: An Introduction to the tool's architecture and workflow]]></title><description><![CDATA[DevOps aims to bridge the gap between development and operations teams, enabling organizations to deliver high-quality software faster and more efficiently. One key aspect of DevOps is configuration management, which involves defining and maintaining...]]></description><link>https://blogs.praneshpyarashrestha.com.np/chef-devops</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/chef-devops</guid><category><![CDATA[Devops]]></category><category><![CDATA[configuration management]]></category><category><![CDATA[Infrastructure as code]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Fri, 06 Jan 2023 05:11:52 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672982306039/ca80ef75-e52e-408f-b98f-b3a531406b59.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>DevOps aims to bridge the gap between development and operations teams, enabling organizations to deliver high-quality software faster and more efficiently. One key aspect of DevOps is configuration management, which involves defining and maintaining the infrastructure and environments that software runs on. Configuration management is a vital part of the software development process, but it can also be a complex and time-consuming task. This is where configuration management tools like Chef come in, helping organizations automate and streamline the process of managing infrastructure. Chef is a popular configuration management tool that helps organizations automate the process of configuring and maintaining infrastructure. In this blog, I've tried to explain the tool's architecture and the workflow involved in the simplest way possible.</p>
<h2 id="heading-what-is-chef">What is Chef?</h2>
<p>Chef is an open-source configuration management tool that enables users to define infrastructure as code. This means that infrastructure can be managed and version-controlled just like software, allowing organizations to easily track changes, roll back if necessary, and collaborate with team members.</p>
<p>Chef is written in Ruby and is based on a client-server model. The Chef server stores the configuration data for each node (i.e., system) in the infrastructure, and the Chef client runs on each node and communicates with the server to ensure that the node is configured according to the desired state.</p>
<h2 id="heading-chef-workflow">Chef Workflow</h2>
<p>The basic workflow of chef is instantiated below:</p>
<p><img src="https://www.linode.com/docs/guides/beginners-guide-chef/chef_graph_hu14dd7de041028599665536aad0220d76_36528_694x0_resize_q71_bgfafafc_catmullrom_3.jpg" alt="A Beginner's Guide to Chef | Linode" /></p>
<ol>
<li><p>The configuration data is written in a Chef recipe, which is a Ruby file that specifies the desired state of the system.</p>
</li>
<li><p>The recipe is then uploaded to the Chef server.</p>
</li>
<li><p>The Chef client is run on each node(this can be automated), which communicates with the server to retrieve the appropriate configuration data.</p>
</li>
<li><p>The Chef client then applies the configuration data to the node, making any necessary changes to bring the system into compliance with the desired state.</p>
<p> <img src="https://docs.chef.io/images/chef_overview_2020.svg" alt="Chef Infra Overview" /></p>
</li>
</ol>
<h2 id="heading-chef-architecture">Chef Architecture</h2>
<p><img src="https://www.simplilearn.com/ice9/free_resources_article_thumb/work-station.JPG" alt="What Is Chef: Here's What You Need to Know" /></p>
<p>The Chef architecture consists of three main components: the Chef server, the Chef client, and the nodes.</p>
<p>The Chef server is the central repository for all of the configuration data for the nodes in the infrastructure. It stores the configuration data and serves it to the Chef clients whenever requested.</p>
<p>The Chef client is installed on each node in the infrastructure and is responsible for communicating with the Chef server to retrieve the appropriate configuration data and apply it to the node.</p>
<p>The nodes are the systems that are being managed by Chef. They can be servers, virtual machines, or any other type of system that can run the Chef client. The process of attaching node to the chef server is called bootstraping. This implies that each node should be bootstraped in order to run the node updates.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>To wrap this off, Chef is a powerful tool for configuration management that allows developers to define and automate the configuration of their systems. Its client-server architecture, with the Chef server as the central repository for configuration data and the Chef client running on each node to apply the configuration, makes it easy to manage and maintain the desired state of the infrastructure. Whether you're managing a small number of servers or a large, complex infrastructure, Chef can help you automate and streamline your configuration management processes.</p>
]]></content:encoded></item><item><title><![CDATA[Flutter: BLoC vs. Cubit]]></title><description><![CDATA[In BLoC architecture or BLoC pattern, there are two terms often involved viz: bloc and cubit. The Cubit is a subset of the famous implementation of BLoC Pattern; it abandons the concept of Events and simplifies the way of emitting states.
bloc

When ...]]></description><link>https://blogs.praneshpyarashrestha.com.np/flutter-bloc-vs-cubit</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/flutter-bloc-vs-cubit</guid><category><![CDATA[Flutter]]></category><category><![CDATA[flutter bloc]]></category><category><![CDATA[Bloc Architecture in Flutter Programming]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Sat, 03 Dec 2022 07:26:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1670054178405/FgZHJSa43.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670039870979/cc6fa833-647e-46ba-bcfc-4cd918627368.png" alt="image.png" /></p>
<p>In BLoC architecture or BLoC pattern, there are two terms often involved viz: bloc and cubit. The Cubit is a subset of the famous implementation of BLoC Pattern; it abandons the concept of Events and simplifies the way of emitting states.</p>
<h2 id="heading-bloc">bloc</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670040314908/df7d922d-1c78-4163-a381-a9e075109497.png" alt="image.png" /></p>
<p>When we use BLoC, there’s two important things: “Events” and “States”. That means that when we send an “Event” we can receive one or more “States”, and these “States” are sent in a stream.</p>
<h2 id="heading-whats-a-cubit">What’s a Cubit?</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1670040564413/ce8e15c0-c0c8-46fa-b497-546a46ae4067.png" alt="image.png" /></p>
<p>When we use cubit, we can only send “states” and to trigger these states we can do it by calling a function (like actions). It’s a class that stores an observable state, the observation is powered by Streams but in such a friendly way that it is not necessary to know reactive programming.</p>
<p>Like I mentioned, Cubit is a subset of Bloc (Bloc extends Cubit) so you can think of Cubit as a simplified Bloc which has less functionality. Blocs are more powerful than Cubits but Cubits are more simple.</p>
<p>The recommended thing is to use Cubit for simpler methods and evolve to Bloc, because you don't need an excavator (Bloc) to remove a sand shovel.</p>
<h2 id="heading-track-events-and-states">Track Events and States</h2>
<p>Sometimes you want to track what “event/state” was sent, or maybe the relation between an “event” and the “state”. This helps us to make the debugging easier, understand the relation between event and state, verify the sequence of the data flow, and check transitions. For large applications sometimes could be difficult to know which “event” triggers certain “states” also report this thing could be useful for analytics.</p>
<p>One of the major difference between BLoC and Cubit is this:</p>
<blockquote>
<p><em>BLoC is event-driven and Cubit is not.</em></p>
</blockquote>
<p><strong>BLoC</strong>: Because it is event-driven we can know what event it triggered, what’s the current state and the next one. We can override “onTransition” and check how these events are coming and how these states change; another way is using a BLoC observer.</p>
<p><strong>Cubit:</strong> As we know, cubit is not event-driven. We call functions (like actions) to send these “states”, so we can track which state were emitted and not events because here there are not events. We can track state overriding the “onChange” function; another way is using a BLoC observer.</p>
<h2 id="heading-in-conclusion">In conclusion..</h2>
<p>For things like API Calls, Database Access, etc. you can use BLoC or Cubit, both works. <strong>Cubit</strong> is a subset of <strong>Bloc</strong>; so, it reduces complexity. Cubit eliminates the event classes. Cubit uses emit rather than yield to emit state. Since emit works synchronously, you can ensure that the state is updated in the next line. Cubit is perfectly suitable to any app scale and anyone saying one scales better than the other is ill-informed.</p>
<p>You have to choose between traceability with an event-driven architecture which comes with boiler plate vs more traditional code. One advantage of event driven architectures is that events can be used by 0 or many handlers, the emitter does not care. The disadvantage is the indirection and extra boiler plate.</p>
]]></content:encoded></item><item><title><![CDATA[Local Host IP Address Explained]]></title><description><![CDATA[If you are an experienced web developer, then you’ve likely seen the term “localhost” on many occasions. And even if you’re a beginner and just getting started in web development, you might have seen the number “127.0.0.1:” while using a live server ...]]></description><link>https://blogs.praneshpyarashrestha.com.np/localhost-ip-address</link><guid isPermaLink="true">https://blogs.praneshpyarashrestha.com.np/localhost-ip-address</guid><category><![CDATA[Web Development]]></category><category><![CDATA[localhost]]></category><dc:creator><![CDATA[Pranesh Pyara Shrestha]]></dc:creator><pubDate>Sat, 05 Nov 2022 14:48:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1667659541355/NVs4vOE-8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667658167290/pCJDSvYW4.png" alt="image.png" /></p>
<p>If you are an experienced web developer, then you’ve likely seen the term “localhost” on many occasions. And even if you’re a beginner and just getting started in web development, you might have seen the number “127.0.0.1:” while using a live server plugin in Visual Studio Code or in any other IDEs.</p>
<p>In this article, I will try to explain what localhost is alongside its corresponding IP address, “127.0.0.1”.</p>
<h2 id="heading-what-is-localhost">What is Localhost??</h2>
<p>In computer networking, host means a “server”. Just like you can put a website on the internet by hosting it on a server, you can make your own computer that server. This connection is called loopback. The IP address for that loopback is 127.0.0.1. If you’ve put a website on the internet before, then you’ve dealt with hosting companies like Heroku, Hostinger, Netlify, and many others. These are what I refer to as “remote hosts” or virtual servers.</p>
<p>If you’ve served a website on your computer so you can test it without connecting to the internet, what you’re dealing with is a localhost. So, by definition, localhost is the computer or hostname currently making a request to itself. In this case, the computer is also the virtual server.</p>
<h2 id="heading-what-is-the-ip-address-127001">What is the IP Address 127.0.0.1?</h2>
<p>If you want to visit a website, you type the website address to your browser’s address bar. The Domain Name Server (DNS) matches the address to a numeric IP address corresponding to that name. This is how it is done for every website you visit.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667655414515/AVA9fQg1E.png" alt="image.png" /></p>
<p>Localhost is not an exception to this. So, if you type localhost to your browser’s address bar, it transforms to the IP address 127.0.0.1. This 127.0.0.1 IP address is reserved for local servers on computers, so you will never find another IP address that starts with 127.</p>
<h2 id="heading-but-localhost-what-or-127001-what">But localhost: what? Or 127.0.0.1: what?</h2>
<p>Just like HTTP and HTTPS, the localhost is a protocol. Remember that the website domain name is what follows the http or https. So, something has to follow localhost: and 127.0.0.1:. That thing is the port number.</p>
<p>For example, in an Express app, that port number is the port variable you set. Something like this:</p>
<p><code>const port = 4000;</code> </p>
<p>So if you type localhost:4000 in the browser address bar and hit ENTER, the web application you’re currently making will be served to you:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667654945272/bLEl84WFc.png" alt="image.png" /></p>
<p>Also, if you type 127.0.0.1:4000, you will get the same response:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667655063645/T-29b71_2.png" alt="image.png" /></p>
<p>If you use with the live server extension of Visual Studio Code, it uses a port 5500 attached to 127.0.0.1, followed by the filename:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1667655190936/d39ngh70I.png" alt="image.png" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>I hope this article has helped you learned more about localhost, what its IP address is, and how it works to serve websites for local testing.</p>
<p>And yes! There’s no place like localhost. Properly put, “there’s no place like 127.0.0.1” :).</p>
<p>Keep coding and exploring new things and technologies…</p>
]]></content:encoded></item></channel></rss>