<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nihit Raj on Medium]]></title>
        <description><![CDATA[Stories by Nihit Raj on Medium]]></description>
        <link>https://medium.com/@giet12aei033?source=rss-a48fdb79f555------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*aF5ry5LNaJiSlq04</url>
            <title>Stories by Nihit Raj on Medium</title>
            <link>https://medium.com/@giet12aei033?source=rss-a48fdb79f555------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 15:53:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@giet12aei033/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introduction to Docker: Why Use It, Architecture, Differences vs VM, and Dockerfile Explained]]></title>
            <link>https://medium.com/@giet12aei033/introduction-to-docker-why-use-it-architecture-differences-vs-vm-and-dockerfile-explained-8aac5a4139f5?source=rss-a48fdb79f555------2</link>
            <guid isPermaLink="false">https://medium.com/p/8aac5a4139f5</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Nihit Raj]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 10:12:59 GMT</pubDate>
            <atom:updated>2025-09-26T10:12:59.795Z</atom:updated>
            <content:encoded><![CDATA[<p>Containers have revolutionized modern software development by making applications lightweight, portable, and easy to deploy. Docker is the most popular containerization platform that simplifies building, shipping, and running applications in isolated environments. This blog will explain why Docker is used, its architecture, how it differs from virtual machines (VMs), and dive deep into Dockerfiles along with practical interview questions.</p><h3>Why Did We Start Using Docker? What Problems Does It Solve?</h3><p>Before Docker, developers faced numerous challenges:</p><ul><li>“It works on my machine” problem: Applications behaved differently in development and production due to environment inconsistencies.</li><li>Heavy virtual machines: VMs were resource-heavy, slow to start, and not portable.</li><li>Dependency conflicts: Installing multiple versions of libraries and tools on the same system caused conflicts.</li><li>Complex deployments: Packaging and deploying apps with all dependencies was error-prone and time-consuming.</li></ul><h3>Docker solves these by:</h3><ul><li><strong>Portability:</strong> Package your app and all dependencies into a single container that runs consistently anywhere.</li><li><strong>Lightweight:</strong> Shares OS kernel, requiring fewer resources than full virtual machines.</li><li><strong>Fast startup:</strong> Containers start almost instantly compared to VM boot times.</li><li><strong>Scalability:</strong> Run many container instances easily and orchestrate with Kubernetes/Docker Swarm.</li><li><strong>Consistency:</strong> Works the same across development, testing, and production environments.</li></ul><h3>Docker Architecture</h3><p>Docker follows a client-server architecture, mainly comprising:</p><ul><li><strong>Docker Client:</strong> User interface where you run commands like docker run or docker build. Commands go to the daemon.</li><li><strong>Docker Daemon (dockerd):</strong> Background service running on your machine that builds, runs, and manages containers and images.</li><li><strong>Docker Images:</strong> Read-only templates containing your app and dependencies.</li><li><strong>Docker Containers:</strong> Running instances of Docker images, isolated from other containers and the host system.</li><li><strong>Docker Registry:</strong> Remote repository like Docker Hub where images are stored and shared.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LpA33QrmbeU6sGKs.png" /></figure><h3>Docker vs Virtual Machines (VMs)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*guZCt8ggQd0JDAJirr9r2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GSBiIOZFsiWn8JfR.png" /></figure><h3>Simple Docker Interview Questions</h3><h3>1. How to write a sample Dockerfile?</h3><p>A Dockerfile is a text file containing instructions to build a Docker image.</p><pre># Use official Python runtime as base image<br>FROM python:3.8-slim</pre><pre># Set working directory inside container<br>WORKDIR /app</pre><pre># Copy current directory contents into container at /app<br>COPY . /app</pre><pre># Install any needed packages specified in requirements.txt<br>RUN pip install --no-cache-dir -r requirements.txt</pre><pre># Make port 80 available to the outside<br>EXPOSE 80</pre><pre># Define environment variable<br>ENV NAME World</pre><pre># Run app.py when container launches<br>CMD [&quot;python&quot;, &quot;app.py&quot;]</pre><h3>2. Common Commands in Dockerfile</h3><ul><li><strong>FROM:</strong> Sets the base image to start from</li><li><strong>WORKDIR:</strong> Sets the working directory inside the container</li><li><strong>COPY:</strong> Copies files/directories from host to container</li><li><strong>ADD:</strong> Like COPY but can also extract tarballs and download URLs</li><li><strong>RUN:</strong> Executes commands during build (e.g., install packages)</li><li><strong>CMD:</strong> Default command run when container starts (can be overridden)</li><li><strong>ENTRYPOINT:</strong> Configures a container to run as an executable</li><li><strong>EXPOSE:</strong> Documents which ports the container listens on</li><li><strong>ENV:</strong> Sets environment variables inside container</li><li><strong>VOLUME:</strong> Creates mount points for persistent/shared data</li><li><strong>USER:</strong> Specifies the user to run commands or container</li><li><strong>ARG:</strong> Defines variables that can be passed during build time</li></ul><h3>3. What is ENTRYPOINT?</h3><ul><li>ENTRYPOINT sets the executable that will always run when the container starts.</li><li>Unlike CMD, which can be overridden with arguments, ENTRYPOINT is the main command and parameters can be appended.</li><li>It’s useful for containers that behave like standalone applications or scripts.</li></ul><p><strong>Example:</strong></p><pre>ENTRYPOINT [&quot;python&quot;, &quot;app.py&quot;]</pre><p>When running:</p><pre>docker run myimage --help</pre><p>The container executes python app.py --help.</p><h3>4. What is a Docker Container?</h3><p>A Docker container is a lightweight, standalone, and executable package of software that includes everything needed to run an application: code, runtime, system tools, libraries, and settings. Containers share the OS kernel but run isolated processes.</p><h3>5. How do you create a Docker container?</h3><p>You create a container by running a Docker image:</p><pre>docker run -d -p 80:80 nginx</pre><p>This command runs an Nginx container in detached mode, mapping port 80 from container to host.</p><h3>6. What is a Docker image?</h3><p>Docker images are read-only templates used to create containers.</p><h3>7. What is a Dockerfile?</h3><p>A text file with commands to build a Docker image.</p><h3>8. How do you create and run a Docker container?</h3><p>Example: docker run -d -p 80:80 nginx creates and runs an Nginx container in detached mode.</p><h3>9. What is the difference between docker run and docker start?</h3><p>docker run creates and starts a new container; docker start starts an existing stopped container.</p><h3>10. How do you stop and remove a container?</h3><p>docker stop &lt;container_id&gt; stops it, docker rm &lt;container_id&gt; removes it.</p><h3>11. How can you inspect logs of a running container?</h3><p>Use docker logs &lt;container_id&gt;.</p><h3>12. How do you list running containers?</h3><p>docker ps shows running containers.</p><h3>13. What command can you use to see all containers, including stopped ones?</h3><p>docker ps -a</p><h3>Conclusion</h3><p>Docker empowers developers to build, share, and run applications anywhere with consistency and efficiency. Understanding Docker’s architecture and how it differs from traditional virtual machines helps in making informed decisions for deployment. Mastering Dockerfile instructions and concepts like ENTRYPOINT is crucial for customizing container behavior, optimizing builds, and passing interview tests confidently.</p><p>Start experimenting with Docker today to streamline development workflows, achieve faster delivery cycles, and build scalable systems that meet modern infrastructure demands.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8aac5a4139f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Git and GitHub: Key Commands Explained with Examples]]></title>
            <link>https://medium.com/@giet12aei033/understanding-git-and-github-key-commands-explained-with-examples-ab23e32a2c1a?source=rss-a48fdb79f555------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab23e32a2c1a</guid>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Nihit Raj]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 09:50:51 GMT</pubDate>
            <atom:updated>2025-09-26T09:50:51.805Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to Git: Master Version Control with Essential Commands</h3><p>Version control is a fundamental skill for every developer, allowing you to track changes, collaborate smoothly, and maintain code quality throughout your projects. Git, the most popular version control system today, powers millions of projects worldwide with its flexibility and speed.</p><p>Whether you’re starting your coding journey or looking to sharpen your Git skills, this guide breaks down the most essential Git commands with clear explanations and practical examples. By the end of this post, you’ll confidently manage your code history, collaborate with others on GitHub, and solve common Git challenges like a pro.</p><p>Let’s dive into the world of Git and unlock your development potential!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O_Yd_Y9ZCHnN52eE.png" /></figure><h3>What is Git?</h3><p>Git is a version control system that tracks changes to files in your project, allowing multiple developers to collaborate efficiently, maintain code history, and manage different branches of development locally on your computer.</p><h3>What is GitHub?</h3><p>GitHub is a cloud-based platform that hosts Git repositories online. It provides a user interface, collaboration features like pull requests, issue tracking, and remote hosting so teams can work together on Git projects over the internet.</p><p><strong>In short:</strong></p><ul><li><strong>Git:</strong> Version control tool running locally to track changes.</li><li><strong>GitHub:</strong> Cloud platform hosting Git repositories for collaboration.</li></ul><h3>Key Git Commands Explained</h3><h3>1. git init</h3><p><strong>Purpose:</strong> Initialize a new Git repository in your current directory.</p><p><strong>What it does:</strong> Creates a hidden .git folder containing all metadata and history needed to track changes.</p><p><strong>Example:</strong>bash</p><pre>mkdir my-project<br>cd my-project<br>git init</pre><p>Output:</p><pre>Initialized empty Git repository in /path/to/my-project/.git/</pre><p><em>Explanation:</em> This converts my-project folder into a Git repository ready to track your files.</p><h3>2. git status</h3><p><strong>Purpose:</strong> View the status of your files — see which have been changed, added to staging, or are untracked.</p><p><strong>Example:</strong></p><pre>touch newfile.txt<br>git status</pre><p>Output might look like:</p><pre>Untracked files:<br>  newfile.txt</pre><h3>3. git add</h3><p><strong>Purpose:</strong> Stage changes/new files so they are included in the next commit.</p><p><strong>Example:</strong></p><pre>git add newfile.txt<br>git status</pre><p>Output:</p><pre>Changes to be committed:<br>  new file: newfile.txt</pre><p>Now newfile.txt is staged and ready to commit.</p><ol><li>Commit the file:</li></ol><pre>git commit -m &quot;Add newfile.txt&quot;<br>git stat</pre><p>Output:</p><pre>nothing to commit, working tree clean</pre><p>This means all changes are saved.<em>Explanation:</em> Moves changes from working directory to the staging area (index).</p><h3>4. git commit</h3><p><strong>Purpose:</strong> Save staged changes to the repository with a descriptive message.</p><p><strong>Example:</strong></p><pre>git commit -m &quot;Add homepage HTML structure&quot;</pre><p>Output:</p><pre>[main (root-commit) 1a2b3c4] Add homepage HTML structure<br> 1 file changed, 20 insertions(+)<br> create mode 100644 index.html</pre><h3>5. git log</h3><p><strong>Purpose:</strong> View commit history with IDs, author info, and messages.</p><p><strong>Example:</strong></p><pre>git log --oneline</pre><p>Output:</p><pre>1a2b3c4 Add homepage HTML structure</pre><h3>6. git branch</h3><p><strong>Purpose:</strong> Create, list, or delete branches — isolated development lines.</p><p><strong>Examples:</strong></p><ul><li>List branches:</li><li>bash</li><li>git branch</li><li>Create a new branch</li></ul><pre>git branch feature-xyz</pre><h3>7. git checkout</h3><p><strong>Purpose:</strong> Switch between branches or files.</p><p><strong>Example:</strong></p><pre>git checkout feature-xyz</pre><p>Switches your working directory to feature-xyz branch.</p><h3>8. git merge</h3><p><strong>Purpose:</strong> Combine changes from a branch into the current branch.</p><p><strong>Example:</strong></p><pre>git checkout main<br>git merge feature-xyz</pre><h3>9. git clone</h3><p><strong>Purpose:</strong> Download a remote Git repository locally.</p><p><strong>Example:</strong></p><pre>git clone https://github.com/user/repository.git</pre><p>Creates a local copy called repository.</p><h3>10. git push &amp; git pull</h3><ul><li><strong>Push:</strong> Upload your local commits to a remote repository.</li></ul><pre>git push origin main</pre><ul><li><strong>Pull:</strong> Fetch and merge remote changes to your local repo.</li><li>git pull origin main</li></ul><pre>git pull origin mai</pre><h3>11. Git fetch vs git pull</h3><ul><li>git fetch downloads commits, files, and refs from a remote repository without merging them into your current branch.</li><li>This updates your remote tracking branches, letting you see what others have done before you decide to integrate those changes.</li><li>It gives you control to review changes before applying them.</li></ul><p>Command:</p><pre>git fetch origin</pre><ul><li>git pull is essentially git fetch followed by git merge — it downloads changes from remote and immediately merges them into your current branch.</li><li>It’s a convenient way to keep your branch up to date but may create merge commits if changes conflict.</li></ul><p>Command:</p><pre>git pull origin main</pre><h3>Key Difference:</h3><p>Featuregit fetchgit pullDownloads remote changesYesYesMerges changes immediatelyNoYesControl over mergeYes, manual merge needed afterwardNo, merge happens automaticallyUse caseReview remote changes before mergingQuickly update and merge latest changes</p><h3>12. Git cherry-pick</h3><ul><li>git cherry-pick applies a specific commit from another branch or history onto your current branch.</li><li>It allows you to selectively bring in changes without merging entire branches.</li></ul><p>Example:</p><p>You want to apply commit a1b2c3d from a feature branch into your main branch:</p><pre>git checkout main<br>git cherry-pick a1b2c3d</pre><p><em>Explanation:</em> This copies just the single commit identified by a1b2c3d onto your current branch without merging all other commits from that branch.</p><h3>13. git rebase</h3><ul><li>git rebase moves or reapplies a series of commits from one branch to another, creating a cleaner, linear history.</li><li>Instead of merging and creating a merge commit, it rewrites commit history by applying commits one-by-one.</li></ul><p>Example:</p><p>You want to rebase your feature branch on top of main branch to include the latest changes:</p><pre>git checkout feature<br>git rebase main</pre><p><em>Explanation:</em></p><ul><li>Rebasing replays your feature branch commits on top of main, making it look like you built your work on the most recent version of main.</li><li>It helps avoid messy merge commits and keeps history linear, which is easier to understand.</li></ul><h3>Conclusion</h3><p>Git is an essential tool that revolutionizes how developers work by providing robust version control capabilities. It enables efficient collaboration, maintains a detailed history of all changes, supports experimentation through branching, and offers the safety net of easy rollbacks. By mastering Git and understanding its core commands, you’ll not only keep your code organized and secure but also streamline teamwork and accelerate development.</p><p>Whether you’re an individual developer or part of a large team, Git’s distributed architecture and powerful features make it indispensable in modern software development. Start practicing the commands covered in this guide, and watch how your productivity and collaboration improve dramatically.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab23e32a2c1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering AWS Scenario-Based Interview Questions (Detailed Guide with Examples)]]></title>
            <link>https://medium.com/@giet12aei033/mastering-aws-scenario-based-interview-questions-detailed-guide-with-examples-a1447c452c16?source=rss-a48fdb79f555------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1447c452c16</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Nihit Raj]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 09:04:52 GMT</pubDate>
            <atom:updated>2025-09-26T09:04:52.797Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When you walk into an AWS interview, you won’t just be asked “What is S3?” or “What is an EC2?” Instead, you’ll get <strong>scenario-based questions</strong> that test your <strong>design thinking, cost awareness, and troubleshooting skills</strong>.</p><p>Let’s go step by step through real AWS scenarios you may face, and explore <strong>detailed answers with examples</strong>.</p><h3>🔹 Scenario 1: Your EC2 instance in a private subnet needs to download packages without NAT Gateway. What alternatives exist?</h3><p><strong>Problem:</strong><br> NAT Gateway costs <strong>$32/month + data charges</strong>, which is expensive if all you need is package downloads.</p><p><strong>Alternatives:</strong></p><ol><li><strong>VPC Endpoints</strong></li></ol><ul><li>For services like S3/ECR, create a <strong>Gateway VPC Endpoint</strong>.</li><li>This gives <strong>private connectivity</strong> → no NAT needed.</li><li>Example: Your EC2 pulls Docker images from <strong>ECR</strong> via private VPC Endpoint.</li></ul><p><strong>2. Systems Manager Session Manager</strong></p><ul><li>The <strong>SSM Agent</strong> (running on the instance) opens an outbound TLS connection to the Systems Manager service.</li><li>When you start a session (Console or CLI), the SSM control plane relays input/output through that already-established outbound connection — there is <strong>no inbound network traffic to the instance</strong>.</li><li>The session data can be optionally logged to <strong>CloudWatch Logs</strong> or <strong>S3</strong>, and all operations are recorded in <strong>CloudTrail</strong>.</li></ul><blockquote>User(Console/CLI)<br> |<br> | HTTPS (to AWS SSM API)<br> <br>AWS Systems Manager control plane<br> |<br> (relay over existing channel)<br> |<br>SSM Agent ← — -&gt; Interface endpoint or Internet ← — -&gt; Systems Manager<br> |<br> EC2 instance (private subnet, no SSH inbound)</blockquote><p><strong>3. Proxy Server</strong></p><ul><li>Deploy a Squid proxy in a public subnet.</li><li>Private EC2 routes traffic to proxy → proxy uses IGW.</li></ul><p>👉 <strong>Best Practice:</strong> If only AWS services are needed (S3, ECR), always use <strong>VPC Endpoints</strong> (cheaper + secure).</p><h3>🔹 Scenario 2: How would you set up geolocation-based routing using AWS services?</h3><p><strong>Service:</strong> <strong>Route 53 Geolocation Routing</strong></p><ul><li>Allows routing based on <strong>user’s location</strong>.</li><li>Example:</li><li>US users → <strong>us-east-1 ALB</strong></li><li>EU users → <strong>eu-west-1 ALB</strong></li><li>Default → <strong>ap-south-1 ALB</strong></li></ul><p><strong>Steps:</strong></p><ol><li>Create <strong>A/AAAA records</strong> in Route 53 with Geolocation rules.</li><li>Associate each with the right ALB.</li><li>Add <strong>health checks</strong> for failover.</li></ol><p>👉 Use cases:</p><ul><li>Compliance (data residency rules).</li><li>Performance (users connect to closest region).</li></ul><h3>🔹 Scenario 3: What are the pre-requisites for VPC peering between two VPCs?</h3><ul><li><strong>CIDR blocks must not overlap.</strong></li><li>Both VPCs must be in the <strong>same AWS account or have cross-account permissions</strong>.</li><li>Update <strong>route tables</strong> in both VPCs.</li><li>Security Groups must allow traffic.</li></ul><p>👉 Example:</p><ul><li>VPC A: 10.0.0.0/16</li><li>VPC B: 172.31.0.0/16</li><li>Peering works fine.</li></ul><h3>🔹 Scenario 4: What problems occur when two VPCs have overlapping CIDR blocks?</h3><h4><strong>AWS PrivateLink:</strong></h4><p>AWS PrivateLink lets you <strong>expose a service (like an app, DB, or API) privately</strong> inside AWS without requiring <strong>routing between VPCs</strong>.<br> Instead of connecting via VPC Peering or Transit Gateway, the consumer VPC accesses the service via an <strong>interface endpoint (ENI)</strong> inside its subnet.</p><p>🔹 <strong>Use case</strong>:</p><ul><li>Two VPCs have <strong>overlapping CIDRs</strong> (e.g., 10.0.0.0/16 in both VPCs).</li><li>You want to connect an application in one VPC to a service in another, but routing conflicts prevent peering.</li></ul><p>🔹 <strong>How it works (Example)</strong>:</p><ul><li><strong>Provider VPC</strong> hosts a service on an NLB (Network Load Balancer).</li><li><strong>Consumer VPC</strong> creates a VPC Endpoint (Interface Endpoint) pointing to that NLB.</li><li>The consumer now connects using the <strong>endpoint’s private DNS name</strong> (e.g., service.company.aws).</li></ul><p>👉 Example:</p><ul><li>You run an <strong>internal order API</strong> in VPC-A.</li><li>VPC-B (overlapping CIDR) wants to consume the API.</li><li>Expose the API via <strong>PrivateLink</strong> in VPC-A.</li><li>VPC-B accesses it via <strong>endpoint</strong> without routing conflicts.</li></ul><h4>Proxy / Jump Host:</h4><p>A <strong>proxy/jump host</strong> is an EC2 instance that has <strong>two network interfaces (ENIs)</strong> in different networks (like VPC-A and VPC-B). It acts as a middleman to forward traffic.</p><p>🔹 <strong>Use case</strong>:</p><ul><li>You need quick access to overlapping networks without complex setups.</li><li>Common for <strong>SSH/RDP access</strong> or <strong>small-scale service communication</strong>.</li></ul><p>🔹 <strong>How it works (Example)</strong>:</p><ul><li>VPC-A and VPC-B both have <strong>overlapping CIDRs</strong> (e.g., 10.0.0.0/16).</li><li>You create an EC2 instance with <strong>dual ENIs</strong>: one in VPC-A, one in VPC-B.</li><li>Configure it as a <strong>bastion/proxy server</strong>.</li><li>Users/Apps connect to the jump host first, then the host routes traffic to the other VPC.</li></ul><p>👉 Example:</p><ul><li>You need to run <strong>DB queries</strong> on RDS in VPC-B but your app in VPC-A can’t connect directly due to overlapping CIDRs.</li><li>Spin up a jump host with ENIs in both VPCs.</li><li>App connects to the jump host → jump host forwards traffic to DB.</li></ul><h4>3. NAT inside Transit Gateway (TGW NAT)</h4><p>Transit Gateway (TGW) by default doesn’t support overlapping CIDRs. But you can add <strong>NAT capability inside TGW</strong> to <strong>remap IPs</strong> between VPCs.</p><p>🔹 <strong>Use case</strong>:</p><ul><li>You have multiple VPCs with <strong>overlapping CIDRs</strong>.</li><li>Still want to route traffic between them <strong>at scale</strong>.</li></ul><p>🔹 <strong>How it works (Example)</strong>:</p><ul><li>VPC-A (10.0.0.0/16) and VPC-B (10.0.0.0/16) both overlap.</li><li>You attach both to TGW.</li><li>Configure TGW NAT so that:</li><li>VPC-A’s traffic is <strong>translated</strong> (e.g., to 100.64.0.0/16) before sending to VPC-B.</li><li>Reverse NAT applies when responses return.</li></ul><p>👉 Example:</p><ul><li>App servers in VPC-A need to call an API in VPC-B.</li><li>Without NAT, routing breaks due to CIDR overlap.</li><li>TGW NAT remaps VPC-A traffic into a new non-overlapping range, enabling communication.</li></ul><p>✅ <strong>Summary Table</strong></p><p>Solution When to Use How it Works Example <strong>PrivateLink</strong> Service-to-service private access without routing Consumer VPC uses ENI endpoint to connect Expose Order API in VPC-A to VPC-B <strong>Proxy / Jump Host</strong> Small scale, quick fix, manual access EC2 with dual ENIs forwards traffic SSH/DB access across overlapping VPCs <strong>TGW NAT</strong> Large-scale VPC connectivity with overlapping CIDRs NAT in TGW remaps IP ranges App in VPC-A talks to API in VPC-B despite overlap</p><p>👉 My recommendation:</p><ul><li>Use <strong>PrivateLink</strong> for service exposure (most secure &amp; scalable).</li><li>Use <strong>Jump Host</strong> for admin/debug access.</li><li>Use <strong>TGW NAT</strong> for enterprise-scale overlapping VPC connectivity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-sb7iNEa5--upOMSmtpZQ.png" /></figure><h3>🔹 Scenario 5: Explain differences between AWS ECS, EKS, and Fargate — when would you choose each?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Wsx1mJCDNecPZel9cOZs6A.png" /></figure><h3>🔹 Scenario 6: Explain VPC Peering vs Transit Gateway — when to use which at scale?</h3><h4>VPC Peering</h4><p><strong>Definition:</strong> A direct connection between <strong>two VPCs</strong> using private IPs</p><ul><li><strong>Use Case:</strong> Small setups where only 2–3 VPCs need to communicate.</li></ul><p><strong>Limitations:</strong></p><ul><li><strong>Non-transitive</strong> → if A peers with B, and B peers with C, A cannot talk to C.</li><li>Becomes <strong>hard to manage</strong> when you have many VPCs (N×(N-1)/2 peering connections).</li></ul><p><strong>Example:</strong></p><ul><li><strong>Dev VPC (10.0.0.0/16)</strong> needs to access <strong>DB VPC (172.31.0.0/16)</strong>.</li><li>Simple peering works.</li><li>Route tables updated on both sides.</li></ul><h4>Transit Gateway (TGW)</h4><p><strong>Definition:</strong> A central hub that connects <strong>multiple VPCs and on-premises networks</strong>.</p><ul><li><strong>Use Case:</strong> Medium to large-scale setups with <strong>3+ VPCs</strong> or hybrid cloud.</li></ul><p><strong>Advantages:</strong></p><ul><li><strong>Transitive routing</strong> → VPC A ↔ VPC B ↔ VPC C all work automatically through TGW.</li><li>Simplifies management (hub-and-spoke).</li><li>Can connect VPN, Direct Connect, and VPCs together.</li></ul><p><strong>Example:</strong></p><ul><li>An <strong>enterprise with 10 VPCs</strong> (Dev, QA, Prod, Analytics, Shared Services, etc.).</li><li>Instead of managing <strong>45+ peering connections</strong>, you attach all to <strong>1 TGW</strong>.</li></ul><h3>Simple Decision Rule</h3><p><strong>Use VPC Peering →</strong></p><ul><li>Only 2–3 VPCs.</li><li>No need for transitive routing.</li><li>Cost-sensitive and simple setup.</li></ul><p><strong>Use Transit Gateway →</strong></p><ul><li>More than 3 VPCs.</li><li>Need <strong>centralized routing</strong> or on-prem connectivity.</li><li>Expect <strong>growth</strong> in number of VPCs.</li></ul><p>⚡ Example:</p><ul><li><strong>Startup</strong> with only App VPC ↔ DB VPC: <strong>VPC Peering</strong>.</li><li><strong>Enterprise</strong> with 12 VPCs + on-prem network: <strong>Transit Gateway</strong>.</li></ul><h3>🔹 Scenario 7: How do you secure S3 buckets and enforce compliance?</h3><ul><li>Enable <strong>Block Public Access</strong>.</li><li>Use <strong>IAM + Bucket Policies</strong> (least privilege).</li><li>Encrypt with <strong>SSE-KMS</strong>.</li><li>Use <strong>MFA Delete</strong> for critical data.</li><li>Enforce compliance with <strong>AWS Config + System Control Policies</strong></li></ul><p>👉 Example: Ensure all S3 buckets have <strong>default encryption</strong> enabled using Config Rule.</p><h3>🔹 Scenario 8: How does Auto Scaling work in AWS, and when should you use it?</h3><ul><li>Automatically increases or decreases cloud resources based on real-time demand.</li><li>Predicts future traffic spikes and provisions resources in advance using machine learning.</li><li>Manages scaling for multiple AWS services from a unified interface.</li><li>Uses smart scaling policies with integrated monitoring for seamless resource adjustment.</li><li>Maintains performance and availability while optimizing costs by only using needed resources.</li><li>Use Auto Scaling when your application experiences regular traffic spikes, such as during product launches or seasonal events, to ensure seamless performance and cost optimization</li></ul><h3>🔹 Scenario 9: Reserved Instances vs Savings Plans</h3><ul><li><strong>Reserved Instances (RIs)</strong> = commit to a specific instance type, region, and term → get big discounts.<br> <em>Example:</em> Buying a <strong>3-year Standard RI for </strong><strong>m5.large in us-east-1</strong> saves up to ~72% if you run it 24×7.</li><li><strong>Savings Plans (SPs)</strong> = commit to $/hour of compute usage → discounts apply automatically across eligible compute types.<br> <em>Example:</em> A <strong>Compute Savings Plan of $5/hour</strong> discounts any EC2, Fargate, or Lambda usage up to that amount.</li><li><strong>Flexibility</strong>: RIs are fixed to instance family/region (Convertible RIs allow exchanges); SPs are more flexible, especially Compute SPs.<br> <em>Example:</em> Switching from m5.large to c6g.large uses your Compute SP without extra purchases, but an RI might not.</li><li><strong>Capacity reservation</strong>: RIs (zonal) can reserve capacity for reliability; SPs do not.<br> <em>Example:</em> A zonal RI for r5.large in us-east-1a ensures your production DB always has capacity.</li><li><strong>Best choice</strong>: RIs for predictable workloads needing capacity; SPs for varied workloads or serverless.<br> <em>Example:</em> Use <strong>RIs</strong> for steady database servers, <strong>Compute SPs</strong> for mixed EC2/Fargate/Lambda workloads.</li></ul><h3>🔹 Scenario 10: How would you reduce AWS data transfer (egress) costs across regions and to the internet?</h3><ul><li>Here is a 6-step checklist to cut cross-region AWS data transfer (egress) costs:</li></ul><ol><li>Audit Traffic Patterns: Identify and analyze cross-region data transfer flows using AWS Cost Explorer and VPC Flow Logs.</li><li>Consolidate Resources: Where possible, colocate resources in the same region or Availability Zone to eliminate cross-region transfers.</li><li>Implement Caching: Use Amazon CloudFront CDN to cache content regionally and reduce direct cross-region data fetches.</li><li>Use VPC Endpoints/PrivateLink: Leverage VPC endpoints and AWS PrivateLink for private, cost-free regional service access instead of public internet paths.</li><li>Optimize Region Choices: Select AWS regions with favorable egress pricing and consider regional proximity to your user base to reduce latency and cost.</li><li>Leverage AWS Direct Connect: For hybrid setups, use Direct Connect to route traffic via private lines rather than over the internet.</li></ol><h3>🔹 Scenario 11: What’s your approach to cost optimization in AWS without sacrificing performance</h3><ol><li>Right-size resources to match actual needs.</li><li>Use Auto Scaling to adjust capacity dynamically.</li><li>Leverage Spot and Reserved Instances for cost savings.</li><li>Optimize storage classes and clean unused storage.</li><li>Adopt managed services and caching for efficiency.</li><li>Continuously monitor costs and automate optimizations.</li></ol><h3>🔹 Scenario 12: How do you secure sensitive data in transit and at rest in AWS?</h3><ul><li>Encrypt data in transit using TLS and secure private connections like VPN or PrivateLink.</li><li>Encrypt data at rest with AWS KMS-managed keys on services like S3, EBS, and RDS.</li><li>Apply strict access control with least privilege IAM policies and multi-factor authentication.</li><li>Use AWS KMS for centralized key management, rotation, and auditing.</li><li>Continuously monitor access and encryption status with CloudTrail and AWS Config.</li></ul><h3>🔹 Scenario 13: Say you’re seeing unexpected spikes in EC2 costs. How do you investigate and resolve the issue?</h3><ul><li>Check detailed billing and cost reports in AWS Cost Explorer to identify which EC2 instances or services are driving costs.</li><li>Review CloudWatch metrics for spikes in CPU, network, or instance usage that correlate with cost increases.</li><li>Inspect running EC2 instances for idle, underutilized, or oversized instances.</li><li>Look for sudden changes in workload, traffic, or deployment of new applications or services.</li><li>Verify Auto Scaling policies and schedules to ensure instances are scaling appropriately.</li><li>Use AWS Trusted Advisor to identify cost optimization opportunities and unused resources.</li><li>Take corrective actions like right-sizing, stopping unused instances, adjusting scaling policies, or switching to more cost-effective instance types.</li></ul><h3>🔹 Scenario 14: Your organization uses multiple AWS accounts for different teams. How do you manage permissions, billing, and compliance across them efficiently?</h3><p>To efficiently manage permissions, billing, and compliance across multiple AWS accounts for different teams:</p><ul><li>Use AWS Organizations to centrally manage and consolidate billing, apply policies, and group accounts logically.</li><li>Implement Service Control Policies (SCPs) in AWS Organizations to enforce permission guardrails across accounts.</li><li>Use AWS Identity and Access Management (IAM) roles with cross-account access for secure, controlled permissions delegation.</li><li>Enable consolidated billing to aggregate costs, monitor usage through Cost Explorer, and allocate expenses by account or team.</li><li>Automate compliance checks and enforce standards using AWS Config and AWS Security Hub across all accounts.</li><li>Centralize logging and monitoring with AWS CloudTrail and Amazon CloudWatch Logs aggregated to a central account.</li></ul><h3>🔹 Scenario 15: What are some common challenges engineers face when working with AWS, and how would you mitigate them?</h3><ul><li>Complexity managing resources — use Infrastructure as Code (Terraform/CloudFormation).</li><li>Cost overruns — implement tagging, monitoring, and budgeting tools.</li><li>Security misconfigurations — enforce IAM best practices and automated compliance checks.</li><li>Scaling issues — use Auto Scaling and load balancing.</li><li>Troubleshooting distributed systems — centralize logging and monitoring with CloudWatch and X-Ray.</li></ul><h3>🔹 Scenario 16: Suppose you have an AWS application that requires 24x7 availability and can be down for a maximum of 15 minutes?</h3><ul><li>Design for High Availability using multi-AZ deployments and load balancers.</li><li>Use Auto Scaling to handle traffic spikes and failover.</li><li>Implement robust monitoring and alerting for quick incident response.</li></ul><h3>🔹 Scenario 17: How can you ensure backing up your Elastic Block Store (EBS) volume database?</h3><ul><li>Use automated EBS snapshots scheduled frequently (e.g., every 15 minutes).</li><li>Store snapshots in S3 with lifecycle policies.</li><li>Consider using AWS Backup service for centralized management and compliance.</li><li>Test snapshot restore procedures regularly to ensure backup integrity.</li></ul><h3>🔹 Scenario 18: <em>What are different ways we can connet 2 vpc in different aws account</em>?</h3><p>Connecting two VPCs in different AWS accounts can be achieved in multiple ways depending on your requirements such as latency, cost, and security. Here are the main options:</p><h4>1. VPC Peering</h4><ul><li>Pros: Low latency, easy to set up, no additional cost beyond data transfer fees.</li><li>Cons: Does not support transitive routing (i.e., if VPC A is peered with VPC B and B with C, A can’t communicate with C).</li></ul><p>Setup:</p><ul><li>Create a VPC Peering Connection in Account A.</li><li>Accept the request in Account B.</li><li>Update route tables in both VPCs.</li><li>Ensure security groups and NACLs allow traffic.</li></ul><h4>2. AWS Transit Gateway (TGW)</h4><ul><li>Pros: Supports transitive routing, scalable for multiple VPCs across accounts.</li><li>Cons: Higher cost than VPC Peering, requires configuration of Transit Gateway Attachments.</li></ul><p>Setup:</p><ul><li>Create a Transit Gateway in one account.</li><li>Share it with another account using AWS Resource Access Manager (RAM).</li><li>Attach VPCs to the Transit Gateway in both accounts.</li><li>Update route tables to route traffic via TGW.</li></ul><h4>3. VPN (Site-to-Site VPN)</h4><ul><li>Pros: Works over the internet, encrypted communication.</li><li>Cons: Higher latency than direct connections, relies on public internet.</li></ul><p>Setup:</p><ul><li>Create a Virtual Private Gateway (VGW) in one VPC.</li><li>Create a Customer Gateway in the other VPC using its public IP.</li><li>Establish a VPN connection between them.</li><li>Configure BGP or static routes for communication.</li></ul><h4>4. AWS PrivateLink (VPC Endpoint Services)</h4><ul><li>Pros: Secure, private communication over AWS backbone, no route table updates needed.</li><li>Cons: Only supports specific services (e.g., private API, NLB-based applications).</li></ul><p>Setup:</p><ul><li>Expose a service via Network Load Balancer (NLB) in one VPC.</li><li>Create a VPC Endpoint Service in the same VPC.</li><li>Allow the other AWS account to connect to this service.</li><li>The other account sets up an Interface VPC Endpoint.</li></ul><h4>5. Direct Connect (DX) + AWS Transit Gateway</h4><ul><li>Pros: Low latency, high-speed, dedicated link between AWS accounts.</li><li>Cons: Expensive, requires physical DX connection.</li></ul><p>Setup:</p><ul><li>Establish a Direct Connect connection.</li><li>Use AWS Transit Gateway to link VPCs in both accounts.</li><li>Configure routes accordingly.</li></ul><h3>🔹 Scenario 19: <em>Your production application running on an Amazon EC2 instance has stopped working because the root volume has run out of disk space. How do you resolve the issue without causing downtime?</em></h3><ol><li>Verify the Issue:</li></ol><ul><li>SSH into instance, check disk usage df -h.</li><li>Find large files with sudo du -sh /* | sort -hr | head -10.</li></ul><p>2. Free Up Space Temporarily:</p><ul><li>Clear logs: sudo rm -rf /var/log/*.log.</li><li>Remove unnecessary packages: sudo apt-get autoremove.</li></ul><p>3. Expand EBS Volume:</p><ul><li>Identify volume: aws ec2 describe-volumes --filters Name=attachment.instance-id,Values=&lt;instance-id&gt;.</li><li>Modify volume size: aws ec2 modify-volume --volume-id &lt;volume-id&gt; --size &lt;new-size&gt;.</li><li>Resize filesystem: sudo growpart /dev/xvda 1 and sudo resize2fs /dev/xvda1.</li></ul><p>4. Prevention:</p><ul><li>Set CloudWatch Alarms for disk usage.</li><li>Use Auto Scaling for instance upgrades.</li><li>Consider Amazon EFS or S3 for scalable storage.</li></ul><h3>🔹 Scenario 20: <em>Your application running in a private subnet of a VPC cannot reach the internet, even though it has a NAT Gateway configured. How would you troubleshoot and fix this issue?</em>?</h3><ol><li>Verify NAT Gateway Status: Active, in public subnet, elastic IP attached.</li><li>Check Route Tables: Private subnet’s default route points to NAT Gateway. Public subnet routes to Internet Gateway.</li><li>Security Groups and NACLs: Allow outbound traffic and return traffic for NAT Gateway.</li><li>Validate Routing on Private Instances: Use ip route show and traceroute.</li><li>Service Limits &amp; Outages: Confirm NAT Gateway bandwidth and AWS service health.</li><li>Inspect VPC Flow Logs: Check traffic flow to NAT Gateway.</li><li>Temporary Elastic IP Test: Assign to debug internet access.</li></ol><h3>🔹 Scenario 21: <em>You suspect that an attacker has escalated privileges using an IAM role in your AWS account. What steps would you take to identify, mitigate, and prevent this from happening again</em>?</h3><ol><li>Generate IAM credential report and review recent changes.</li><li>Check CloudTrail for suspicious API calls like AssumeRole, CreateRole, AttachRolePolicy.</li><li>Revoke compromised IAM permissions and sessions immediately.</li><li>Strengthen IAM with least privilege, MFA, and key rotation.</li><li>Monitor with GuardDuty, Config rules, and CloudWatch alarms.</li><li>Prevent with AWS Organizations SCPs, IAM Identity Center, and regular audits.</li></ol><h3>🔹 Scenario 22: <em>Your AWS EC2 instances are randomly getting terminated. What steps would youtake to find the root cause?</em></h3><ul><li>Check AWS Auto Scaling events for any automatic termination or replacement:<br>aws autoscaling describe-scaling-activities</li><li>Verify if Spot Instances were interrupted:<br>aws ec2 describe-spot-instance-requests</li><li>Review EC2 instance termination logs on the instance:<br>cat /var/log/cloud-init.log</li><li>Check if an idle instance termination policy (like instance refresh or lifecycle hooks) is enabled.</li><li>Examine AWS CloudTrail logs for any API calls related to instance termination or deletion.</li><li>Verify if any AWS Budgets actions or scheduled events are triggering instance termination.</li></ul><h3>🔹 Scenario 23: What is Fastest Way to Delete an S3 Bucket with 1TB and Millions of Objects</h3><ul><li>Use Amazon S3 Batch Operations to perform mass deletions efficiently especially at scale.</li><li>Alternatively, use the AWS CLI with --force and --recursive flags for smaller scale but with caution:<br>aws s3 rb s3://bucket-name --force</li><li>Enable Lifecycle policies to automatically expire objects progressively before deletion.</li></ul><h3>🔹 Scenario 24: What is secure and Fast Data Transfer Between S3 Buckets in Different AWS Accounts?</h3><ul><li>Cross-Account IAM Roles and Bucket Policies: Grant read access to the source bucket by creating an IAM role in the destination account and updating bucket policies accordingly.</li><li>S3 Cross-Region Replication (if applicable): Configure replication rules to copy objects securely and automatically from one bucket to another across accounts and regions.</li><li>AWS DataSync: Use DataSync to efficiently and securely transfer large amounts of data between buckets across accounts with encryption in transit.</li></ul><h4>Using S3 Batch Operations for Cross-Account Data Transfer:</h4><ul><li>You can create a batch job to copy objects from the source bucket to the destination bucket, even if they are in different AWS accounts, by specifying appropriate permissions.</li><li>The source bucket must grant read permissions to the AWS Batch Operations service on objects to be copied.</li><li>The destination bucket must allow the account running the batch job to write objects via bucket policies and IAM roles.</li><li>Batch Operations handle large-scale transfers asynchronously, with built-in retries and progress tracking, making it suitable for millions of objects.</li><li>Encryption in transit and at rest applies as usual, maintaining security compliance.</li></ul><h3>Conclusion</h3><p>Scenario-based questions are where interviews are won or lost. Instead of memorizing AWS service definitions, practice <strong>explaining trade-offs</strong> with <strong>cost, security, and scalability</strong> in mind.</p><p>👉 Tip: Try building <strong>mini prototypes</strong> in your AWS free tier. When you’ve solved these problems yourself, interviews become much easier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1447c452c16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tough Terraform Scenario Questions (with Simple Answers for Interviews)]]></title>
            <link>https://medium.com/@giet12aei033/tough-terraform-scenario-questions-with-simple-answers-for-interviews-ce0d1779a07b?source=rss-a48fdb79f555------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce0d1779a07b</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Nihit Raj]]></dc:creator>
            <pubDate>Thu, 25 Sep 2025 05:37:23 GMT</pubDate>
            <atom:updated>2025-09-25T07:43:58.029Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tough Terraform Scenario Questions (with Simple Answers for Interviews)</h3><p>Terraform is one of the most powerful tools for managing cloud infrastructure as code.<br> But in interviews, recruiters don’t just ask syntax questions — they want to know if you can <strong>solve real-world problems</strong>.</p><p>In this blog, I’ll walk through <strong>scenario-based Terraform questions and answers</strong> that I’ve faced (and asked) in interviews.</p><h3>1. ️Splitting a Large State File</h3><p><strong>Q:</strong> <em>You inherit a huge Terraform state (VPC, EKS, RDS, apps). How do you split it into smaller states safely?</em></p><ul><li>Take backup with terraform state pull.</li><li>Group resources logically (network, cluster, apps).</li><li>Use terraform state mv to move resources between new states.</li><li>Use terraform_remote_state for dependencies.</li></ul><pre>terraform state mv &#39;module.old.aws_vpc.main&#39; &#39;module.network.aws_vpc.main&#39;</pre><h3>2. Handling Race Conditions in State</h3><p><strong>Q:</strong> <em>Two pipelines run </em><em>terraform apply on the same state. How do you fix?</em></p><ul><li>Use <strong>S3 + DynamoDB</strong> backend for state and locking.</li><li>DynamoDB prevents two applies at the same time.</li><li>If a lock is stuck → check DynamoDB and manually delete it.</li></ul><h3>3. Enforcing Tags Across Modules</h3><p><strong>Q:</strong> <em>How do you make sure all resources have mandatory tags?</em></p><ul><li>Define a common_tags variable.</li><li>Merge inside modules so no one skips them.</li></ul><pre>variable &quot;common_tags&quot; {<br>  type = map(string)<br>}</pre><pre>resource &quot;aws_s3_bucket&quot; &quot;example&quot; {<br>  bucket = &quot;example&quot;<br>  tags   = merge(var.common_tags, { Name = &quot;example&quot; })<br>}</pre><h3>4. Managing Secrets in Terraform</h3><p><strong>Q:</strong> <em>How do you handle DB passwords securely?</em></p><ul><li>Store secrets in AWS Secrets Manager or SSM Parameter Store.</li><li>Reference using data sources.</li><li>Mark outputs as sensitive = true.</li></ul><pre>data &quot;aws_ssm_parameter&quot; &quot;db_password&quot; {<br>  name = &quot;/prod/db/password&quot;<br>  with_decryption = true<br>}</pre><h3>5. Dealing with prevent_destroy</h3><p><strong>Q:</strong> <em>A resource has </em><em>prevent_destroy, but you must replace it. How?</em></p><ul><li>Either remove prevent_destroy temporarily.</li><li>Or create a <strong>blue/green</strong> resource, switch traffic, and then destroy old one.</li></ul><h3>6. Avoiding Unnecessary Replacements</h3><p><strong>Q:</strong> <em>Plan shows resource will be replaced due to computed attribute. What do you do?</em></p><ul><li>Compare Terraform plan vs AWS CLI.</li><li>Use ignore_changes for noisy attributes.</li><li>Pin provider version if it’s a bug.</li></ul><h3>7. Handling Drift</h3><p><strong>Q:</strong> <em>Resources were changed manually in AWS. How do you fix?</em></p><ul><li>Run terraform plan regularly to detect drift.</li><li>Apply to bring infra back to desired state.</li><li>If manual change must stay → terraform import.</li></ul><h3>8. Cross-Account Resources</h3><ul><li>Use provider alias + assume_role.</li></ul><pre>provider &quot;aws&quot; {<br>  alias  = &quot;shared&quot;<br>  region = &quot;us-east-1&quot;<br>  assume_role {<br>    role_arn = var.shared_role_arn<br>  }<br>}</pre><h3>9. Preventing Accidental Destroy</h3><p><strong>Q:</strong> <em>How do you stop </em><em>terraform destroy in prod?</em></p><ul><li>Use prevent_destroy lifecycle.</li><li>Add CI checks blocking destroy in prod.</li><li>Require manual approvals.</li></ul><h3>11. Safe Upgrades</h3><p><strong>Q:</strong> <em>How do you upgrade Terraform version across projects?</em></p><ul><li>Pin versions in required_version.</li><li>Test in dev → staging → prod.</li><li>Use canary rollout.</li></ul><h3>12. Sharing Modules</h3><p><strong>Q:</strong> <em>How do you share modules with other teams?</em></p><ul><li>Host in Git repo.</li><li>Version with tags (v1.0.0).</li><li>Document usage with examples.</li></ul><h3>13. Renaming a Resource</h3><p><strong>Q:</strong> <em>How do you rename a resource without recreating?</em></p><ul><li>Update code.</li><li>Use terraform state mv old new.</li></ul><pre>terraform state mv aws_instance.old aws_instance.new</pre><h3>14. When to Use count vs for_each?</h3><ul><li><strong>count</strong> → Best for identical resources, indexed numerically.</li><li><strong>for_each</strong> → Best for non-identical resources, keyed by a map or set.</li></ul><p>👉 Example: Creating AWS instances dynamically.</p><pre># Using for_each to create instances from a map<br>resource &quot;aws_instance&quot; &quot;example&quot; {<br>  for_each = var.instances<br>  ami      = each.value.ami<br>  instance_type = each.value.type<br>}</pre><p>This way, you can reference each instance by its key, instead of relying only on numeric indexing.</p><h3>15. Preventing Accidental Destruction of Critical Infrastructure</h3><p>You don’t want to wake up to find a production database gone just because of a bad apply.</p><p>✔️ Solutions:</p><ul><li>Add lifecycle rule:</li></ul><pre>resource &quot;aws_db_instance&quot; &quot;prod&quot; {<br>  # ...<br>  lifecycle {<br>    prevent_destroy = true<br>  }<br>}</pre><ul><li>Always run terraform plan before apply.</li><li>Use <strong>multi-step approvals</strong> in CI/CD pipelines.</li><li>Maintain <strong>backups</strong> for critical infra (databases, S3, etc.).</li></ul><h3>16. Scenario: You Deleted an Essential Database</h3><p>If it happens (yes, we’ve all been there), here’s how to handle it:</p><ul><li>Use prevent_destroy lifecycle rules to avoid accidental deletion.</li><li>Implement code reviews and approval gates before production applies.</li><li>Validate plans before applying</li><li>Always keep backups and snapshots.</li></ul><p>💡 Pro tip: Use terraform import to bring an accidentally deleted resource back under Terraform management.</p><pre>terraform import aws_db_instance.prod my-db-id</pre><h3>17. Restricting AWS Instance Types per Environment</h3><p>You don’t want expensive instances in staging by mistake.</p><p>✔️ Solutions:</p><ul><li>Use input variables with validation.</li><li>Separate workspaces (dev, staging, prod).</li><li>Add conditionals.</li></ul><pre>variable &quot;instance_type&quot; {<br>  type    = string<br>  default = &quot;t3.micro&quot;</pre><pre>  validation {<br>    condition     = var.environment == &quot;prod&quot; ? var.instance_type == &quot;m5.large&quot; : true<br>    error_message = &quot;Production must use m5.large only.&quot;<br>  }<br>}</pre><h3>18. Why is Terraform Re-Creating All Resources for a Small Change?</h3><p>If your terraform plan shows everything being destroyed and recreated, it’s usually because of:</p><ul><li>Changing count to for_each (resource addresses change).</li><li>Lifecycle arguments (create_before_destroy, replace_triggered_by).</li><li>Tainted resources.</li></ul><p>✔️ Fix:</p><ul><li>Check drift</li></ul><pre>terraform state list</pre><ul><li>Use targeted apply:</li></ul><pre>terraform apply -target=aws_instance.example</pre><h3>19. Fixing Circular Dependency Errors</h3><p>Circular dependencies happen when two resources depend on each other.</p><p>✔️ Solution: Use depends_on.</p><pre>resource &quot;aws_s3_bucket&quot; &quot;bucket&quot; { }</pre><pre>resource &quot;aws_iam_role&quot; &quot;role&quot; {<br>  depends_on = [aws_s3_bucket.bucket]<br>}</pre><h3>✅ Conclusion</h3><p>Terraform interviews are rarely about syntax — they are about <strong>real-world problem solving</strong>.<br> The scenarios above cover:</p><ul><li><strong>State management</strong></li><li><strong>Security best practices</strong></li><li><strong>Module design</strong></li><li><strong>Testing &amp; automation</strong></li></ul><p>If you can confidently answer these questions with examples from your experience, you’ll stand out as a strong Terraform engineer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce0d1779a07b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ace Your Next DevOps Interview: Detailed Guide to the Most-Asked Questions]]></title>
            <link>https://medium.com/@giet12aei033/ace-your-next-devops-interview-detailed-guide-to-the-most-asked-questions-9a49fa077d64?source=rss-a48fdb79f555------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a49fa077d64</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Nihit Raj]]></dc:creator>
            <pubDate>Tue, 29 Jul 2025 10:21:06 GMT</pubDate>
            <atom:updated>2025-07-29T10:21:06.115Z</atom:updated>
            <content:encoded><![CDATA[<p>Unlock the essentials of DevOps with this collection of practical questions and answers designed for both interview success and day-to-day problem-solving. Here you’ll find clear explanations and real-life scenarios covering Kubernetes, AWS, Docker, Terraform, and more. Perfect for anyone aiming to deepen their understanding of modern cloud and DevOps practices, this guide will help you learn, revisit, and apply key concepts with confidence. Follow along to enhance your skills and stay on top of the latest in DevOps!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3Mtyy1ibED0SWILp.png" /></figure><h3>1. How do you expose a Kubernetes application to external traffic?</h3><p>To make a Kubernetes application accessible from outside your cluster (e.g., by users on the internet), you use one of several Kubernetes Service types:</p><ul><li>LoadBalancer: Creates a cloud provider load balancer and assigns a public IP. Example: kubectl expose deployment myapp --type=LoadBalancer --port=80</li><li>NodePort: Opens a specific port on all cluster nodes and routes traffic to your service. Example: kubectl expose deployment myapp --type=NodePort --port=80</li><li>Ingress: Acts as a smart router, allowing complex URL- or host-based routing. You configure rules that define how requests are routed to different services.</li></ul><h3>2. What is the purpose of a NAT Gateway?</h3><p>A NAT Gateway acts like a “translation booth” for network addresses. It allows resources (like EC2 instances) in a private subnet to access the internet (for OS updates, outgoing API calls) but blocks unsolicited traffic coming from outside. Think of it as a secure tunnel out to the web, but not vice versa. In AWS, NAT Gateways are managed, scalable, and support high availability.</p><h3>3. How do you check running processes in Linux?</h3><p>Use commands like:</p><ul><li>ps aux — lists all active processes with details.</li><li>top or htop — shows processes dynamically, with resource usage.</li><li>You can filter for user or command: ps aux | grep nginx finds all NGINX processes.</li></ul><h3>4. What command would you use to find files larger than 100MB?</h3><p>Run:</p><pre>find /path/to/search -type f -size +100M</pre><p>This searches the specified directory (and subdirectories) for files over 100MB. Change /path/to/search as needed.</p><h3>5. What is the difference between Deployment and StatefulSet in Kubernetes?</h3><ul><li>Deployment: Best for stateless apps. Pods are replaceable and not unique.</li><li>StatefulSet: For stateful apps (like databases). Pods have persistent, unique IDs and storage. If you need data persistence and stable identities for each pod, use StatefulSet.</li></ul><p>Example: Use Deployment for a web API, StatefulSet for a PostgreSQL database.</p><h3>6. What is a ConfigMap, and how is it different from a Secret?</h3><ul><li>ConfigMap: Stores non-sensitive config data (e.g., environment settings).</li><li>Secret: Stores sensitive data (e.g., passwords), encoded for extra protection, though not encrypted out of the box.</li><li>Both can be injected into pods as files or environment variables. Use ConfigMaps for regular config, Secrets for confidential info.</li></ul><h3>7. How do you check network connectivity between two servers?</h3><p>Use tools depending on what you’re checking:</p><ul><li>ping SERVER_IP — Checks basic reachability.</li><li>telnet SERVER_IP PORT or nc -zv SERVER_IP PORT — Checks if a specific port is open.</li><li>traceroute SERVER_IP — Shows the route packets take.</li><li>ssh — Attempts to start a secure session.</li></ul><h3>8. You have an application in Account A that needs to access an S3 bucket in Account B. How would you configure this?</h3><ol><li>In Account B, create an IAM role with S3 permissions, trusted for Account A.</li><li>Add a bucket policy in Account B’s S3 bucket to allow actions for that role.</li><li>In Account A, have the app assume the IAM role (using AWS STS).</li><li>Access the bucket as if it was in the same account, using temporary credentials.</li></ol><h3>9. Write a Dockerfile for a Node.js application with multi-stage builds.</h3><pre># Stage 1: Build<br>FROM node:18-alpine AS build<br>WORKDIR /app<br>COPY package*.json ./<br>RUN npm install<br>COPY . .<br>RUN npm run build<br><br># Stage 2: Production<br>FROM node:18-alpine<br>WORKDIR /app<br>COPY --from=build /app/dist ./dist<br>COPY --from=build /app/package*.json ./<br>RUN npm install --production<br>CMD [&quot;node&quot;, &quot;dist/index.js&quot;]</pre><p>This approach keeps the final image small.</p><h3>10. How do you handle Terraform state file corruption?</h3><ul><li>Use remote state backends like AWS S3 (with versioning).</li><li>If corruption occurs, restore from a previous backup version.</li><li>Avoid manual edits to state files. Protect local state with regular, automated backups.</li></ul><h3>11. Your EC2 instance in a private subnet needs to download packages without NAT Gateway. What alternatives exist?</h3><ul><li>Use AWS Systems Manager (SSM) Session Manager, which doesn’t require internet access or NAT Gateway.</li><li>Set up a proxy or bastion host in a public subnet.</li><li>Use VPC endpoints if your packages come from AWS services (e.g., S3, ECR).</li></ul><h3>12. How do you debug a container that has exited?</h3><ol><li>View logs: docker logs &lt;container-id&gt;</li><li>Start a new shell in the failed image:<br>docker run -it --entrypoint /bin/sh &lt;image&gt;</li><li>For Kubernetes, use kubectl logs and kubectl describe pod &lt;pod-name&gt;</li></ol><h3>13. You need to import an existing AWS VPC into Terraform. What are the steps?</h3><ol><li>Define an empty aws_vpc resource block in your .tf file.</li><li>Import using:<br>terraform import aws_vpc.main vpc-xxxxxx</li><li>Run terraform plan to see differences and adjust your .tf code to reflect the imported resource.</li></ol><h3>14. How would you implement blue-green deployment in Kubernetes?</h3><ul><li>Create two separate environments (“blue” for old, “green” for new).</li><li>Deploy new version as “green” alongside “blue”.</li><li>Change service/Ingress to redirect real traffic to green after testing.</li><li>If all goes well, remove old (“blue”) pods.</li></ul><h3>15. How do you manage secrets in Terraform without hardcoding them?</h3><ul><li>Use environment variables, never put secrets in code.</li><li>Store secrets in secret managers (AWS Secrets Manager, Vault) and reference via data sources.</li><li>Pass sensitive values with terraform apply -var &#39;secret=value&#39; or use .tfvars excluded from version control.</li></ul><h3>16. What’s the difference between COPY and ADD commands in Dockerfile?</h3><ul><li>COPY: Only copies local files/directories.</li><li>ADD: Also extracts local tar files and can pull files from remote URLs.</li><li>Recommendation: Use COPY unless you need ADD’s extra features.</li></ul><h3>17. How would you implement cross-account resource provisioning using Terraform?</h3><ul><li>Configure multiple AWS provider blocks, each with a different account’s credentials or use assume_role.</li><li>Reference resources from one account in another by associating resources to the appropriate provider.</li></ul><h3>18. How would you handle secrets in a Docker container for a PHP application connecting to MySQL?</h3><ul><li>Inject secrets at runtime as environment variables (read using getenv() in PHP).</li><li>For orchestrated setups, use Docker Secrets (Swarm) or Kubernetes Secrets, and mount them into the container.</li><li>Never store secrets directly in your image or codebase.</li></ul><h3>19. An S3 bucket was created via Terraform, but someone manually added a policy. How do you handle this drift?</h3><ul><li>Run terraform plan to see changes (“drift”).</li><li>Decide whether to overwrite manual policy (reapply Terraform) or import/manual adjust your Terraform code to the new, correct policy.</li><li>Communicate with your team on the chosen action.</li></ul><h3>20. How do you implement network policies to restrict pod-to-pod communication in Kubernetes?</h3><ul><li>Write a NetworkPolicy YAML resource specifying allowed/denied traffic by pod label, namespace, or IP range.</li><li>Example: Deny all by default, then explicitly allow needed routes.</li></ul><h3>21. Your company’s cloud costs are increasing rapidly. How would you approach cost optimization without impacting performance?</h3><ul><li>Analyze cloud bills to identify costly services/resources.</li><li>Right-size servers and databases, use auto-scaling, purchase reserved or savings plans for stable workloads.</li><li>Set up automated cleanup of unused resources.</li><li>Enable cost alerts, tag resources for accountability.</li></ul><h3>22. How would you set up geolocation-based routing using AWS services?</h3><ul><li>Use AWS Route 53 Geolocation Routing Policies to direct users to different resources depending on their region.</li><li>For content (static files/media), use AWS CloudFront with geolocation restrictions to serve the nearest content edge cache.</li></ul><h3>23. Your company’s cloud costs are increasing rapidly. How would you approach cost optimization without impacting performance?</h3><ul><li>Analyze cloud bills to identify costly services/resources.</li><li>Right-size servers and databases, use auto-scaling, purchase reserved or savings plans for stable workloads.</li><li>Set up automated cleanup of unused resources.</li><li>Enable cost alerts, tag resources for accountability.</li></ul><h3>24. How would you set up geolocation-based routing using AWS services?</h3><ul><li>Use AWS Route 53 Geolocation Routing Policies to direct users to different resources depending on their region.</li><li>For content (static files/media), use AWS CloudFront with geolocation restrictions to serve the nearest content edge cache.</li></ul><h3>Conclusion</h3><p>Mastering DevOps means understanding not just the tools, but the reasoning and patterns behind how modern cloud infrastructure works. By breaking down real interview scenarios and exploring solutions for Kubernetes, AWS, Docker, Terraform, and more, you’re equipping yourself with skills that go beyond theory — skills demanded by today’s dynamic engineering teams. Whether you’re prepping for your next big opportunity or striving to elevate daily operations, these insights and examples will serve as a strong foundation for solving real-world challenges. Keep exploring, stay curious, and continue building your DevOps expertise — the future of technology depends on innovators like you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a49fa077d64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding the Cloud: How I Turned My AWS Architecture into Diagrams]]></title>
            <link>https://medium.com/@giet12aei033/coding-the-cloud-how-i-turned-my-aws-architecture-into-diagrams-24417d79fd9f?source=rss-a48fdb79f555------2</link>
            <guid isPermaLink="false">https://medium.com/p/24417d79fd9f</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Nihit Raj]]></dc:creator>
            <pubDate>Tue, 29 Jul 2025 05:44:15 GMT</pubDate>
            <atom:updated>2025-07-29T05:48:04.747Z</atom:updated>
            <content:encoded><![CDATA[<p>In the rapidly evolving world of cloud computing, architecting solutions on AWS isn’t just a technical exercise — it’s an art form. It blends engineering with strategic thinking and requires clarity not only in design but also in communication. As more teams migrate workloads to the cloud, the need to <strong>visualize complex architectures</strong> becomes essential.</p><p>That’s what sparked my journey: turning AWS architecture into living diagrams — using code.</p><p>In this post, I’ll walk you through why cloud diagrams matter, how Infrastructure as Code (IaC) can be leveraged for visualization, the tools I used, and a practical example to help you bring your own architecture to life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HFgugbg52aWs-bR8.png" /></figure><h3>🧠 Why Diagrams Still Matter in Cloud Architecture</h3><p>You might think that once infrastructure is codified, diagrams are redundant. But I’d argue the opposite.</p><p>Clear diagrams aren’t just helpful — they’re <strong>critical</strong> for:</p><ul><li><strong>Simplification</strong>: Making sense of sprawling cloud setups.</li><li><strong>Team Alignment</strong>: Ensuring architects, developers, and stakeholders speak the same language.</li><li><strong>Living Documentation</strong>: Acting as real-time visual references for evolving systems.</li></ul><p>In fact, teams with clear architecture diagrams see up to <strong>30% greater development efficiency</strong>. The visual clarity reduces back-and-forth, prevents misconfigurations, and aligns team members from Day 1.</p><h3>⚙️ Enter: Infrastructure as Code (IaC)</h3><p>Traditional diagramming with PowerPoint or static draw.io templates falls flat in the face of modern, modular, ever-evolving cloud setups.</p><p>This is where <strong>Infrastructure as Code</strong> shines.</p><p>IaC doesn’t just define your resources — it becomes the <strong>single source of truth</strong>, and, when paired with the right tools, it can generate <strong>accurate, real-time architecture diagrams</strong> with minimal effort.</p><p>With IaC, you get:</p><ul><li>✅ <strong>Version control</strong> with Git</li><li>✅ <strong>Modularity</strong> and reuse of architecture components</li><li>✅ <strong>Automatic diagrams</strong> that evolve with your code</li></ul><h3>🔧 Tools I Used to Turn AWS Code into Diagrams</h3><p>To bring this vision to life, I assembled a small but powerful toolkit:</p><h3>1. Terraform</h3><p>An open-source IaC tool that lets you declare AWS resources using code. Its declarative style is ideal for consistency and readability.</p><h3>2. Diagramming Libraries</h3><p>I used <strong>Mermaid.js</strong> and <strong>PlantUML</strong> — both great for converting infrastructure configurations into clean diagrams using plain text syntax.</p><ul><li><strong>Mermaid.js</strong>: Great for quick, markdown-friendly visuals.</li><li><strong>PlantUML</strong>: A bit more expressive — ideal for detailed architecture diagrams.</li></ul><h3>3. AWS CloudFormation</h3><p>While my preference is Terraform, I also explored <strong>CloudFormation</strong> — AWS’s native IaC tool. It integrates well with AWS-specific visual tools like CloudFormation Designer.</p><h3>💡 A Simple Example: From Code to Diagram</h3><p>Let’s say I want to spin up a basic architecture: one EC2 instance, an S3 bucket, and an RDS database.</p><p>Here’s what the <strong>Terraform code</strong> might look like:</p><pre>resource &quot;aws_instance&quot; &quot;my_ec2&quot; {<br>  ami           = &quot;ami-12345678&quot;<br>  instance_type = &quot;t2.micro&quot;<br>}</pre><pre>resource &quot;aws_s3_bucket&quot; &quot;my_bucket&quot; {<br>  bucket = &quot;my-unique-bucket-name&quot;<br>}</pre><pre>resource &quot;aws_db_instance&quot; &quot;my_db&quot; {<br>  allocated_storage = 20<br>  engine            = &quot;mysql&quot;<br>  engine_version    = &quot;5.7&quot;<br>  instance_class    = &quot;db.t2.micro&quot;<br>  identifier        = &quot;my-database&quot;<br>  name              = &quot;mydb&quot;<br>  username          = &quot;admin&quot;<br>  password          = &quot;password&quot;<br>}</pre><p>With <strong>PlantUML</strong>, you can easily create a visual like:</p><pre>@startuml<br>cloud &quot;AWS&quot; {<br>  [EC2 Instance] --&gt; [S3 Bucket]<br>  [EC2 Instance] --&gt; [RDS Database]<br>}<br>@enduml</pre><p>This gives you a clear architectural map that updates as your Terraform changes — no manual redraws required.</p><h3>🤔 Misunderstandings and Common Debates</h3><p>There are a few misconceptions when it comes to diagramming code-based architecture:</p><ul><li><strong>“If it’s already in code, why draw it?”</strong><br> Because diagrams bridge the gap between technical and non-technical audiences. Not everyone can (or should) read Terraform.</li><li><strong>“Should diagrams be high-level or detailed?”</strong><br> It depends on the audience. High-level overviews help with strategic planning. Detailed diagrams assist in debugging and audits.</li></ul><p>Ultimately, you’ll often need <strong>both</strong>, depending on the situation.</p><h3>✅ Conclusion: Code Your Way to Clarity</h3><p>Visualizing your AWS architecture with code is more than just a cool trick — it’s a smarter, cleaner way to keep your infrastructure transparent, up-to-date, and accessible to all stakeholders.</p><p>Whether you’re using Terraform, CloudFormation, or CDK, combining IaC with tools like PlantUML or Mermaid brings clarity to complexity.</p><p>The next time you architect a cloud solution, don’t stop at writing the code — <strong>draw it with your code</strong>. You’ll thank yourself (and so will your team).</p><p><strong>🚀 Ready to start diagramming your AWS infrastructure through code?</strong><br> You’ve already got the blueprint in your Terraform files. Now all that’s left is to make it visual.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24417d79fd9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevOps Interview Questions 2024]]></title>
            <link>https://medium.com/@giet12aei033/devops-interview-questions-2024-f0669f7a2b84?source=rss-a48fdb79f555------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0669f7a2b84</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Nihit Raj]]></dc:creator>
            <pubDate>Fri, 06 Sep 2024 04:52:21 GMT</pubDate>
            <atom:updated>2024-09-06T04:52:21.032Z</atom:updated>
            <content:encoded><![CDATA[<p>In 2024, DevOps remains a critical function in IT organizations, bridging the gap between development and operations. As companies continue to adopt DevOps practices, the demand for skilled engineers has never been higher. Whether you’re an experienced professional looking to switch jobs or a newbie trying to break into the field, preparing for a DevOps interview can be daunting. To help you succeed, I’ve compiled a comprehensive list of DevOps interview questions that you might encounter in 2024, along with explanations and insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*AOjJWGhIhHeIt7bWeA0P3w.jpeg" /></figure><h3><strong>Q. You’re trying to upgrade your worker node, but the pod is not being evicted. What could be the cause?</strong></h3><p>Here are potential reasons why a pod might not be evicted when trying to upgrade a worker node:</p><ul><li><em>Pod Disruption Budgets (PDBs): </em>If a Pod Disruption Budget is configured, it may prevent the eviction of pods to ensure a minimum number of pods are always available. Check the PDB settings to see if they are restricting the eviction.</li><li><em>Taints and Tolerations</em>: The node might have taints that the pod does not tolerate, or the pod might have tolerations that are not matching the node’s taints. Verify that the taints and tolerations are properly configured.</li><li><em>Node Affinity and Node Selectors</em>: If the pod has specific node affinity or node selectors, it might only be schedulable on certain nodes. Ensure that there are other nodes available that meet the pod’s affinity or selector criteria.</li></ul><h3><strong>Q. What is Pod Disruption Budget (PDB)?</strong></h3><ul><li>PDB is a resource that is created to ensure minimum number of replicas of pod that must be available at any given time. It help ensures high availability of the application during voluntery disruption such as node maintenance. It prevents too many pods to be down simultaneously, thereby protecting application availability.</li><li>PBD is only for voluntery disruption not for involuntary disruption.<br>Proper use of PDB requires correct labeling and a sufficient number of replicas tp meet the requirement.</li></ul><pre>apiVersion: policy/v1<br>kind: PodDisruptionBudget<br>metadata:<br>  name: zk-pdb<br>spec:<br>  minAvailable: 2<br>  selector:<br>    matchLabels:<br>      app: zookeeper</pre><pre>apiVersion: policy/v1<br>kind: PodDisruptionBudget<br>metadata:<br>  name: zk-pdb<br>spec:<br>  maxUnavailable: 1<br>  selector:<br>    matchLabels:<br>      app: zookeeper</pre><h3><strong>Q. How do you monitor the health of a container and ensure that an application is running as expected ?</strong></h3><p>In Kubernetes, probes are employed to monitor a container’s health and verify that an application is running correctly.</p><ul><li><em>Liveness Probe: </em>It ensures that application within a container is live and operational. This is useful for detecting and remedying situation where an application is stuck ot deadlock.</li></ul><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: liveness-probe-example<br>spec:<br>  containers:<br>  - name: my-container<br>    image: my-image:latest<br>    livenessProbe:<br>      httpGet:<br>        path: /healthz<br>        port: 8080<br>      initialDelaySeconds: 30<br>      periodSeconds: 10<br>      timeoutSeconds: 5</pre><ul><li><em>Readiness Probe: </em>It determines if container is ready to accept traffic. If the readiness probe fails, the pod is marked as “unready,” and it’s removed from the service load balancer until it passes again.</li></ul><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: readiness-probe-example<br>spec:<br>  containers:<br>  - name: my-container<br>    image: my-image:latest<br>    readinessProbe:<br>      httpGet:<br>        path: /ready<br>        port: 8080<br>      initialDelaySeconds: 20<br>      periodSeconds: 5<br>      timeoutSeconds: 3</pre><ul><li><em>Startup probes: </em>It is used to determine whether a container has started successfully. It is particularly useful for containers that require a longer time to initialize and become ready. Unlike liveness and readiness probes, which check the ongoing health and readiness of a container, the startup probe focuses on the initial startup phase.</li></ul><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: startup-probe-example<br>spec:<br>  containers:<br>  - name: my-container<br>    image: my-image:latest<br>    startupProbe:<br>      httpGet:<br>        path: /startup<br>        port: 8080<br>      failureThreshold: 30<br>      periodSeconds: 10<br>      timeoutSeconds: 5</pre><h3><strong>Q. How can you control which node a pod is scheduled on?</strong></h3><p>Node affinity is a Kubernetes feature that controls on which nodes pods can be scheduled on by using labels assigned to those nodes.</p><pre>kubectl label nodes &lt;node-name&gt; disktype=ssd</pre><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: node-affinity-example<br>spec:<br>  containers:<br>  - name: my-container<br>    image: my-image:latest<br>  affinity:<br>    nodeAffinity:<br>      requiredDuringSchedulingIgnoredDuringExecution:<br>        nodeSelectorTerms:<br>        - matchExpressions:<br>          - key: disktype<br>            operator: In<br>            values:<br>            - ssd</pre><h3><strong>Q. What are taints and toleration in kubernetes?</strong></h3><p>In Kubernetes, taints and tolerations are mechanisms used to control which pods can be scheduled on which nodes.</p><p>A <strong>taint</strong> is applied to a node and prevents pods from being scheduled on that node unless the pods have matching tolerations.</p><p>A taint consists of a key, a value, and an effect.</p><ul><li><strong>Key:</strong> A string used to identify the taint.</li><li><strong>Value:</strong> An optional string that provides additional information.</li><li><strong>Effect:</strong> Defines the impact of the taint on pod scheduling. The available effects are:</li><li>NoSchedule: Pods will not be scheduled on the node if they do not tolerate the taint.</li><li>PreferNoSchedule: Kubernetes will try to avoid scheduling pods on the node, but it’s not a strict requirement.</li><li>NoExecute: Pods already running on the node will be evicted if they do not tolerate the taint, and new pods will not be scheduled.</li></ul><p>A <strong>toleration</strong> is applied to a pod and allows the pod to be scheduled on nodes with matching taints.<br>A toleration also consists of a key, a value, and an effect, and optionally a tolerationSeconds field that specifies the duration a pod can tolerate a NoExecute taint.</p><pre>kubectl taint nodes &lt;node-name&gt; key=value:NoSchedule</pre><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: taint-toleration-example<br>spec:<br>  containers:<br>  - name: my-container<br>    image: my-image:latest<br>  tolerations:<br>  - key: &quot;key&quot;<br>    operator: &quot;Equal&quot;<br>    value: &quot;value&quot;<br>    effect: &quot;NoSchedule&quot;</pre><h3><strong>Q. How to copy file from Pod to local machine ?</strong></h3><p>To copy a file from a Kubernetes pod to local machine, use the kubectl cp command. This command allows to transfer files between a container in a pod and local filesystem.</p><pre>kubectl cp &lt;namespace&gt;/&lt;pod-name&gt;:&lt;path-to-file-in-pod&gt; &lt;path-to-local-file&gt;</pre><h3><strong>Q. Is it possible that service in one namespace can commmunicate with another namespace?</strong></h3><p>Yes, it is possible for services in one Kubernetes namespace to communicate with services in another namespace. Kubernetes allows cross-namespace communication by using fully qualified domain names (FQDNs) for services.</p><pre> &lt;service-name&gt;.&lt;namespace-name&gt;.svc.cluster.local</pre><h3><strong>Q. How can we prevent a service in one namespace from accessing a service in another namespace using FQDN?</strong></h3><ul><li>Kubernetes Network Policies allow to define rules that control traffic between pods and services based on namespaces, labels, and IP addresses. To restrict access between services in different namespaces.</li><li>Create network policies that explicitly deny traffic from pods in one namespace to services or pods in another namespace.</li><li>To deny traffic from namespace-a to namespace-b, we can create a policy in namespace-b that blocks incoming traffic from namespace-a as below:</li></ul><pre>apiVersion: networking.k8s.io/v1<br>kind: NetworkPolicy<br>metadata:<br>  name: deny-namespace-a<br>  namespace: namespace-b<br>spec:<br>  podSelector:<br>    matchLabels:<br>      app: target-app<br>  policyTypes:<br>  - Ingress<br>  ingress:<br>  - from:<br>    - namespaceSelector:<br>        matchLabels:<br>          name: namespace-a</pre><h3><strong>Q. Why namespace is used in Kubernetes?</strong></h3><ul><li>It allows teams or project to exist in their own virtual cluster without fear of impacting each other’s work.</li><li>Implement RBAC to restrict users and process to certain namespaces.</li><li>Easy method to seperate dev, test and prod resources.</li></ul><h3><strong>Q. Why is _heplers.tpl file used in helm?</strong></h3><ul><li>In Helm charts, the _helpers.tpl file is used to define reusable templates and functions.It stores commonly used template snippets that can be referenced across multiple chart files. This avoids duplication and centralizes template logic.</li></ul><pre>{{- define &quot;mychart.labels&quot; -}}<br>app: {{ .Chart.Name }}<br>release: {{ .Release.Name }}<br>{{- end -}}</pre><h3><strong>Q. What are the most commanly used helm command ?</strong></h3><p>Helm is a powerful package manager for Kubernetes that simplifies the deployment and management of applications.</p><p>helm install: Deploy a Helm chart to your Kubernetes cluster.</p><pre>helm install &lt;release-name&gt; &lt;chart&gt; [flags]</pre><p>helm upgrade : Upgrade a release to a new version of a chart.</p><pre>helm upgrade &lt;release-name&gt; &lt;chart&gt; [flags]</pre><p>helm uninstall : Uninstall a Helm release from your cluster.</p><pre>helm uninstall &lt;release-name&gt; [flags]</pre><p>helm list : List all Helm releases in the cluster</p><pre>helm list [flags]</pre><p>helm repo add <strong>: </strong>Add a new Helm chart repository</p><pre>helm repo add &lt;repo-name&gt; &lt;repo-url&gt;</pre><p>helm repo update: Update information about available charts from repositories.</p><pre>helm repo update</pre><p>helm search: Search for charts in Helm repositories.</p><pre>helm search repo &lt;keyword&gt;</pre><p>helm show: Display information about a chart.</p><pre>helm show &lt;chart-type&gt; &lt;chart&gt;</pre><p>helm template: Render the Helm chart to Kubernetes manifests without installing it.</p><pre>helm template &lt;release-name&gt; &lt;chart&gt; [flags]</pre><p>helm history: Show the history of revisions for a given release.</p><pre>helm history &lt;release-name&gt; [flags]</pre><h3><strong>Q. What is the difference between stateless and stateful application?</strong></h3><ul><li>The applications that don’t need to remember any information between requests. Each request is treated independently is stateless application.<br><em>Example: </em>A web server that serves static content or a front-end application that doesn’t need to store user data.</li><li>The applications that need to maintain and manage data or state between requests. They remember and store information over time.<br><em>Example: </em>A database or a messaging queue that needs to retain and manage data consistently.</li></ul><h3><strong>Q. What is the difference between deployment and stateful set and when are they used?</strong></h3><ul><li><strong>Purpose:</strong> Deployments are designed for stateless applications where each instance is identical and does not need to maintain state. In contrast, StatefulSets are used for stateful applications that require stable identities and persistent storage.</li><li><strong>Replica Management:</strong> Deployments manage replicas uniformly, ensuring a specified number of pods are running. StatefulSets assign unique identities to each pod and manage their state across restarts.</li><li><strong>Network Identity:</strong> Pods in Deployments do not have stable network identities, meaning they can be replaced or scaled without concern for their individual identity. StatefulSets provide stable, unique network identities for each pod, which is crucial for applications needing consistent addresses.</li><li><strong>Storage:</strong> Deployments typically use ephemeral storage, which is not retained between pod restarts. StatefulSets, however, use Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) to provide reliable, long-term storage.</li><li><strong>Rolling Updates:</strong> Deployments allow rolling updates, enabling smooth transitions between versions with no downtime. StatefulSets handle updates in a more controlled manner, ensuring that stateful applications are updated sequentially and reliably.</li><li><strong>Scaling:</strong> Scaling Deployments is straightforward, as you can simply adjust the number of replicas. StatefulSets scale pods in a specific order, ensuring that the application’s state is managed correctly.</li><li><strong>Pod Management:</strong> In Deployments, pods are interchangeable and stateless, while in StatefulSets, each pod has a distinct identity and retains its state, making them non-interchangeable.</li></ul><h4>When to Use Each:</h4><ul><li><strong>Deployments</strong> are ideal for stateless applications such as web servers or APIs, where each pod is identical and doesn’t need to retain information between restarts.</li><li><strong>StatefulSets</strong> are best suited for stateful applications like databases or message queues, where each pod needs to maintain a unique identity and access persistent storage.</li></ul><h3>Conclusion</h3><p>As we approach 2024, DevOps engineers play a crucial role in integrating development and operations.By understanding these concepts, we’re better prepared to demonstrate our skills and stay adaptable in a fast-evolving field. Let’s keep learning, practicing, and engaging with the DevOps community to ensure our success in the year ahead.</p><p>Good luck with your preparations…!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0669f7a2b84" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>