<?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[Kubernetes]]></description><link>https://learning-k8s.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 00:54:03 GMT</lastBuildDate><atom:link href="https://learning-k8s.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[What Actually Happens When You Run kubectl apply in Kubernetes?]]></title><description><![CDATA[We run kubectl apply command almost every day…
kubectl apply -f deployment.yaml

But have you ever wondered…
What actually happens inside Kubernetes after you hit Enter?
You are basically telling Kube]]></description><link>https://learning-k8s.hashnode.dev/what-actually-happens-when-you-run-kubectl-apply-in-kubernetes</link><guid isPermaLink="true">https://learning-k8s.hashnode.dev/what-actually-happens-when-you-run-kubectl-apply-in-kubernetes</guid><dc:creator><![CDATA[Malathi Shetty]]></dc:creator><pubDate>Wed, 25 Mar 2026 10:24:50 GMT</pubDate><content:encoded><![CDATA[<p>We run <code>kubectl apply</code> command almost every day…</p>
<pre><code class="language-plaintext">kubectl apply -f deployment.yaml
</code></pre>
<p>But have you ever wondered…</p>
<p><code>What actually happens inside Kubernetes after you hit Enter?</code></p>
<p>You are basically telling Kubernetes:</p>
<blockquote>
<p>“Hey, I want my app to run like THIS (as written in the file). Make it happen.”</p>
</blockquote>
<h1>Super Simple Analogy (Pizza Shop)</h1>
<p>Think of Kubernetes like a <strong>smart</strong> pizza shop OR pizza restaurant:</p>
<ul>
<li><p>You = Customer (kubectl)</p>
</li>
<li><p><code>deployment.yaml</code> = Your order (YAML file)</p>
</li>
<li><p>Kubernetes = Restaurant system</p>
</li>
<li><p>Pods = Chefs making pizza</p>
</li>
</ul>
<p>You’re basically saying:</p>
<blockquote>
<p>“I want my app to run like THIS. Make it happen.”</p>
</blockquote>
<h2>Step-by-step in real life terms what actually happens behind the scenes inside Kubernetes?</h2>
<p>Let’s break it down in a simple way 👇:</p>
<p>1️⃣ You send a request</p>
<p>kubectl talks to the API Server 📡<br /><code>kubectl</code> is just a client</p>
<p>You run the command.</p>
<ul>
<li><code>kubectl</code> reads the YAML file → converts it into JSON → sends request via REST API over HTTP</li>
</ul>
<p>The kubectl command sends your request (create Pod, deploy app) to the Kubernetes API Server. <code>kubectl</code> <strong>does not deploy anything itself</strong></p>
<p><strong>Analogy:</strong> You place your order at the counter</p>
<ul>
<li><p><code>kubectl</code> = You speaking</p>
</li>
<li><p>API Server = Reception desk</p>
</li>
</ul>
<p>“I want 2 pizzas like this!”</p>
<p>2️⃣ Kubernetes checks everything</p>
<p>API Server is the entry point</p>
<p>API Server validates &amp; processes the request</p>
<p>All requests go through <strong>kube-apiserver</strong><br />The API Server checks the YAML file and verifies if the configuration is valid.</p>
<p>Central communication hub</p>
<p>API server is the “front door” of the cluster.</p>
<h3>What actually happens:</h3>
<p>Before storing in etcd, Kubernetes also runs:</p>
<ul>
<li><p>Who are you? (authentication)</p>
</li>
<li><p>Are you allowed? (authorization)</p>
</li>
<li><p>Is your request valid? (admission checks) <strong>(VERY important)</strong></p>
</li>
</ul>
<p>If everything is fine → it accepts your request.</p>
<p>These can:</p>
<ul>
<li><p>modify your request (e.g., inject sidecars like Istio)</p>
</li>
<li><p>reject it (policy enforcement)</p>
</li>
</ul>
<p><code>Before persisting the request, the API server runs it through an internal request pipeline including authentication, authorization, and admission controllers.</code></p>
<p><code>Before saving, Kubernetes may also modify or enforce rules using admission controllers.</code></p>
<p><strong>Analogy:</strong> Reception checks your order</p>
<ul>
<li><p>Is it readable?</p>
</li>
<li><p>Is it valid?</p>
</li>
</ul>
<p><code>If wrong → rejected.</code></p>
<p><code>If correct → accepted</code></p>
<p>3️⃣ It saves your request</p>
<p>The <strong>desired state of resources</strong> is stored in etcd as Kubernetes objects.<br />Once validated, the desired/cluster state (source of truth) stores your Deployment in etcd (the Kubernetes database).</p>
<p>👉 Important:<br />At this point:</p>
<ul>
<li><p>Your app is <strong>NOT running</strong></p>
</li>
<li><p>No containers exist yet</p>
</li>
</ul>
<p>It’s just a saved instruction saying:<br />“Hey, I want 3 copies of this app.”</p>
<p><strong>Analogy:</strong> Order is saved in system database</p>
<ul>
<li>etcd = Restaurant’s order register</li>
</ul>
<p><strong>Important:</strong><br />This is the <strong>“desired state”</strong><br />(what you WANT)</p>
<p>4️⃣ Controllers create pods</p>
<p>Controller Manager detects changes (automatically)</p>
<p>Now the smart part.</p>
<blockquote>
<p>Controllers continuously watch the API server for changes and ensure the desired state matches the actual state. They are always <strong>watching</strong>.</p>
</blockquote>
<p>Creates/updates resources</p>
<p>Different controllers exist:</p>
<ul>
<li><p>Deployment Controller sees your request → creates a ReplicaSet</p>
</li>
<li><p>ReplicaSet Controller sees that → creates 3 Pods</p>
</li>
<li><p>Node Controller</p>
</li>
</ul>
<blockquote>
<p>At this stage, Pods are created as Kubernetes objects, but they are not yet scheduled or running on any node.</p>
</blockquote>
<p><code>Different controllers (like Deployment controller) watch the state and act accordingly.</code></p>
<p><code>Deployment → ReplicaSet → Pod</code></p>
<p><strong>Analogy:</strong> Manager checks if order is being prepared</p>
<ul>
<li><p>“Customer wants 2 pizzas”</p>
</li>
<li><p>“Do we have 2 pizzas ready?”</p>
</li>
</ul>
<p>If not → it tells staff:<br /><code>“Start making!”</code></p>
<p>5️⃣ Scheduler picks machines</p>
<p>Scheduler assigns the Pod to a Node</p>
<p>Scheduler updates the Pod’s <code>nodeName</code> field<br />The scheduler decides which worker node should run the pod.</p>
<p>👉 “Which machine should run each pod?”</p>
<p>It picks the best nodes and updates the info.</p>
<p>Still no containers running yet — just assignments.</p>
<p><strong>Analogy:</strong> Decides which chef will cook</p>
<ul>
<li><p>Which kitchen station is free?</p>
</li>
<li><p>Which has resources?</p>
</li>
</ul>
<p><code>Assigns work</code></p>
<p>6️⃣ Kubelet creates the container</p>
<p><strong>Kubelet runs the containers</strong><br />On each selected machine, the <strong>kubelet</strong>:  </p>
<ul>
<li><p>The kubelet on that node pulls the image,</p>
</li>
<li><p>starts the container and</p>
</li>
<li><p>Reports status.</p>
</li>
</ul>
<p>Kubernetes uses <strong>container runtime</strong> (like containerd, not always Docker)</p>
<p>Now the real action.</p>
<p>Each machine has a <strong>kubelet</strong>. It sees:</p>
<p>“Oh, this pod is assigned to me.”</p>
<p>So it:</p>
<ul>
<li><p>Downloads the container image</p>
</li>
<li><p>uses CNI (Container Network Interface) for networking and CSI (Container Storage Interface) for storage</p>
</li>
<li><p>Starts the container</p>
</li>
</ul>
<p>Now your app is finally running!</p>
<p><strong>Analogy:</strong> Actual chef starts cooking</p>
<ul>
<li><p>Pulls ingredients (container image)</p>
</li>
<li><p>Starts making pizza (container)</p>
</li>
</ul>
<h2>Key idea (very important)</h2>
<ul>
<li><p>Everything goes through the <strong>API server</strong></p>
</li>
<li><p>Most control-plane components communicate via the API server, ensuring loose coupling. i.e Some components <strong>do have direct communication paths</strong> (e.g., kubelet → container runtime)</p>
</li>
<li><p>Each one just watches and does its job</p>
</li>
</ul>
<h2>One-line takeaway</h2>
<p><code>kubectl apply</code> doesn’t run your app — it just tells Kubernetes what you want, and Kubernetes makes it happen step by step.</p>
<hr />
<h2>Flow: Event-driven nature (not linear)</h2>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/ca127590-bbb6-40f2-be8d-0297662bbcee.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/8f0fb3e5-d2c0-416a-a118-78fa1563d76c.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/e23365ed-b7cb-440a-b7ca-6194311eb4e9.png" alt="" style="display:block;margin:0 auto" />

<h2>Who’s involved (in simple terms)</h2>
<p>Think of Kubernetes like a system with different workers:</p>
<ul>
<li><p><strong>kubectl</strong> → Just a messenger. It sends your request.</p>
</li>
<li><p><strong>API server</strong> → The main gatekeeper. Everything goes through here.</p>
</li>
<li><p><strong>etcd</strong> → The database. It stores everything.</p>
</li>
<li><p><strong>Controllers</strong> → The “brains” that figure out what needs to be created.</p>
</li>
<li><p><strong>Scheduler</strong> → Picks which machine should run your app.</p>
</li>
<li><p><strong>Kubelet</strong> → The worker on each machine that actually runs containers.</p>
</li>
</ul>
<p>Reality:</p>
<ul>
<li><p>It’s <strong>event-driven + continuous</strong></p>
</li>
<li><p>Controllers are always watching</p>
</li>
<li><p>Not a one-time chain</p>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/ef4c2cab-edfa-42db-bb2f-f806977394b9.png" alt="" style="display:block;margin:0 auto" />

<p>Most components communicate via the API server, ensuring loose coupling.</p>
<h2>The big idea (most important part)</h2>
<p>Here’s the surprising truth:</p>
<ul>
<li><p>The <strong>Controller Manager does NOT directly talk to Kubelet</strong></p>
</li>
<li><p>Most Kubernetes components interact through the API server, though some internal components (like kubelet and container runtime) communicate directly.</p>
</li>
<li><p>Everything goes through the API server.</p>
<ul>
<li><p>Watches cluster state via the API server (which reads from etcd)</p>
</li>
<li><p>Sends updates <strong>back to API Server -</strong> Everyone <strong>writes back to it</strong></p>
</li>
</ul>
</li>
</ul>
<p>It’s like a shared notice board.</p>
<ul>
<li><p>Then:</p>
<ul>
<li><p><strong>Scheduler</strong> assigns pods</p>
</li>
<li><p><strong>Kubelet</strong> reads instructions from <strong>API Server</strong></p>
</li>
</ul>
</li>
</ul>
<p>👉 So the <strong>API Server is the central hub</strong> — everything connects <em>through it</em>.</p>
<p><code>This is not a one-time flow — Kubernetes continuously watches and reacts.</code></p>
<h3>But the REAL truth:</h3>
<ul>
<li><p>Nothing runs instantly</p>
</li>
<li><p>Nothing runs directly</p>
</li>
<li><p>Everything goes through <strong>API Server</strong></p>
</li>
<li><p>Everything is <strong>watched continuously</strong></p>
</li>
</ul>
<p><code>You declare → Kubernetes stores → Controllers notice → System fixes → Repeat forever</code></p>
<blockquote>
<p>Kubernetes is NOT executing commands<br />It is continuously correcting reality to match your YAML</p>
</blockquote>
<h2>Easy analogy (post office)</h2>
<p>Think of it like sending a package:</p>
<ol>
<li><p>You submit a request (kubectl)</p>
</li>
<li><p>Post office accepts it (API server)</p>
</li>
<li><p>It gets recorded (etcd)</p>
</li>
<li><p>Workers prepare packages (controllers)</p>
</li>
<li><p>Planner assigns delivery trucks (scheduler)</p>
</li>
<li><p>Drivers deliver it (kubelet runs containers)</p>
</li>
</ol>
<p>Components don’t directly call each other — they just check the system and do their job.</p>
<h2>Key takeaway</h2>
<ul>
<li><p><code>kubectl apply</code> doesn’t run anything</p>
</li>
<li><p>It just <strong>declares what you want</strong></p>
</li>
<li><p>Kubernetes slowly makes it real, step by step</p>
</li>
</ul>
<h2>Final Result:</h2>
<p>✔ Pod gets created<br />✔ Container starts running<br />✔ Application becomes available<br />✔ Deployment successful</p>
<p>DevOps Insight:</p>
<p>Kubernetes always works on the concept of:<br />Desired State vs Actual State</p>
<p>Desired State = What you wrote in YAML<br />Actual State = What is really running</p>
<p>Kubernetes constantly checks:</p>
<blockquote>
<p>“Are these equal?”</p>
</blockquote>
<p>If not:<br />👉 It automatically fixes it</p>
<p><strong>Kubernetes doesn’t care what you ran.<br />It only cares what you WANT.</strong></p>
<h1>Example (super simple)</h1>
<p>You said:</p>
<p>“Run 3 copies of my app”</p>
<p>But 1 crashes</p>
<p>Kubernetes says:<br />“You wanted 3… I see only 2… let me create 1 more.”</p>
<p>That’s the power.</p>
<hr />
<h1>One-line summary</h1>
<p>👉 <code>kubectl apply</code> is not just a command —<br />it starts a <strong>chain reaction inside Kubernetes</strong> that makes your app run automatically.</p>
<p>Controllers continuously work to make the cluster match the desired configuration.</p>
<p>If you're working with Kubernetes daily, this simple command actually triggers multiple components inside the cluster</p>
<hr />
<h2>kubectl apply in 10 seconds</h2>
<pre><code class="language-plaintext">You don’t run containers.
You declare a state.
Kubernetes makes it true.
</code></pre>
<hr />
<p>“Now that we understand the basic flow, let’s go one level deeper into what actually happens behind the scenes"</p>
<ol>
<li>Apply Strategy (3-Way Merge)</li>
</ol>
<p>One critical detail often overlooked is how kubectl apply actually updates resources.</p>
<p>It uses a 3-way merge strategy involving:</p>
<pre><code class="language-plaintext">It uses a 3-way merge strategy involving:

• Last applied configuration
(stored as last-applied-configuration annotation for client-side apply, or managed fields for server-side apply)

• Current live state in the cluster

• New configuration from your YAML
</code></pre>
<p><code>This allows Kubernetes to:</code></p>
<p><code>• Apply only the changes you’ve made   • Avoid overwriting fields managed by other controllers or users</code></p>
<p>2. Admission Controllers</p>
<p>Before your request is persisted, it passes through admission controllers, which are critical in real-world clusters.</p>
<p>There are two main types:</p>
<p>Mutating Admission Controllers Modify requests (e.g., injecting sidecars like service meshes) Validating Admission Controllers Enforce policies and can reject requests</p>
<p>These controllers can:</p>
<p>Automatically alter your resource definitions Completely block deployments</p>
<p>In production, this layer is often where security and compliance policies are enforced.</p>
<p><strong>Examples</strong>:</p>
<ul>
<li><p>PodSecurity</p>
</li>
<li><p>ResourceQuota</p>
</li>
<li><p>LimitRanger</p>
</li>
</ul>
<p>3. Watches &amp; Informers Are Not Emphasized</p>
<p>The system is not a direct chain of calls between components.</p>
<p>Instead:</p>
<p>Components do not call each other directly They communicate via: Watches (event streams from the API server) Shared state (stored in etcd)</p>
<p>For example:</p>
<p>Controllers watch for changes instead of being “triggered”</p>
<p>This is a fundamental architectural concept that explains how Kubernetes remains loosely coupled and scalable.</p>
<p>4. Not a Linear Flow — It’s Event-Driven</p>
<p>The process is often described as a step-by-step pipeline, but in reality:</p>
<p>Kubernetes is event-driven and asynchronous</p>
<p>This entire Controllers process run by reconciliation loops that continuously push the system toward the desired state.</p>
<p>This means:</p>
<p>State changes propagate over time, not instantly Multiple components act independently</p>
<p>This explains real-world behaviors like delays, retries, and eventual consistency.</p>
<p>5. API Semantics (PATCH vs POST vs PUT)</p>
<p>kubectl apply is not always creating resources.</p>
<p>kubectl apply typically sends a PATCH request, but may use POST for creation if the resource does not exist.</p>
<p>This enables:</p>
<p>Incremental updates Field-level changes instead of full replacements</p>
<p>👉 Understanding this is key for debugging conflicts and API behavior.</p>
<p>6. Missing Real-World Failure Scenarios</p>
<p>The article focuses on the “happy path,” but real systems often fail in different ways:</p>
<p><code>Common issues include:</code></p>
<p><code>• ImagePullBackOff – container image cannot be fetched   • Pending Pods – scheduler cannot find a suitable node   • CrashLoopBackOff – application keeps failing   • Resource constraints – insufficient CPU/memory</code></p>
<p>👉 These scenarios are essential for troubleshooting and operating Kubernetes in production.</p>
<p>💡 Final Thought</p>
<p>The high-level flow is correct, but Kubernetes is far more nuanced under the hood. Understanding these deeper concepts is what separates basic familiarity from production-ready expertise.</p>
<p>There can be slight delays between each step due to the asynchronous and distributed nature of Kubernetes.</p>
<p>Kubernetes is eventually consistent, not instantly consistent.</p>
<p><code>You can observe this flow using:</code></p>
<ul>
<li><p><code>kubectl describe pod</code></p>
</li>
<li><p><code>kubectl get events</code></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Why does Kubernetes ignore failures… and then suddenly restart everything?]]></title><description><![CDATA[Not everything that looks like failure in Kubernetes is actually a failure.
Sometimes it's just configuration (rules), not a real error.

What confused me?
While debugging a Pod, I saw this:

Liveness]]></description><link>https://learning-k8s.hashnode.dev/why-does-kubernetes-ignore-failures-and-then-suddenly-restart-everything</link><guid isPermaLink="true">https://learning-k8s.hashnode.dev/why-does-kubernetes-ignore-failures-and-then-suddenly-restart-everything</guid><category><![CDATA[Kubernetes liveness probe explained]]></category><category><![CDATA[readiness probe vs liveness]]></category><category><![CDATA[failureThreshold Kubernetes]]></category><category><![CDATA[CrashLoopBackOff explained]]></category><dc:creator><![CDATA[Malathi Shetty]]></dc:creator><pubDate>Wed, 25 Mar 2026 05:00:59 GMT</pubDate><content:encoded><![CDATA[<p><strong>Not everything that looks like failure in Kubernetes is actually a failure.</strong></p>
<p>Sometimes it's just <strong>configuration (rules), not a real error.</strong></p>
<hr />
<h2>What confused me?</h2>
<p>While debugging a Pod, I saw this:</p>
<ul>
<li><p><code>Liveness: tcp-socket :80 delay=15s timeout=1s period=20s #success=1 #failure=3</code></p>
</li>
<li><p><code>Readiness: tcp-socket :80 delay=5s timeout=1s period=10s #success=1 #failure=3</code></p>
</li>
</ul>
<p>At first glance, it looked scary.</p>
<p><code>#success=1 #failure=3</code></p>
<p>It looks like(Failure History):<br />“Oh no, the Pod already failed 3 times!”</p>
<p>But that’s wrong.</p>
<p>It actually means (Threshold Rule):<br /><strong>“Fail 3 times in a row BEFORE taking action”</strong></p>
<blockquote>
<p>Kubernetes doesn’t react to single failures — it evaluates patterns over time using defined thresholds.</p>
<p>Those numbers are rules, not history.</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/aa71e647-5f52-42a1-abc7-ca1979b7f250.png" alt="" style="display:block;margin:0 auto" />

<h3>What is <code>tcp-socket :80</code> in Kubernetes?</h3>
<pre><code class="language-plaintext">tcp-socket :80
</code></pre>
<p>It means:</p>
<blockquote>
<p>Kubernetes is trying to <strong>open a TCP connection to port 80</strong> on the container.</p>
</blockquote>
<hr />
<h3>Simple meaning</h3>
<ul>
<li><p><strong>TCP</strong> → basic network connection (like “can I reach you?”)</p>
</li>
<li><p><strong>port 80</strong> → where your app is expected to listen (usually HTTP)</p>
</li>
</ul>
<p>So Kubernetes is asking:</p>
<blockquote>
<p>“Can I connect to this container on port 80?”</p>
</blockquote>
<p>What each field means (quick decode):</p>
<pre><code class="language-plaintext">delay=15s → wait before first check 
timeout=1s → max time for probe response 
period=20s → check every 20 seconds 
#failure=3 → fail 3 times → action 
#success=1 → 1 success → mark healthy
</code></pre>
<hr />
<p>⚙️ <strong>What are Liveness &amp; Readiness?</strong></p>
<p>🔹 <strong>Liveness Probe</strong></p>
<ul>
<li><p>Checks: “Is the container alive?”</p>
</li>
<li><p>If it fails <strong>3 times continuously</strong> → Kubernetes <strong>restarts the container</strong></p>
</li>
</ul>
<p>Like checking if an app is frozen and restarting it.</p>
<p>🔹 <strong>Readiness Probe</strong></p>
<ul>
<li><p>Checks: “Is the container ready to serve traffic?”</p>
</li>
<li><p>If it fails <strong>3 times continuously</strong> → Kubernetes <strong>stops sending traffic to it</strong></p>
</li>
</ul>
<p>Like removing a sick player from a match.</p>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/5ccd5581-4af3-46d6-a9f9-84b9ab4703d9.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><p>Liveness = “Should I restart?”</p>
</li>
<li><p>Readiness = “Should I send traffic?”</p>
</li>
</ul>
<hr />
<p><strong>The Important Detail</strong></p>
<p><code>#failure=3</code> means:</p>
<p>NOT: “failed 3 times already”</p>
<p>YES: “will tolerate up to 3 failures before acting”</p>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/c4c31493-851d-4573-92c4-1d59ff818197.png" alt="" style="display:block;margin:0 auto" />

<h2>When does Kubernetes actually take action?</h2>
<p>Understanding the threshold is not enough — timing also matters.</p>
<p>Kubernetes waits based on this formula:</p>
<p><code>Action Time = failureThreshold × periodSeconds</code></p>
<h3>Example</h3>
<pre><code class="language-plaintext">failureThreshold = 3  
periodSeconds = 10
</code></pre>
<p>Kubernetes waits <strong>30 seconds</strong> before taking action</p>
<h3>What happens during that time?</h3>
<ul>
<li><p>1st check → fail<br />(wait 10 secs)</p>
</li>
<li><p>2nd check → fail<br />(wait 10 secs)</p>
</li>
<li><p>3rd check → fail<br />➡️ Now Kubernetes acts</p>
</li>
</ul>
<blockquote>
<p>Kubernetes is a control system — it continuously evaluates state and acts only when thresholds are crossed.</p>
</blockquote>
<hr />
<h3>What action does Kubernetes take?</h3>
<blockquote>
<p>Liveness → restart the container</p>
<p>Readiness → stop sending traffic</p>
</blockquote>
<hr />
<h3><strong>Why this matters</strong></h3>
<ul>
<li><p>Your app might fail briefly and still be fine</p>
</li>
<li><p>Kubernetes gives it time before reacting</p>
</li>
</ul>
<p>This is part of its <strong>fault tolerance design</strong></p>
<p>If you misunderstand this, you might:</p>
<ul>
<li><p>Panic unnecessarily</p>
</li>
<li><p>Debug the wrong thing</p>
</li>
<li><p>Waste time chasing “fake errors”</p>
</li>
</ul>
<hr />
<p><strong>Where you SHOULD actually check</strong></p>
<p>Instead of focusing on that line alone:</p>
<p><strong>1. Check events</strong><br /><code>kubectl describe pod</code></p>
<p>Look for: <strong>"Unhealthy"</strong></p>
<p><strong>2. Check pod status</strong></p>
<p><code>kubectl get pods</code></p>
<p>Look at: <strong>READY</strong> column</p>
<p><strong>3. Check service issues</strong></p>
<p>If a service has no endpoints:</p>
<ul>
<li><p>Readiness probe may be failing</p>
</li>
<li><p>OR labels don’t match</p>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/6dee4789-bc1a-42b9-b46a-077c0e1d2a98.png" alt="" style="display:block;margin:0 auto" />

<hr />
<p><strong>Big Lesson (Very Important)</strong></p>
<p><strong>Kubernetes doesn’t react instantly — it waits and tolerates some failure.</strong></p>
<p>This is called:</p>
<p>➡️ <strong>Fault tolerance</strong></p>
<p>Meaning:</p>
<ul>
<li><p>One failure = OK</p>
</li>
<li><p>Two failures = still OK</p>
</li>
<li><p>Three failures in a row = now action</p>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/703fb8cc-081d-4a9b-97b0-43fffb2eeafd.png" alt="" style="display:block;margin:0 auto" />

<hr />
<p><strong>Simple Analogy</strong></p>
<p>Think of it like alarms:</p>
<ul>
<li><p>You don’t call the fire brigade for 1 spark</p>
</li>
<li><p>You wait until it’s clearly a fire</p>
</li>
</ul>
<p>Kubernetes does the same.</p>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/39071e63-70ae-45c3-9dc3-4cecf2e5a3d8.png" alt="" style="display:block;margin:0 auto" />

<hr />
<p>One-Line Takeaway</p>
<p><strong>Those numbers are rules, not history — they define when Kubernetes acts, not what already happened.</strong></p>
<p><strong>Debug real failures, not configuration.</strong></p>
<hr />
<h2>Final Thought</h2>
<p>Kubernetes is <strong>deliberately patient</strong>, not slow.<br />That patience is what gives you fault tolerance.</p>
<p>Kubernetes delays action intentionally — it only acts after the failure threshold is exceeded.<br />Understanding this saves a lot of debugging time.</p>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/2bedd436-fcdb-4445-8e5d-e9c8c3aa8956.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h2>Real-World Examples (Simple &amp; Practical)</h2>
<p>Here’s how these concepts show up in real production issues:</p>
<hr />
<h3>1. App/Pod Keeps Restarting (Liveness Probe)</h3>
<p><strong>What you see:</strong><br />Your Pod keeps restarting again and again.</p>
<p><strong>What’s happening:</strong></p>
<ul>
<li><p>Your app gets stuck (maybe infinite loop, deadlock, or crash)</p>
</li>
<li><p>Liveness probe checks: “Are you alive?”</p>
</li>
<li><p>It fails 3 times consecutively → Kubernetes restarts the container</p>
</li>
</ul>
<p>Like force-closing a frozen mobile app</p>
<p><strong>Important:</strong><br />This is NOT Kubernetes failing</p>
<p>It’s Kubernetes trying to <strong>fix your app automatically</strong></p>
<hr />
<h3>2. App Running But No Traffic (Readiness Probe)</h3>
<p><strong>What you see:</strong></p>
<ul>
<li><p>Pod is running</p>
</li>
<li><p>But users can’t access your app</p>
</li>
</ul>
<p><strong>What’s happening:</strong></p>
<ul>
<li><p>Readiness probe checks: “Are you ready?”</p>
</li>
<li><p>Your app is slow / still starting / DB not connected</p>
</li>
<li><p>It fails 3 times consecutively → Kubernetes stops sending traffic</p>
</li>
</ul>
<p>Like a restaurant that is open but not ready to serve customers yet</p>
<hr />
<h3>3. CrashLoopBackOff (Common Confusion)</h3>
<p><strong>What you see:</strong></p>
<pre><code class="language-plaintext">CrashLoopBackOff
</code></pre>
<p>Looks scary</p>
<p><strong>What’s actually happening:</strong></p>
<ul>
<li><p>Your app crashes on startup (bad config, wrong env variables, etc.)</p>
</li>
<li><p>Liveness keeps restarting it</p>
</li>
<li><p>It fails again → restart → fail → restart…</p>
</li>
</ul>
<ol>
<li><p>Loop continues → CrashLoopBackOff  </p>
<p><strong><mark class="bg-yellow-200 dark:bg-yellow-500/30">Kubernetes is NOT the problem<br />Your app/config is the problem</mark></strong></p>
</li>
</ol>
<hr />
<h3>4. Service Not Working (No Endpoints)</h3>
<p><strong>What you see:</strong></p>
<ul>
<li><p>Service exists</p>
</li>
<li><p>But no traffic reaches your Pod</p>
</li>
</ul>
<p><strong>What’s happening:</strong></p>
<ul>
<li><p>Readiness probe is failing</p>
<p><strong>OR</strong></p>
</li>
<li><p>Labels don’t match</p>
</li>
</ul>
<ol>
<li><p>Kubernetes removes your Pod from traffic</p>
</li>
<li><p>Like a delivery app hiding a restaurant that isn’t ready</p>
</li>
</ol>
<hr />
<h2>Simple Summary</h2>
<table>
<thead>
<tr>
<th>Situation</th>
<th>What You Think</th>
<th>What’s Actually Happening</th>
</tr>
</thead>
<tbody><tr>
<td>Restarting Pod</td>
<td>Kubernetes broken</td>
<td>Liveness fixing stuck app</td>
</tr>
<tr>
<td>No traffic</td>
<td>Service issue</td>
<td>Readiness blocking traffic</td>
</tr>
<tr>
<td>CrashLoopBackOff</td>
<td>System failure</td>
<td>App crashing repeatedly</td>
</tr>
<tr>
<td>#failure=3</td>
<td>Already failed</td>
<td>Threshold before action</td>
</tr>
</tbody></table>
<pre><code class="language-plaintext">Real-world mapping:

- Readiness failing → No traffic
- Liveness failing → Restarts / CrashLoopBackOff
- Service mismatch → No endpoints
</code></pre>
<hr />
<h2>Final Insight</h2>
<ul>
<li><p>Kubernetes is not failing randomly</p>
</li>
<li><p>It is <strong>protecting your system using rules</strong></p>
</li>
</ul>
<p>Once you understand this, debugging becomes much easier:</p>
<ul>
<li><p>You stop panicking</p>
</li>
<li><p>You debug faster</p>
</li>
<li><p>You fix the real problem</p>
</li>
</ul>
<hr />
<h1>Real Production Troubleshooting Checklist</h1>
<hr />
<h2>Step-by-Step Kubernetes Debugging Checklist</h2>
<h3>1. Check Pod Status</h3>
<pre><code class="language-plaintext">kubectl get pods
</code></pre>
<p>Look for:</p>
<ul>
<li><p>Restarting?</p>
</li>
<li><p>Not ready?</p>
</li>
<li><p>CrashLoopBackOff?</p>
</li>
</ul>
<hr />
<h3>2. If Restarting → Check Liveness</h3>
<p>Ask:</p>
<ul>
<li><p>Is app crashing?</p>
</li>
<li><p>Infinite loop?</p>
</li>
<li><p>Memory/CPU issue?</p>
</li>
</ul>
<p>Fix:</p>
<ul>
<li><p>Logs</p>
</li>
<li><p>App bug</p>
</li>
<li><p>Config issue</p>
</li>
</ul>
<hr />
<h3>3. If Running But Not Working → Check Readiness</h3>
<p>Ask:</p>
<ul>
<li><p>App still starting?</p>
</li>
<li><p>DB/API not connected?</p>
</li>
<li><p>Health endpoint failing?</p>
</li>
</ul>
<p>Fix:</p>
<ul>
<li><p>Increase delay</p>
</li>
<li><p>Fix dependencies</p>
</li>
<li><p>Check <code>/health</code> endpoint</p>
</li>
</ul>
<hr />
<h3>4. If CrashLoopBackOff</h3>
<p>Most common causes:</p>
<ul>
<li><p>Wrong environment variables</p>
</li>
<li><p>Missing secrets</p>
</li>
<li><p>Bad config</p>
</li>
</ul>
<p>Rule:<br /><strong>Kubernetes is restarting → your app is failing</strong></p>
<hr />
<h3>5. If No Traffic</h3>
<p>Ask:</p>
<ul>
<li><p>Service connected?</p>
</li>
<li><p>Labels correct?</p>
</li>
</ul>
<p>👉 Check:</p>
<pre><code class="language-plaintext">kubectl get svc
kubectl get endpoints
</code></pre>
<hr />
<h3>6. Always Check Logs</h3>
<pre><code class="language-plaintext">kubectl logs &lt;pod-name&gt;
</code></pre>
<p>This tells the <em>real story</em></p>
<hr />
<h3>7. Golden Rule</h3>
<p>Don’t panic at config output</p>
<p>Instead ask:</p>
<ul>
<li><p>Is it restarting?</p>
</li>
<li><p>Is it serving traffic?</p>
</li>
<li><p>Is it actually broken?</p>
</li>
</ul>
<hr />
<h1>Summary:</h1>
<p>If someone asks: <strong>“How do you debug a failing Pod?”</strong></p>
<p>You can say:</p>
<ol>
<li><p>Check Pod status</p>
</li>
<li><p>If restarting → Liveness issue</p>
</li>
<li><p>If no traffic → Readiness issue</p>
</li>
<li><p>If crashing (CrashLoopBackOff) → logs/config issue</p>
</li>
<li><p>If no endpoints → service/labels mismatch</p>
</li>
</ol>
<blockquote>
<p>kubectl get pods</p>
<p>kubectl describe pod </p>
<p>kubectl logs </p>
<p>kubectl get svc</p>
<p>kubectl get endpoints</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/68384e70844acdda2b275fa7/60028d6e-3430-4488-93e9-74d795ca2f76.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h1>One-Line Power Statement</h1>
<blockquote>
<p>“Kubernetes doesn’t fail randomly — it enforces rules with patience. Your job is to understand which rule is being triggered.”</p>
<p>Next time you see a failure in Kubernetes,</p>
<p>don’t ask: “Why did it fail?”</p>
<p>Ask: “Which rule is being triggered?”</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[1. Kubernetes Architecture]]></title><description><![CDATA[Kubernetes architecture is actually very straightforward once you split it into two parts –1. Control Plane2. Worker NodesTogether they form the Cluster.

CONTROL PLANE — This is the brain of the cluster
1. API Server
This is the central communicatio...]]></description><link>https://learning-k8s.hashnode.dev/1-kubernetes-architecture</link><guid isPermaLink="true">https://learning-k8s.hashnode.dev/1-kubernetes-architecture</guid><category><![CDATA[kubernetes architecture]]></category><dc:creator><![CDATA[Malathi Shetty]]></dc:creator><pubDate>Mon, 17 Nov 2025 08:34:07 GMT</pubDate><content:encoded><![CDATA[<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1763367875246/22c27572-a121-452e-b553-efc7dd3f97ee.png" alt class="image--center mx-auto" /></p>
<p><strong>Kubernetes architecture is actually very straightforward once you split it into two parts –</strong><br /><strong>1. Control Plane</strong><br /><strong>2. Worker Nodes</strong><br />Together they form the <strong>Cluster</strong>.</p>
<hr />
<h2 id="heading-control-plane-this-is-the-brain-of-the-cluster"><strong>CONTROL PLANE — This is the brain of the cluster</strong></h2>
<h3 id="heading-1-api-server"><strong>1. API Server</strong></h3>
<p>This is the <strong>central communication point</strong> (Heart of the Cluster) of Kubernetes.<br />Everything — kubectl commands, controllers, kubelets — talks to the API Server.</p>
<p>It:</p>
<ul>
<li><p>Receives and validates every request</p>
</li>
<li><p>Talks to etcd to read/update cluster data</p>
</li>
<li><p>Ensures everyone communicates in a standard format</p>
</li>
</ul>
<p>So if I run:</p>
<pre><code class="lang-bash">kubectl get pods
</code></pre>
<p>the API Server handles that entire request.</p>
<hr />
<h3 id="heading-2-etcd"><strong>2. etcd</strong></h3>
<p>This is the <strong>database of Kubernetes</strong>.<br />It stores the <strong>entire cluster state</strong>, including:</p>
<ul>
<li><p>Pods</p>
</li>
<li><p>Deployments</p>
</li>
<li><p>Services</p>
</li>
<li><p>Secrets / ConfigMaps</p>
</li>
<li><p>Node information</p>
</li>
</ul>
<p>Anything the API Server needs, it reads or writes from etcd.</p>
<hr />
<h3 id="heading-3-scheduler"><strong>3. Scheduler</strong></h3>
<p>The Scheduler looks for <strong>Pods that are not yet assigned to a Node</strong>.</p>
<p>It decides:</p>
<ul>
<li><p>Which Pod should run on which Node</p>
</li>
<li><p>Based on CPU, memory, taints, affinity, etc.</p>
</li>
</ul>
<p>Once it picks a node, it updates the API Server so the plan is recorded in etcd.</p>
<hr />
<h3 id="heading-4-controller-manager"><strong>4. Controller Manager</strong></h3>
<p>Controller Manager ensures that the <strong>desired state = actual state</strong>.<br />It continuously watches the cluster.</p>
<p><strong>Example:</strong></p>
<ul>
<li><p>If a Pod crashes, the Controller Manager will recreate it automatically.</p>
</li>
<li><p>If a node dies, it reschedules pods somewhere else.</p>
</li>
<li><p>It basically keeps the cluster healthy and stable.</p>
</li>
</ul>
<hr />
<h3 id="heading-5-cloud-controller-manager"><strong>5. Cloud Controller Manager</strong></h3>
<p>This component talks to <strong>cloud provider APIs</strong><br />(AWS, Azure, GCP, DigitalOcean, etc.)</p>
<p>It manages:</p>
<ul>
<li><p>Load balancers</p>
</li>
<li><p>Volumes (EBS, Persistent Disks)</p>
</li>
<li><p>Node lifecycle (add/remove nodes)</p>
</li>
</ul>
<p>It is what lets Kubernetes work smoothly in the cloud.</p>
<hr />
<h1 id="heading-worker-node-this-is-where-applications-run"><strong>WORKER NODE — This is where applications run</strong></h1>
<p>Each Worker Node hosts <strong>Pods</strong>, and has three main components.</p>
<hr />
<h3 id="heading-1-kubelet"><strong>1. Kubelet</strong></h3>
<p>This is the <strong>node agent</strong>.</p>
<p>It:</p>
<ul>
<li><p>Talks to API Server</p>
</li>
<li><p>Makes sure containers are running as expected</p>
</li>
<li><p>Reports issues back to Control Plane</p>
</li>
</ul>
<p>If a container fails, kubelet will restart or report it.</p>
<hr />
<h3 id="heading-2-container-runtime-interface-cri"><strong>2. Container Runtime Interface (CRI)</strong></h3>
<p>This is the engine that <strong>actually runs containers</strong>.</p>
<p>Examples:</p>
<ul>
<li><p>Docker</p>
</li>
<li><p>containerd</p>
</li>
<li><p>CRI-O</p>
</li>
</ul>
<p>Kubelet uses this runtime to create and manage containers.</p>
<hr />
<h3 id="heading-3-kube-proxy"><strong>3. kube-proxy</strong></h3>
<p>This handles <strong>networking</strong> inside the node.</p>
<p>It:</p>
<ul>
<li><p>Manages forwarding rules</p>
</li>
<li><p>Ensures Pod-to-Pod communication</p>
</li>
<li><p>Enables access to Services</p>
</li>
</ul>
<p>Without kube-proxy, nothing in the cluster could talk to each other.</p>
<hr />
<h3 id="heading-4-pods"><strong>4. Pods</strong></h3>
<p>These are the <strong>smallest deployable units</strong> in Kubernetes.<br />A Pod may contain:</p>
<ul>
<li><p>1 container</p>
</li>
<li><p>or multiple tightly coupled containers</p>
</li>
</ul>
<p>Applications <em>actually run inside Pods</em>.</p>
<p>Overall, Kubernetes works because the Control Plane makes decisions and maintains cluster state,<br />and the Worker Nodes focus on running workloads.<br />This separation is what gives Kubernetes reliability, self-healing and scalability.</p>
<hr />
<h2 id="heading-questions-using-same-answer"><strong>Questions using SAME ANSWER:</strong></h2>
<ol>
<li><p>Explain Kubernetes architecture and its components.</p>
</li>
<li><p>Explain Control Plane vs Data Plane architecture.</p>
</li>
<li><p>What components run on the Control Plane?</p>
</li>
<li><p>What components run on Worker Nodes?</p>
</li>
<li><p>Explain EKS architecture (because EKS = same K8s architecture + managed control plane).</p>
</li>
</ol>
<p>➡️ <strong>One architecture answer covers all these.</strong></p>
<p><strong>Core Answer:</strong><br />Control Plane components (API server, etcd, scheduler, controller-manager) +<br />Worker Node components (kubelet, kube-proxy, container runtime).</p>
<p>Explain Kubernetes architecture in a simple way in interview:</p>
<p>Kubernetes mainly has <strong>two big parts</strong> — the <strong>Control Plane</strong>, which is like the brain, and the <strong>Worker Nodes</strong>, where your actual applications run. Together, all of this forms the <strong>Kubernetes cluster</strong>.</p>
<p>Starting with the <strong>Control Plane</strong>:</p>
<p>The most important component is the <strong>API Server</strong>. Think of it as the heart or the communication center. Every request — whether it’s coming from <code>kubectl</code>, from another component, or even from automation tools — goes through the API Server. It talks to <strong>etcd</strong>, which is the cluster’s database. etcd stores everything about the cluster: pods, secrets, configmaps, services, deployments — basically the entire state.</p>
<p>Then we have the <strong>Scheduler</strong>. Its job is simple: whenever a new Pod is created, the Scheduler decides which worker node it should run on. The decision is based on resource availability like CPU, memory, taints, affinity, etc.</p>
<p>Next is the <strong>Controller Manager</strong>. This component continuously watches the cluster’s desired state versus the actual state. If something drifts — like a Pod crashes — the controller manager steps in to fix it. It ensures the cluster maintains the state defined in our manifests.</p>
<p>Now, on the <strong>Worker Node</strong> side:</p>
<p>Each node has a <strong>kubelet</strong>, which is the main agent. kubelet ensures that the containers described by the API Server actually run on the node. If something is wrong, kubelet reports it back.</p>
<p>The next part is the <strong>Container Runtime</strong>, like Docker, containerd, or CRI-O — this is the software that actually runs our containers.</p>
<p>We also have <strong>kube-proxy</strong>, which handles networking on the node. It makes sure Pods can talk to each other and to Services by managing the necessary routing rules.</p>
<p>Finally, the Node runs <strong>Pods</strong>, which are the smallest deployable units in Kubernetes. A Pod may contain one or more containers that always run together on the same node.</p>
<p>In summary, Kubernetes provides a very resilient and self-healing architecture. The Control Plane decides <em>what</em> should happen, and the Worker Nodes execute <em>how</em> it should happen. Because of this separation, Kubernetes can auto-restart Pods, scale applications, and roll out updates smoothly — even when things fail.</p>
]]></content:encoded></item></channel></rss>