<?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[Kubernetes]]></title><description><![CDATA[Let's dive into the Kubernetes world.]]></description><link>https://thek8sguide.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6ad77272a22dae02e1051360/4c78c3d6-548f-48a7-a42a-bb803c50c688.png</url><title>Kubernetes</title><link>https://thek8sguide.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 04 Nov 2026 08:20:06 GMT</lastBuildDate><atom:link href="https://thek8sguide.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding Kubernetes Controller - The architecture]]></title><description><![CDATA[Let us deep dive into one of the K8s Control Plane component - The Controller(s).]]></description><link>https://thek8sguide.hashnode.dev/understanding-kubernetes-controller-the-architecture</link><guid isPermaLink="true">https://thek8sguide.hashnode.dev/understanding-kubernetes-controller-the-architecture</guid><dc:creator><![CDATA[aj-learnings]]></dc:creator><pubDate>Tue, 27 Oct 2026 17:21:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ad77272a22dae02e1051360/2c30af35-3650-42c5-b469-f11b3f9b7b17.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Since we've already discussed Kubernetes components and how they communicate in the previous articles, we'll now start exploring them in more detail.</p>
<p>We'll begin with <strong>Kubernetes Controllers</strong>, often referred to as the brains of Kubernetes.</p>
<details data-node-type="hn-details-summary">
<summary>The Problem</summary>
<p>Let's assume we have three instances of our application running, and all three are operating at 80% capacity. Everything is working fine, and users are being served without any issues.</p><p>Then comes the nightmare: one instance crashes.</p><p>Intelligent routing might redirect incoming requests to the remaining two Pods, but who notices that an instance is missing? Who creates a replacement? Who keeps track of whether the desired number of instances is running?</p><p>The answer is one of the K8s controller - The <strong>ReplicaSet Controller</strong>.</p>
</details>

<h3>What is a Kubernetes Controller ?</h3>
<p>A Kubernetes controller, in simple terms, is a component whose job is to bring the actual state of the cluster closer to its desired state. It continuously observes the resources it is responsible for and takes action whenever it detects a difference between the desired and actual states.</p>
<p>Kubernetes has many controllers, each responsible for a specific set of tasks. Although their responsibilities differ, they all follow the same underlying principle: <strong>reconcile the actual state with the desired state.</strong></p>
<h3>The Desired vs Actual state</h3>
<p><strong>Desired state</strong> is the state that the user or operator wants the cluster to maintain. It describes the target configuration of the cluster.</p>
<p><strong>Actual state</strong> represents the current state of the cluster, based on what is actually happening at that moment. K8s components observe this state and work towards bringing it closer to the desired state.</p>
<h3>The Working</h3>
<p>Let us understand the working of any controller in K8s :</p>
<ul>
<li><em><strong>Observation</strong></em> - The controller observe the current state of the resource it is responsible for.</li>
<li><em><strong>Comparison</strong></em> - It then compares the Desired state with the Actual state.</li>
<li><em><strong>Correction</strong></em> - if the state's don't match, it takes the necessary action. Depending on its responsibility, it might create a resource, update one, or remove one.</li>
<li><em><strong>Repetition</strong></em> - It doesn't stops after performing the task once, as changes can happen at any time, and the desired state may also change. So, it keeps reconciling.</li>
</ul>
<h3>A real controller - The ReplicaSet Controller</h3>
<p>The ReplicaSet controller is one of the well-known controllers in Kubernetes. When we create a resource of type <code>ReplicaSet</code>, we specify the desired number of replicas (instances) we want to run. The job of this controller is to ensure that the number of matching Pods is equal to the desired replica count.</p>
<p>For example, let's say we create a ReplicaSet with <code>replicas: 3</code>. The controller observes the current state and finds that no matching Pods exist yet. It then requests the creation of three Pods through the API Server. Now, imagine one of these Pods gets deleted. The controller detects that only two matching Pods remain, even though the desired count is three. It requests the creation of another Pod to make up for the difference.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6ad77272a22dae02e1051360/96e683a2-26db-4051-945b-86a28af663dc.gif" alt="" style="display:block;margin:0 auto" />

<p>As discussed in the <a href="https://thek8sguide.hashnode.dev/understanding-kubernetes-the-naive-way">previous article</a>, creating a Pod and running it are two different responsibilities. The ReplicaSet controller requests Pod creation, but it doesn't run the Pod itself. The Scheduler assigns the new Pod to a suitable Node, and the kubelet on that Node works with the container runtime to run its containers. We can refer to the previous article of the series for this.</p>
<p>This process continues as long as the ReplicaSet exists. Whether a Pod is deleted, fails, or the desired replica count changes, the controller keeps reconciling the state to bring the number of matching Pods closer to the requested count.</p>
<h3>Other Controllers</h3>
<p>Kubernetes has many controllers to manage different aspects of the cluster. Although their responsibilities differ, the underlying principle remains the same: <strong>to reconcile the actual state with the desired state</strong>.</p>
<p>For example, the <strong>Node Controller</strong> monitors the health of Nodes and responds when their state changes. Similarly, other controllers handle different responsibilities to help keep the cluster running as expected.</p>
<p>We'll explore these controllers in more detail as we encounter them in upcoming articles.</p>
<hr />
<p>Thus, this marks the end of our introduction to Kubernetes Controllers!</p>
<p>We've seen why controllers are needed, how they work towards the desired state through reconciliation, and how the ReplicaSet controller applies this principle in practice.</p>
<p>But this is only the beginning. In the upcoming articles, we'll go beyond the concepts and explore how these controllers actually work under the hood by looking at the Kubernetes source code, examining debug logs, and even building a custom controller of our own.</p>
<p><strong>Stay tuned for more!</strong></p>
<p>You can find me here - <a href="https://www.linkedin.com/in/aayushjalan"><strong><u>LinkedIn</u></strong></a> <a href="https://www.instagram.com/aj_learnings/"><strong><u>Instagram</u></strong></a> <a href="https://x.com/aj_learnings"><strong><u>Twitter(X)</u></strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Kubernetes Watch Mechanism - How Components Stay in Sync]]></title><description><![CDATA[Let us discuss about the watch mechanism in K8s and how do all components communicate.]]></description><link>https://thek8sguide.hashnode.dev/kubernetes-watch-mechanism-how-components-stay-in-sync</link><guid isPermaLink="true">https://thek8sguide.hashnode.dev/kubernetes-watch-mechanism-how-components-stay-in-sync</guid><dc:creator><![CDATA[aj-learnings]]></dc:creator><pubDate>Fri, 23 Oct 2026 19:00:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ad77272a22dae02e1051360/23443e8c-e71c-4741-af94-07fbd68867d4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the previous article, we explored the roles of Kubernetes components in deploying and running an application. Now, since each component performs specific tasks, a few questions naturally arise: How do these components communicate? How do they know what needs to be done? Who informs them when something changes?</p>
<p>Kubernetes components generally don't communicate directly with one another. Instead, they interact through the Kubernetes API Server, which acts as a common point of communication. This allows components to focus on their own responsibilities without needing to know the internal workings of other components.</p>
<p>Components make read and write requests to the API Server to retrieve or update resources. But how do they know when something changes? One approach would be to keep sending requests to the API Server at regular intervals to check for updates. However, this approach has a few disadvantages:</p>
<ul>
<li><strong>Unnecessary requests:</strong> Components may keep making requests even when nothing has changed.</li>
<li><strong>Delayed updates:</strong> A component may not detect a change until its next scheduled check.</li>
<li><strong>Increased load:</strong> Frequent polling by multiple components can generate a large number of requests to the API Server.</li>
</ul>
<p>This is where the <strong>Kubernetes Watch Mechanism</strong> comes into the picture. Instead of repeatedly requesting the latest state, components can watch for changes to the resources they care about and receive notifications when relevant changes occur.</p>
<h3>The Working of the Mechanism</h3>
<p>In K8s, the Watch mechanism uses long-lived HTTP connections to observe changes in resources. It is an event-driven mechanism mediated by the API Server. Components establish a connection with the API Server through the Kubernetes Watch API and listen for relevant changes to the resources they are interested in.</p>
<details data-node-type="hn-details-summary">
<summary>Long lived HTTP connection</summary>
<p>A long-lived HTTP connection is not a separate protocol. It is a connection that remains open for an extended period, and there are different ways to use it. Two examples are HTTP streaming and Server-Sent Events (SSE).</p><p>In these approaches, the client sends an HTTP request, and the server keeps the response open to stream data back to the client. However, the client generally cannot send arbitrary new application messages through that same response. To send another request, it uses a separate HTTP request.</p><p>This differs from WebSocket, which support full-duplex communication, meaning both the client and server can send data to each other over the same connection.</p><img class="rounded-lg max-w-full h-auto" src="https://cdn.hashnode.com/uploads/covers/6ad77272a22dae02e1051360/bbafe43b-3d9b-4275-b05f-480f7ac2c973.gif" style="display:block;margin:0 auto" />
</details>

<p>Let us go step by step to understand the working for a component :</p>
<ul>
<li><p><em>Initial Request (LIST)</em> - The component first performs a <strong>LIST</strong> operation.It asks the API Server to return a list of resources of a particular type. The response looks something like this:</p>
<pre><code class="language-json">// API call : GET /api/v1/pods
{
    "kind": "PodList",
    "apiVersion": "v1",
    "metadata": {
        "resourceVersion": "12345",
        ...others
     },
    "items": [
        ....
    ]
}
</code></pre>
<p>The<code>metadata.resourceVersion</code>field identifies the version associated with the returned snapshot. The component keeps track of this version so it can use it when starting the Watch request.</p>
</li>
<li><p><em>Watch Request</em> - Now, the component opens a watch request with the API Server <code>GET /api/v1/pods?watch=true&amp;resourceVersion=12345</code>. This establishes a long-lived HTTP connection between the component and the API Server. The server keeps the response open and streams relevant changes that occurred after the specified resource version.</p>
</li>
<li><p><em>Streaming Updates</em> - Whenever a relevant change occurs, such as a Pod being created, updated, or deleted, the API Server sends an event over the same connection. For example:</p>
<pre><code class="language-json">{
  "type": "ADDED",
  "object": { ...... }
}

{
  "type": "MODIFIED",
  "object": { ...... }
}

{
  "type": "DELETED",
  "object": { ...... }
}
</code></pre>
<p>The component processes these events and takes the appropriate action. For example, when the Scheduler learns about a new Pod that has not yet been assigned to a Node, it can evaluate that Pod for scheduling.</p>
</li>
</ul>
<p>However, this connection does not remain open indefinitely. It may close because of a timeout, a network interruption, or other reasons. The component must handle these situations and reconnect when needed.</p>
<p>To resume watching, it can use the latest <code>resourceVersion</code> it has processed, allowing it to receive subsequent changes as long as that version is still available in the API Server's history. If the requested version is no longer available, the API Server can return a <code>410 Gone</code> response. The component must then perform another LIST operation to obtain a fresh snapshot and start watching again using the new version.</p>
<h3>An Example</h3>
<p>Let us understand this complete interaction with the help of a simple example - Creating a Pod. We will assume that the Scheduler already have an established connection.</p>
<ol>
<li>Create a <code>Pod</code> - We send a request to the API Server using <code>kubectl</code> to create a Pod. After validation, the K8s stores the Pod's data in <code>etcd</code>.</li>
<li>API Server sends an event - Since the Scheduler have a connection established, so the API Server streams an event with the new Pod's details over the same connection.</li>
<li>Scheduler starts focusing on the <code>Pod</code> - The Scheduler then decides the suitable node for the POD based on Pod's requirement and scheduling constraints.</li>
<li>Updating the API Server - Once the node is assigned to the <code>Pod</code>, the Scheduler makes a separate API request to the update the information in the <code>etcd</code>.</li>
<li>Running the Pod - On the assigned Node, the <code>kubelet</code> got the Pod's specs through its own watcher with the API Server. It then works on that Node to run the Pod.</li>
</ol>
<h3>Illustration</h3>
<img src="https://cdn.hashnode.com/uploads/covers/6ad77272a22dae02e1051360/f5918dd4-d29a-46ea-9b6a-253357cdc3fc.gif" alt="" style="display:block;margin:0 auto" />

<p>This design let's Kubernetes to scale to thousands of nodes — components don’t spam the API Server, they just “listen” for updates.</p>
<p>In the upcoming articles in this series, we'll go more deeper into the Kubernetes world.</p>
<p><strong>Stay tuned for more!</strong></p>
<p>You can find me here - <a href="https://www.linkedin.com/in/aayushjalan">LinkedIn</a> <a href="https://www.instagram.com/aj_learnings/">Instagram</a> <a href="https://x.com/aj_learnings">Twitter(X)</a></p>
]]></content:encoded></item><item><title><![CDATA[Understanding Kubernetes - The Naive Way]]></title><description><![CDATA[Let us dig into Kubernetes components, their interactions, and their collaboration through a simple real-world analogy.]]></description><link>https://thek8sguide.hashnode.dev/understanding-kubernetes-the-naive-way</link><guid isPermaLink="true">https://thek8sguide.hashnode.dev/understanding-kubernetes-the-naive-way</guid><dc:creator><![CDATA[aj-learnings]]></dc:creator><pubDate>Wed, 21 Oct 2026 18:24:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ad77272a22dae02e1051360/f5674fd0-e25b-4db5-ac37-f26edfcea1f6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<details>
<summary>Beyond the Abstractions</summary>
<blockquote class="editor-blockquote"><p>In today's AI-driven world, where we rely on AI to get things done faster, it's easy to overlook the fundamentals of the systems we use every day.</p><p>From my experience, I believe it's important to understand how these systems work under the hood. When things break, services go down, or a blackout hits, knowing the internals helps you troubleshoot problems, make informed decisions, and get things back on track.</p><p><strong>AI can help us build faster, but understanding the fundamentals helps us when things go wrong.</strong></p></blockquote>
</details>

<p><em><strong>Kubernetes</strong></em> or <em><strong>k8s</strong></em>, in simple terms, is a system that helps us deploy, manage, and scale applications. Originally developed by Google, it automates many of the tasks involved in running applications, making them easier to manage reliably at scale.</p>
<details>
<summary>The Why Behind Kubernetes</summary>
<blockquote class="editor-blockquote"><p>As containerized applications started gaining popularity, managing them at scale became increasingly complex. Docker emerged as a major player in the container ecosystem, and various tools and systems began evolving around it. However, deploying containers, distributing them across machines, scaling them based on demand, and handling failures still required significant effort.</p><p>This created the need for a system that could automate these operations and manage containerized applications efficiently. Kubernetes emerged as a solution to this challenge.</p></blockquote>
</details>

<p>To understand Kubernetes and what it does, we first need to understand its resources and components. It wouldn't be entirely incorrect to say that these components, working together, are what make Kubernetes what it is.</p>
<p>There are, however, many resources and components in Kubernetes. As the title of this blog suggests, we'll keep things simple and won't cover every one of them here. Instead, we'll follow a <em><strong>learn as you go</strong></em> approach.</p>
<p>This approach has personally worked well for me, as too much theoretical information without practical context can make it difficult to understand how things actually work.</p>
<p>Before we dive in the k8s components role's and their working, let us learn some essential terms to start with.</p>
<ul>
<li><p>Pod - The smallest unit in K8s. It can contain one or more containers but the application container runs here.</p>
</li>
<li><p><em>Node</em> - A physical or virtual machine where application workloads run . It has its own CPU, memory, and storage.</p>
</li>
<li><p><em>Cluster</em> - A group of machine(s), or node(s), managed by Kubernetes to deploy and manage applications.</p>
</li>
</ul>
<p>Now, let's take a look at some of the key components of Kubernetes and understand their roles. These components form the backbone of K8s. These components are each responsible for a different task. To understand them better, let's group them based on their roles and where they typically run.</p>
<h3>Control Plane components</h3>
<p>These components are responsible for managing the cluster and making decisions about its state.</p>
<ul>
<li><p><em>API Server</em> - This is the main entry point for interacting with the Kubernetes API. It validates, stores and exposes K8s resources. We can think of it as the gateway through which users and Kubernetes components interact with the cluster.</p>
</li>
<li><p><em>etcd</em> - This is the Kubernetes database. It is a key-value store that holds the cluster's data, including the desired and current states recorded in Kubernetes resources.</p>
</li>
<li><p><em>Scheduler</em> -This is the Pod assigner. Its primary job is to assign a Pod to a Node based on multiple factors, such as node availability, the Pod's requirements, and other scheduling constraints.</p>
</li>
<li><p><em>Controllers</em> - These are the brains of K8s. They make sure what <em>should be</em> is what <em>is.</em> They continuously monitor resources and take action to bring the actual state of the cluster closer to the desired state.</p>
</li>
</ul>
<h3>Worker Node Components</h3>
<p>These components help run and manage application workloads on nodes.</p>
<ul>
<li><em>kubelet</em> — This is a <strong>node-level agent</strong> that runs on every worker node (and sometimes on control plane nodes too). It is responsible for ensuring that the Pods assigned to its node are running as expected.</li>
</ul>
<p>Before wrapping up our discussion of components, let's look at one more tool: <em>kubectl</em> (pronounced “cube control”). It is a CLI tool that we, as users or administrators, use to communicate with the API Server.</p>
<p>These are just a few high-level components that will help us understand the lifecycle of an application in Kubernetes. K8s has many other components, which we will explore in later parts of this series as and when we use them.</p>
<p>Now, it's time to bring together the components we've discussed above and see how they work together when we create a resource in K8s -</p>
<blockquote>
<p>Whenever we create a resource using <code>kubectl</code>, it sends a request to the <code>API Server</code>. The <code>API Server</code> validates the request and stores the resource's data in <code>etcd</code>. After that, different components act depending on the type of resource we created.</p>
<p>For a Pod that hasn't been assigned to a Node yet, the <code>Scheduler</code> picks it up and selects a suitable Node based on factors such as resource availability and the Pod's requirements. Meanwhile, <code>Controllers</code> continuously monitor resources and take action to bring the cluster's actual state closer to its desired state.</p>
<p>Once a Node is assigned to the Pod, the <code>kubelet</code> on that Node takes over. It works with the container runtime to ensure the Pod's containers run as expected.</p>
</blockquote>
<p>Now, comes the best part :-</p>
<h3>A Real world analogy - The City of 100 Streetlight</h3>
<hr />
<blockquote>
<p>Let us imagine Kubernetes as a system that needs to maintain 100 streetlights across the city 🌆</p>
<table>
<thead>
<tr>
<th>Component</th>
<th>Role in the City</th>
</tr>
</thead>
<tbody><tr>
<td><em>kubectl</em></td>
<td>This can be the city planner submitting a proposal "Install 100 streetlights."</td>
</tr>
<tr>
<td><em>API Server</em></td>
<td>The city’s central office that records every plan and status update. It doesn’t build anything, just coordinates communication.</td>
</tr>
<tr>
<td><em>etcd</em></td>
<td>The city’s permanent record book — stores both plans and current statuses.</td>
</tr>
<tr>
<td><em>Scheduler</em></td>
<td>The city’s logistics officer: “Put these 10 lights on Street A, 20 on Street B…” (decides placement)</td>
</tr>
<tr>
<td><em>Controller</em></td>
<td>The maintenance supervisor: “One light is broken, replace it” or “We need 100 total, only 98 exist, add 2 more.</td>
</tr>
<tr>
<td><em>kubelet</em></td>
<td>The electrician on each street — actually installs, powers, and maintains the lights assigned to that street. Reports back when lights are on or off.</td>
</tr>
</tbody></table>
<p>With this analogy, we can related how all these components stich together and help us in achieving the goal.</p>
</blockquote>
<p>With this, we come to the end of this article!</p>
<p>K8s is much, much more than what we've discussed above, but these concepts can serve as a great starting point for beginners or a quick refresher for those revisiting the basics.</p>
<p>In the upcoming articles in this series, we'll dive deeper into Kubernetes components and their inner workings, with practical examples and animations to make things easier to understand.</p>
<p><strong>Stay tuned for more!</strong></p>
<p>You can find me here - <a href="https://www.linkedin.com/in/aayushjalan">LinkedIn</a> <a href="https://www.instagram.com/aj_learnings/">Instagram</a> <a href="https://x.com/aj_learnings">Twitter(X)</a></p>
]]></content:encoded></item></channel></rss>