<?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 Shahzad Ali Ahmad on Medium]]></title>
        <description><![CDATA[Stories by Shahzad Ali Ahmad on Medium]]></description>
        <link>https://medium.com/@shahzadaliahmad?source=rss-1a09a3d5d4e8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ng5b1btlnQdvQODrzLtXZA.jpeg</url>
            <title>Stories by Shahzad Ali Ahmad on Medium</title>
            <link>https://medium.com/@shahzadaliahmad?source=rss-1a09a3d5d4e8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:25:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shahzadaliahmad/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[How Labels and Selectors Power Everything in Kubernetes]]></title>
            <link>https://medium.com/@shahzadaliahmad/how-labels-and-selectors-power-everything-in-kubernetes-571841229eb9?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/571841229eb9</guid>
            <category><![CDATA[kubestronaut]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cka]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Fri, 26 Jun 2026 02:39:22 GMT</pubDate>
            <atom:updated>2026-06-26T02:39:22.859Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKISlR1eIbp6xn9vb0yfSA.png" /><figcaption><strong>Labels and Selectors are the invisible glue that powers Kubernetes. Learn how they connect Pods, Services, Deployments, and much more.</strong></figcaption></figure><p><em>The simple Kubernetes concept that quietly connects Pods, Services, Deployments, and almost every other resource.</em></p><h3>Introduction</h3><p>If someone asked me:</p><blockquote><strong><em>“What’s the most underrated feature in Kubernetes?”</em></strong></blockquote><p>My answer would be:</p><p><strong>Labels and Selectors.</strong></p><p>They don’t run containers.</p><p>They don’t schedule Pods.</p><p>They don’t expose applications.</p><p>They don’t manage networking.</p><p>Yet without them…</p><p>Almost <strong>nothing in Kubernetes would work the way it does today.</strong></p><p>Services wouldn’t know which Pods to send traffic to.</p><p>Deployments couldn’t manage Pods.</p><p>ReplicaSets wouldn’t know how many Pods they own.</p><p>Network Policies couldn’t identify workloads.</p><p>Monitoring tools couldn’t organize metrics.</p><p>Even your own automation scripts would become much harder to build.</p><p>In fact, Labels and Selectors form the <strong>foundation of how Kubernetes resources discover, group, and interact with each other</strong>. They enable Kubernetes to remain dynamic and flexible, allowing components to scale, restart, and move across nodes without breaking connectivity or relationships.</p><p>In this article, we’ll explore why Labels and Selectors are one of the most important concepts in Kubernetes and how they quietly power almost everything happening inside your cluster.</p><h3>Imagine a Warehouse Without Labels</h3><p>Imagine walking into a warehouse containing thousands of boxes.</p><p>Every box looks identical.</p><p>Now someone asks:</p><blockquote><em>“Can you find the production web servers?”</em></blockquote><p>Impossible.</p><p>Then they ask:</p><blockquote><em>“Find every database.”</em></blockquote><p>Still impossible.</p><p>Now imagine every box has labels.</p><pre>Application = Frontend</pre><pre>Environment = Production</pre><pre>Version = v2</pre><p>Suddenly finding the right boxes becomes easy.</p><p>You can filter, group, and organize everything instantly.</p><p>This is exactly how Kubernetes works.</p><p>Without labels, Kubernetes would have no efficient way to organize or identify resources. Labels act as metadata that gives meaning to otherwise identical-looking objects.</p><h3>What Is a Label?</h3><p>A <strong>Label</strong> is simply a key-value pair attached to a Kubernetes object.</p><p>Think of it as a tag or metadata that describes the object.</p><p>Example:</p><pre>labels:<br>  app: web<br>  environment: production<br>  version: v1</pre><p>A Pod can have one label.</p><p>Or ten.</p><p>Or twenty.</p><p>Labels describe what the object is, not how it behaves.</p><p>They are:</p><ul><li>Lightweight</li><li>Flexible</li><li>User-defined</li><li>Non-unique (multiple objects can share the same label)</li></ul><p>This flexibility allows you to design your own labeling strategy based on your application’s needs.</p><h3>Real Example</h3><p>Suppose your cluster contains these Pods.</p><pre>Pod A<br>app = web<br>environment = production<br>------------------------<br>Pod B<br>app = web<br>environment = staging<br>------------------------<br>Pod C<br>app = payment<br>environment = production<br>------------------------<br>Pod D <br>app = database <br>environment = production</pre><p>Every Pod now carries useful information.</p><p>Kubernetes can easily identify them based on:</p><ul><li>Application type</li><li>Environment</li><li>Role in the system</li></ul><p>This makes it possible to group and manage resources logically instead of relying on fragile identifiers like Pod names or IP addresses.</p><h3>Why Are Labels So Important?</h3><p>Imagine a Service needs to send traffic to your web application.</p><p>How does it know which Pods belong to the application?</p><p>Pods don’t register themselves.</p><p>Services don’t remember Pod names.</p><p>Pods are also ephemeral — they can be created, destroyed, or replaced at any time.</p><p>Instead…</p><p>The Service simply searches for matching labels.</p><p>This dynamic discovery mechanism ensures that:</p><ul><li>New Pods are automatically included</li><li>Terminated Pods are automatically removed</li><li>No manual updates are required</li></ul><p>This is what makes Kubernetes highly resilient and self-healing.</p><h3>Meet Selectors</h3><p>A <strong>Selector</strong> is simply a filter.</p><p>It asks Kubernetes:</p><blockquote><em>“Show me every object with this label.”</em></blockquote><p>Example:</p><pre>selector:<br>  app: web</pre><p>Kubernetes looks through every Pod.</p><p>Pods matching:</p><pre>app = web</pre><p>become part of the Service.</p><p>Everything else is ignored.</p><p>Selectors can be simple (match a single label) or more advanced using expressions like:</p><ul><li>matchLabels</li><li>matchExpressions</li></ul><p>This allows for powerful filtering logic when managing complex systems.</p><h3>Let’s See It Visually</h3><p>Imagine four Pods.</p><pre>+-------------+<br>| Web Pod 1   |<br>| app = web   |<br>+-------------+</pre><pre>+-------------+<br>| Web Pod 2   |<br>| app = web   |<br>+-------------+</pre><pre>+------------------+<br>| Payment Pod      |<br>| app = payment    |<br>+------------------+</pre><pre>+------------------+<br>| Database Pod     |<br>| app = database   |<br>+------------------+</pre><p>Now the Service says:</p><pre>selector:<br>  app: web</pre><p>Kubernetes immediately selects:</p><pre>✓ Web Pod 1</pre><pre>✓ Web Pod 2</pre><p>The remaining Pods are ignored.</p><p>No IP addresses.</p><p>No Pod names.</p><p>Just labels.</p><p>This abstraction allows Kubernetes to route traffic dynamically without needing to track individual Pods.</p><h3>Services Depend on Labels</h3><p>Earlier in this series, we learned that Services provide stable networking.</p><p>But here’s something many beginners don’t realize:</p><p><strong>Services don’t know Pod names.</strong></p><p>They only understand labels.</p><p>Example Service:</p><pre>selector:<br>  app: frontend</pre><p>Whenever Kubernetes finds Pods matching:</p><pre>labels:<br>  app: frontend</pre><p>they automatically become part of the Service.</p><p>Even if new Pods are created…</p><p>The Service discovers them instantly.</p><p>This is why scaling applications in Kubernetes is seamless — Services automatically adapt to changes in the number of Pods.</p><h3>Deployments Also Use Labels</h3><p>Let’s deploy three replicas.</p><pre>replicas: 3</pre><p>How does the Deployment know which Pods belong to it?</p><p>Again…</p><p>Labels.</p><p>Example:</p><pre>template:<br>  metadata:<br>    labels:<br>      app: nginx</pre><p>The Deployment watches every Pod carrying:</p><pre>app = nginx</pre><p>If one Pod disappears…</p><p>The Deployment notices.</p><p>A replacement Pod is created.</p><p>Additionally, Deployments use labels to perform rolling updates, ensuring that new versions of Pods are gradually introduced without downtime.</p><p>Without labels, Deployments couldn’t manage Pods effectively.</p><h3>ReplicaSets Depend on Selectors Too</h3><p>ReplicaSets constantly ask:</p><blockquote><em>“How many Pods with my labels currently exist?”</em></blockquote><p>Example:</p><pre>selector:<br>  matchLabels:<br>    app: nginx</pre><p>Suppose it expects:</p><pre>3 Pods</pre><p>Current state:</p><pre>Pod 1<br>app = nginx<br>------------<br>Pod 2<br>app = nginx</pre><p>Only two exist.</p><p>ReplicaSet immediately creates another one.</p><p>This continuous reconciliation loop ensures that the desired state always matches the actual state.</p><p>Again…</p><p>Labels make this possible.</p><h3>Labels Help Organize Large Clusters</h3><p>Imagine your company runs 5,000 Pods.</p><p>Without labels:</p><pre>pod-a9fd7<br>pod-b8df6<br>pod-xy71a<br>pod-qwe23</pre><p>Impossible to understand.</p><p>Now imagine:</p><pre>app = frontend<br>team = payments<br>environment = production<br>version = v2</pre><p>Suddenly everything becomes organized.</p><p>You can quickly answer questions like:</p><ul><li>Show all production Pods.</li><li>Show payment services.</li><li>Show frontend version v2.</li><li>Show staging workloads.</li></ul><p>Labels enable powerful querying using tools like kubectl, making cluster management far more efficient.</p><h3>Labels Can Describe Anything</h3><p>Common labels include:</p><pre>app: frontend<br>team: payments<br>version: v2<br>environment: production<br>tier: backend<br>owner: platform-team<br>region: asia<br>project: ecommerce</pre><p>You decide what information matters.</p><p>Labels can represent:</p><ul><li>Business context (team, project)</li><li>Technical details (version, tier)</li><li>Operational data (environment, region)</li></ul><h3>Multiple Labels Make Kubernetes Powerful</h3><p>A Pod can have several labels.</p><p>Example:</p><pre>labels:<br>  app: frontend<br>  environment: production<br>  version: v2<br>  team: ecommerce</pre><p>Now you can filter by:</p><p>Only production:</p><pre>environment = production</pre><p>Only version 2:</p><pre>version = v2</pre><p>Only ecommerce:</p><pre>team = ecommerce</pre><p>Or combine them for more precise targeting.</p><p>This multi-dimensional filtering is what makes Kubernetes highly flexible.</p><h3>Kubernetes Uses Labels Everywhere</h3><p>Many Kubernetes resources rely on labels and selectors.</p><p>Examples include:</p><ul><li>Services (traffic routing)</li><li>Deployments (Pod management)</li><li>ReplicaSets (replica control)</li><li>StatefulSets (stateful workloads)</li><li>DaemonSets (node-level workloads)</li><li>Jobs (batch processing)</li><li>Network Policies (security rules)</li><li>Monitoring systems (metrics grouping)</li><li>Backup tools (resource selection)</li><li>GitOps platforms (deployment automation)</li><li>Service meshes (traffic control)</li></ul><p>Once you understand labels, many Kubernetes resources suddenly become much easier to understand.</p><h3>A Real Production Example</h3><p>Imagine an e-commerce application.</p><pre>Frontend Pods<br>↓<br>Labels<br>app = frontend<br>↓<br>Frontend Service<br>-------------------------<br>Payment Pods<br>↓<br>Labels<br>app = payment<br>↓<br>Payment Service<br>-------------------------<br>Inventory Pods<br>↓<br>Labels<br>app = inventory  <br>↓  <br>Inventory Service</pre><p>Each Service automatically discovers only the Pods it should communicate with.</p><p>No manual configuration.</p><p>No IP management.</p><p>Just labels.</p><p>This architecture allows teams to independently scale and update services without affecting others.</p><h3>Common Beginner Mistakes</h3><h4>❌ Using Pod Names Instead of Labels</h4><p>Pod names change.</p><p>Labels remain consistent.</p><p>Always rely on labels.</p><h4>❌ Forgetting Labels</h4><p>Without labels:</p><ul><li>Services cannot find Pods.</li><li>Deployments cannot manage Pods.</li><li>ReplicaSets cannot scale Pods.</li></ul><p>Many Kubernetes resources simply stop working as expected.</p><h4>❌ Using Inconsistent Label Names</h4><p>Avoid mixing:</p><pre>application<br>app-name<br>service<br>my-app</pre><p>Instead, adopt a consistent labeling strategy across your cluster.</p><p>Consistency improves readability, automation, and collaboration.</p><h3>Best Practices</h3><p>✔ Use meaningful labels.</p><p>✔ Keep naming consistent.</p><p>✔ Label every workload.</p><p>✔ Include environment labels.</p><p>✔ Include version labels.</p><p>✔ Include team ownership.</p><p>✔ Avoid unnecessary labels.</p><p>✔ Follow Kubernetes recommended label conventions when possible.</p><p>Good labeling makes operating large Kubernetes clusters significantly easier.</p><h3>The Mental Model I Use</h3><p>Imagine a large library.</p><p>Books aren’t organized by their cover color.</p><p>They’re organized using labels:</p><ul><li>Fiction</li><li>Science</li><li>History</li><li>Technology</li></ul><p>When someone searches for a book, the librarian doesn’t inspect every page.</p><p>They simply search the labels.</p><p>Kubernetes works exactly the same way.</p><p>Pods don’t introduce themselves.</p><p>Kubernetes identifies them using labels.</p><p>Selectors act like search queries, instantly finding the right resources.</p><h3>Key Takeaways</h3><p>Remember these important concepts:</p><ul><li>Labels are key-value pairs attached to Kubernetes objects.</li><li>Labels describe what an object is.</li><li>Selectors search for matching labels.</li><li>Services use selectors to find Pods.</li><li>Deployments use labels to manage Pods.</li><li>ReplicaSets use labels to maintain replica counts.</li><li>Labels enable dynamic discovery and scaling.</li><li>Labels make large clusters manageable.</li><li>Consistent labeling is a production best practice.</li></ul><h3>Final Thoughts</h3><p>Labels and Selectors may look like tiny pieces of YAML, but they are one of the core design principles of Kubernetes.</p><p>They create the relationships between resources without hardcoding IP addresses or object names.</p><p>This loose coupling allows Kubernetes to be flexible, scalable, and self-healing.</p><p>As your applications grow from a handful of Pods to thousands running across multiple clusters, a good labeling strategy becomes just as important as writing good application code.</p><p>Once you truly understand Labels and Selectors, you’ll begin to see them everywhere in Kubernetes — and you’ll realize they’re quietly powering almost everything inside your cluster.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=571841229eb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Kubernetes Services Exist Even Though Every Pod Has an IP Address]]></title>
            <link>https://medium.com/@shahzadaliahmad/why-kubernetes-services-exist-even-though-every-pod-has-an-ip-address-39238eeefd3b?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/39238eeefd3b</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[ckad]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Fri, 26 Jun 2026 02:16:53 GMT</pubDate>
            <atom:updated>2026-06-26T02:16:53.854Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n4h8aKixMrb5iyuyuCJzOg.png" /><figcaption>Every Pod has an IP — but that’s not why applications communicate reliably in Kubernetes. Discover why Services are the real backbone of cluster networking.</figcaption></figure><p><em>Understanding the real problem Kubernetes Services solve and why Pod IPs alone aren’t enough.</em></p><h3>Introduction</h3><p>One of the first things you learn about Kubernetes is that <strong>every Pod gets its own IP address</strong>.</p><p>At first glance, this seems like everything you need for communication. If each Pod has a unique IP, then applications should be able to talk to each other directly — just like traditional systems.</p><p>So naturally, a question comes to mind:</p><blockquote>“If every Pod already has an IP address, why do we need Kubernetes Services?”</blockquote><p>It’s a great question — and one that reveals a deeper understanding of how Kubernetes works.</p><p>The answer lies in Kubernetes’ core design philosophy.</p><p>Pods are meant to be <strong>temporary and replaceable</strong>.</p><p>Applications, however, require <strong>stable and reliable communication</strong>.</p><p>This mismatch creates a problem that Kubernetes Services are specifically designed to solve.</p><p>In this article, we’ll explore:</p><ul><li>Why Pod IPs alone are not enough</li><li>What problems arise when relying on Pod IPs</li><li>How Kubernetes Services provide stability, scalability, and reliability</li></ul><h3>Let’s Start With a Simple Application</h3><p>Imagine you’ve deployed a simple web application.</p><p>Your cluster currently looks like this:</p><pre>Kubernetes Cluster</pre><pre>           +------------------------+<br>           |                        |<br>           |   Web Pod              |<br>           |   IP: 10.244.1.12      |<br>           |                        |<br>           +------------------------+</pre><p>Your frontend application communicates directly with:</p><pre>http://10.244.1.12</pre><p>Everything works perfectly.</p><p>At this stage, it feels simple and intuitive.</p><p>You might think:</p><blockquote><em>“Great! Every Pod has an IP. Problem solved.”</em></blockquote><p>But this setup only works in a <strong>very controlled and static environment</strong>.</p><p>In real-world Kubernetes clusters, things are constantly changing.</p><h3>Pods Are Designed to Be Temporary</h3><p>Unlike virtual machines, Pods are <strong>ephemeral</strong>.</p><p>Kubernetes treats Pods as disposable units that can be created, destroyed, and replaced at any time.</p><p>This behavior is intentional and enables powerful features like self-healing and scaling.</p><p>Pods can be recreated for many reasons:</p><ul><li>The application crashes</li><li>The node hosting the Pod fails</li><li>A new version of the application is deployed</li><li>The cluster scales up or down</li><li>Kubernetes reschedules workloads for better resource usage</li><li>Rolling updates replace old Pods with new ones</li></ul><p>The key point is:</p><blockquote><strong><em>A new Pod never keeps the old Pod’s IP address.</em></strong></blockquote><p>For example:</p><pre>Old Pod<br><br>10.244.1.12<br><br>↓<br><br>Pod crashes<br><br>↓<br><br>New Pod<br><br>10.244.3.25</pre><p>Even though the application is logically the same, its network identity has changed.</p><p>If another application is still trying to reach:</p><pre>10.244.1.12</pre><p>that request will fail because the Pod no longer exists.</p><h3>Imagine This in the Real World</h3><p>Suppose you’re building an online shopping platform.</p><p>Your frontend communicates with a product service.</p><pre>Frontend<br>↓<br>10.244.1.12</pre><p>Now imagine a user browsing your website.</p><p>At that exact moment, the Product Pod crashes.</p><p>Kubernetes immediately replaces it:</p><pre>Old Pod<br>10.244.1.12<br>↓<br>New Pod<br>10.244.4.18</pre><p>However, your frontend is still sending requests to:</p><pre>10.244.1.12</pre><p>That IP is now invalid.</p><p>The result?</p><ul><li>Failed API calls</li><li>Broken user experience</li><li>Potential revenue loss</li></ul><p>This is unacceptable in production systems where reliability is critical.</p><h3>Scaling Makes the Problem Even Bigger</h3><p>Now consider scaling.</p><p>Your application becomes popular, and Kubernetes creates multiple replicas.</p><pre>Product Pod A<br>10.244.1.12<br>Product Pod B<br>10.244.2.15<br>Product Pod C<br>10.244.5.20</pre><h3>Now your frontend faces a new challenge:</h3><p>Which IP should it use?</p><pre>10.244.1.12 ?<br>10.244.2.15 ?<br>10.244.5.20 ?</pre><p>There is no single correct answer.</p><p>Even worse:</p><ul><li>Pods can be added or removed dynamically</li><li>IPs change frequently</li><li>The number of Pods is unpredictable</li></ul><p>Managing this manually would require:</p><ul><li>Constant updates to configuration</li><li>Custom load balancing logic</li><li>Complex service discovery mechanisms</li></ul><p>This quickly becomes unmanageable.</p><h3>Kubernetes Needed a Stable Address</h3><p>To solve this problem, Kubernetes introduced the concept of a <strong>Service</strong>.</p><p>A Service acts as a <strong>stable abstraction layer</strong> over a dynamic set of Pods.</p><p>Think of it as a permanent entry point.</p><p>Instead of connecting to individual Pods, applications connect to the Service.</p><pre>Frontend<br>↓<br>Product Service<br>↓<br>Product Pods</pre><p>The frontend no longer needs to know:</p><ul><li>How many Pods exist</li><li>What their IPs are</li><li>When they are created or destroyed</li></ul><p>It only needs to know the Service.</p><h3>How a Service Solves the Problem</h3><p>A Service is assigned a <strong>virtual IP address</strong>, also known as a ClusterIP.</p><p>For example:</p><pre>Product Service<br>10.96.12.5</pre><p>Behind the scenes:</p><pre>Product Service<br>                 10.96.12.5<br>                      │<br>          ┌───────────┼───────────┐<br>          │           │           │<br>      Pod A       Pod B       Pod C<br> 10.244.1.12 10.244.2.15 10.244.5.20</pre><p>Applications communicate only with:</p><pre>10.96.12.5</pre><p>The Service acts as a <strong>traffic router</strong>, forwarding requests to one of the available Pods.</p><p>This abstraction ensures that:</p><ul><li>The client sees a stable endpoint</li><li>The backend can change freely</li></ul><h3>What Happens When a Pod Crashes?</h3><p>Suppose Pod B crashes.</p><p>Before:</p><pre>Service<br>↓<br>Pod A<br>Pod B<br>Pod C</pre><p>After the crash:</p><pre>Service<br>↓<br>Pod A<br>Pod C</pre><p>Kubernetes automatically updates the Service’s internal list of endpoints.</p><p>When a new Pod is created:</p><pre>Service<br>↓<br>Pod A<br>Pod C<br>Pod D</pre><p>The Service immediately starts routing traffic to the new Pod.</p><p>This happens <strong>without any manual intervention</strong>.</p><p>The frontend continues to communicate with the same Service IP.</p><h3>How Does the Service Know Which Pods Belong to It?</h3><p>Kubernetes uses <strong>labels and selectors</strong>.</p><p>Pods are tagged with labels:</p><pre>labels:<br>  app: product</pre><p>The Service defines a selector:</p><pre>selector:<br>  app: product</pre><p>Kubernetes continuously monitors the cluster state.</p><p>Whenever a Pod matches the selector:</p><ul><li>It is added to the Service</li><li>It becomes eligible to receive traffic</li></ul><p>When a Pod is removed:</p><ul><li>It is automatically excluded</li></ul><p>This dynamic discovery mechanism is what makes Services powerful and flexible.</p><h3>What About Load Balancing?</h3><p>Services also provide built-in <strong>load balancing</strong>.</p><p>Instead of sending all traffic to a single Pod, Kubernetes distributes requests across all healthy Pods.</p><p>Example:</p><pre>Request 1 → Pod A<br>Request 2 → Pod B<br>Request 3 → Pod C<br>Request 4 → Pod D</pre><p>This improves:</p><ul><li>Performance</li><li>Availability</li><li>Resource utilization</li></ul><p>Under the hood, kube-proxy implements this behavior using techniques like:</p><ul><li>iptables rules</li><li>IPVS (in more advanced setups)</li></ul><p>You don’t need to configure any of this manually.</p><h3>Services Also Provide Stable DNS</h3><p>In real-world systems, applications rarely use raw IP addresses.</p><p>Instead, they rely on <strong>DNS names</strong>.</p><p>Kubernetes automatically creates DNS entries for Services.</p><p>For example:</p><pre>product-service</pre><p>or fully qualified:</p><pre>product-service.default.svc.cluster.local</pre><p>Instead of writing:</p><pre>http://10.244.5.20</pre><p>applications use:</p><pre>http://product-service</pre><p>This provides:</p><ul><li>Readability</li><li>Stability</li><li>Environment independence</li></ul><p>Even if Pods change constantly, the DNS name remains the same.</p><h3>What Happens Behind the Scenes?</h3><p>Let’s trace a request:</p><pre>Client<br>↓<br>Service DNS<br>↓<br>Service IP<br>↓<br>kube-proxy<br>↓<br>Available Pod<br>↓<br>Application Response</pre><p>Detailed flow:</p><ol><li>The client sends a request to product-service.</li><li>Kubernetes DNS resolves it to the Service IP.</li><li>The request reaches the Service’s virtual IP.</li><li>kube-proxy intercepts the request.</li><li>It selects a healthy Pod.</li><li>The request is forwarded to that Pod.</li><li>The Pod processes the request and responds.</li></ol><p>This entire process is transparent to the client.</p><h3>A Real Production Example</h3><p>Consider an e-commerce platform:</p><pre>                User<br>                 │<br>                 ▼<br>          Frontend Service<br>                 │<br>      ┌──────────┴──────────┐<br>      ▼                     ▼<br>Frontend Pod 1       Frontend Pod 2<br>                 │<br>                 ▼<br>          Product Service<br>      ┌──────────┴──────────┐<br>      ▼                     ▼<br> Product Pod 1        Product Pod 2<br>                 │<br>                 ▼<br>          Database Service<br>                 │<br>                 ▼<br>            Database Pod</pre><p>Every component communicates through Services.</p><p>This architecture enables:</p><ul><li>Horizontal scaling</li><li>Fault tolerance</li><li>Seamless updates</li><li>Decoupled services</li></ul><h3>The Mental Model I Use</h3><p>Think of a large office building.</p><p>Employees move desks frequently.</p><p>If customers tried to reach employees using desk numbers, communication would constantly fail.</p><p>Instead, they call the reception desk.</p><p>The receptionist knows where everyone is.</p><p>Pods are like employees.</p><p>Services are the reception desk.</p><p>Applications talk to the Service, not the Pods.</p><h3>Common Beginner Mistakes</h3><h4>❌ Connecting directly to Pod IPs</h4><p>Pod IPs are temporary and unreliable.</p><h4>❌ Assuming Pod IPs never change</h4><p>Pods are ephemeral by design.</p><h4>❌ Trying to manually load balance Pods</h4><p>Kubernetes already provides this functionality.</p><h4>❌ Ignoring Labels</h4><p>Without labels, Services cannot discover Pods.</p><h3>Key Takeaways</h3><ul><li>Every Pod has an IP, but it is temporary</li><li>Pods are constantly created and destroyed</li><li>Applications need stable communication endpoints</li><li>Services provide a consistent virtual IP</li><li>Services automatically discover Pods using labels</li><li>Services handle load balancing</li><li>Services provide DNS-based access</li><li>Applications should always communicate via Services</li></ul><h3>Final Thoughts</h3><p>Kubernetes Services are not just an optional feature — they are a fundamental building block.</p><p>They bridge the gap between:</p><ul><li>Dynamic infrastructure (Pods)</li><li>Stable application communication</li></ul><p>Without Services, managing communication in a Kubernetes cluster would be extremely complex.</p><p>Once you understand Services, many other concepts — like Ingress, networking policies, and service meshes — become much easier to grasp.</p><p>If you’re preparing for the CKA or working in production environments, mastering Services is essential.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39238eeefd3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes ConfigMaps and Secrets Explained]]></title>
            <link>https://medium.com/@shahzadaliahmad/kubernetes-configmaps-and-secrets-explained-7889c82088b9?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/7889c82088b9</guid>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Sun, 21 Jun 2026 16:11:05 GMT</pubDate>
            <atom:updated>2026-06-21T16:11:05.830Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFZIGIF8L6qSpry-xj1zqQ.png" /><figcaption>Learn how to manage application configuration, protect sensitive data, and build secure, production-ready Kubernetes applications.</figcaption></figure><p><em>Understanding how Kubernetes manages application configuration and sensitive data without rebuilding containers.</em></p><h3>Introduction</h3><p>Imagine your development team has built an application that connects to a database.</p><p>The application needs several pieces of information to run:</p><ul><li>Database Host</li><li>Database Port</li><li>Application Environment</li><li>API Keys</li><li>Database Passwords</li><li>Third-Party Credentials</li></ul><p>A common beginner approach is to put all these values directly inside the application code.</p><p>For example:</p><pre>DATABASE_HOST=&quot;db.company.com&quot;<br>DATABASE_PASSWORD=&quot;mypassword123&quot;</pre><p>This might work initially, especially for small projects or local development environments, but it quickly becomes a problem as applications grow and move through different stages of deployment.</p><p>What happens when:</p><ul><li>You move from Development to Production?</li><li>The database password changes?</li><li>Multiple environments need different configurations?</li><li>Someone accidentally commits secrets to Git?</li><li>Different teams need different settings for the same application?</li></ul><p>In traditional environments, configuration changes often required modifying code, rebuilding applications, and redeploying them. This process is slow, error-prone, and difficult to manage at scale.</p><p>Modern applications need a better way to manage configuration.</p><p>This is exactly why Kubernetes provides:</p><ul><li>ConfigMaps</li><li>Secrets</li></ul><p>These two resources allow you to separate application code from configuration and credentials, making applications more portable, secure, and easier to manage.</p><p>In this article, we’ll explore what they are, how they work, when to use them, and why every Kubernetes engineer should understand them.</p><h3>The Configuration Problem</h3><p>Let’s imagine an e-commerce application.</p><p>The application needs:</p><pre>Application Name<br>Environment<br>Database Host<br>Database Port<br>API Endpoint</pre><p>If these values are hardcoded inside the container image:</p><pre>Container Image<br>     │<br>     ├── Application Code<br>     ├── Database Host<br>     ├── Environment<br>     └── API URL</pre><p>Every time a value changes:</p><pre>Modify Code<br>      ↓<br>Build New Image<br>      ↓<br>Push Image<br>      ↓<br>Deploy Again</pre><p>This becomes inefficient.</p><p>For example, if your production database moves to a new server, you shouldn’t need to rebuild your application image just to update a hostname.</p><p>Configuration should not require rebuilding applications.</p><p>Instead, configuration should be externalized so that the same container image can be deployed across multiple environments with different settings.</p><p>This concept is one of the foundations of cloud-native application design and aligns closely with the Twelve-Factor App methodology.</p><h3>What Is a ConfigMap?</h3><p>A ConfigMap is a Kubernetes object used to store non-sensitive configuration data.</p><p>Think of a ConfigMap as a configuration file stored inside Kubernetes.</p><p>Instead of hardcoding values inside the application, you store them separately.</p><p>Example:</p><pre>ConfigMap</pre><pre>APP_ENV=production<br>APP_NAME=shopping-app<br>DATABASE_HOST=mysql-service<br>DATABASE_PORT=3306</pre><p>Your application can then read these values at runtime.</p><p>This separation provides several benefits:</p><ul><li>Configuration can change without rebuilding images.</li><li>Different environments can use different settings.</li><li>Operations teams can manage configuration independently from developers.</li><li>Applications become more portable and reusable.</li></ul><p>A ConfigMap can store simple key-value pairs, entire configuration files, command-line arguments, or application settings.</p><h3>Why ConfigMaps Are Useful</h3><p>Imagine your application runs in three environments:</p><pre>Development<br>Testing<br>Production</pre><p>Each environment has different settings.</p><p>Development:</p><pre>APP_ENV=dev<br>DATABASE_HOST=dev-db</pre><p>Testing:</p><pre>APP_ENV=test<br>DATABASE_HOST=test-db</pre><p>Production:</p><pre>APP_ENV=prod<br>DATABASE_HOST=prod-db</pre><p>Without ConfigMaps, you might need three separate container images.</p><p>With ConfigMaps, you can use:</p><pre>One Container Image<br>        +<br>Different ConfigMaps</pre><p>Instead of creating different container images, you use different ConfigMaps.</p><p>The same application image works everywhere.</p><p>This follows a key cloud-native principle:</p><blockquote><em>Build once, deploy anywhere.</em></blockquote><p>This approach simplifies CI/CD pipelines because the application image remains unchanged while configuration is injected during deployment.</p><h3>Creating a ConfigMap</h3><p>A simple ConfigMap looks like this:</p><pre>apiVersion: v1<br>kind: ConfigMap</pre><pre>metadata:<br>  name: app-config</pre><pre>data:<br>  APP_ENV: production<br>  APP_NAME: ecommerce-app<br>  DATABASE_HOST: mysql-service<br>  DATABASE_PORT: &quot;3306&quot;</pre><p>Apply it:</p><pre>kubectl apply -f configmap.yaml</pre><p>Verify:</p><pre>kubectl get configmap</pre><p>Output:</p><pre>NAME<br>app-config</pre><p>You can inspect its contents using:</p><pre>kubectl describe configmap app-config</pre><p>or</p><pre>kubectl get configmap app-config -o yaml</pre><p>The ConfigMap now exists inside the cluster and can be consumed by Pods and Deployments.</p><h3>How Applications Use ConfigMaps</h3><p>There are several ways to consume ConfigMaps.</p><p>The method you choose depends on how your application expects configuration data.</p><p>Some applications prefer environment variables, while others expect configuration files.</p><h3>Method 1: Environment Variables</h3><p>The most common approach.</p><p>Deployment Example:</p><pre>env:<br>- name: APP_ENV<br>  valueFrom:<br>    configMapKeyRef:<br>      name: app-config<br>      key: APP_ENV</pre><p>Inside the container:</p><pre>echo $APP_ENV</pre><p>Output:</p><pre>production</pre><p>The application can now access the configuration dynamically.</p><p>This approach works particularly well for modern applications built using frameworks such as Spring Boot, Node.js, Django, Flask, and .NET.</p><h3>Method 2: Entire ConfigMap as Environment Variables</h3><p>Instead of specifying each key individually:</p><pre>envFrom:<br>- configMapRef:<br>    name: app-config</pre><p>Kubernetes loads all values automatically.</p><p>Result:</p><pre>APP_ENV=production<br>APP_NAME=ecommerce-app<br>DATABASE_HOST=mysql-service<br>DATABASE_PORT=3306</pre><p>This method is useful when your ConfigMap contains many configuration values and you want to avoid repetitive YAML definitions.</p><p>However, be careful with naming conflicts because all keys become environment variables inside the container.</p><h3>Method 3: Mounting ConfigMaps as Files</h3><p>Some applications prefer configuration files.</p><p>Example:</p><pre>volumes:<br>- name: config-volume<br>  configMap:<br>    name: app-config</pre><p>Mounted into:</p><pre>/etc/config</pre><p>Result:</p><pre>/etc/config/APP_ENV<br>/etc/config/DATABASE_HOST<br>/etc/config/DATABASE_PORT</pre><p>Applications can read these files directly.</p><p>This approach is commonly used for:</p><ul><li>NGINX configuration files</li><li>Apache configuration files</li><li>Application property files</li><li>Custom YAML or JSON configuration files</li></ul><p>One advantage of mounted ConfigMaps is that Kubernetes can update the mounted files when the ConfigMap changes, allowing some applications to reload configuration without restarting.</p><h3>The Problem with ConfigMaps</h3><p>ConfigMaps are excellent for configuration.</p><p>However, they are not designed for sensitive data.</p><p>Consider:</p><pre>Database Password<br>AWS Secret Key<br>API Tokens<br>JWT Keys</pre><p>Storing these in a ConfigMap is dangerous.</p><p>Why?</p><p>Because ConfigMaps are stored as plain text.</p><p>Anyone with sufficient Kubernetes permissions can easily view them.</p><p>For example:</p><pre>kubectl get configmap app-config -o yaml</pre><p>would expose all stored values.</p><p>This creates a security risk when dealing with credentials.</p><p>This leads us to Secrets.</p><h3>What Is a Secret?</h3><p>A Secret is a Kubernetes object used to store sensitive information.</p><p>Examples:</p><pre>Database Passwords<br>API Keys<br>OAuth Tokens<br>TLS Certificates<br>Cloud Credentials</pre><p>Instead of exposing sensitive data directly, Kubernetes provides Secrets as a dedicated resource.</p><p>Think of it like this:</p><pre>ConfigMap → Public Information</pre><pre>Secret → Private Information</pre><p>Secrets are designed to reduce accidental exposure of sensitive information and provide a standardized way for applications to consume credentials.</p><p>Kubernetes supports several Secret types, including:</p><pre>Opaque<br>TLS<br>Docker Registry Credentials<br>Service Account Tokens</pre><p>The most commonly used type is:</p><pre>Opaque</pre><p>which stores arbitrary key-value pairs.</p><h3>Creating a Secret</h3><p>Example:</p><pre>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: database-secret<br>type: Opaque<br>data:<br>  username: YWRtaW4=<br>  password: U3VwZXJTZWNyZXQ=</pre><p>You may notice strange values.</p><p>That’s because Kubernetes stores Secret values in Base64 format.</p><p>After applying the Secret:</p><pre>kubectl apply -f secret.yaml</pre><p>You can verify it:</p><pre>kubectl get secret</pre><p>Output:</p><pre>NAME<br>database-secret</pre><h3>Understanding Base64</h3><p>Example:</p><p>Original:</p><pre>admin</pre><p>Encoded:</p><pre>YWRtaW4=</pre><p>Password:</p><pre>SuperSecret</pre><p>Encoded:</p><pre>U3VwZXJTZWNyZXQ=</pre><p>Generate Base64:</p><pre>echo -n &quot;admin&quot; | base64</pre><p>Decode Base64:</p><pre>echo &quot;YWRtaW4=&quot; | base64 --decode</pre><p>Output:</p><pre>admin</pre><p>Important:</p><blockquote><em>Base64 is encoding, not encryption.</em></blockquote><p>Anyone can decode it.</p><p>Many beginners mistakenly assume Secrets are fully encrypted because they appear unreadable.</p><p>In reality, Base64 simply converts data into a different representation.</p><p>Secrets improve handling of sensitive data, but additional security measures are still recommended.</p><p>These include:</p><ul><li>Encryption at rest</li><li>RBAC restrictions</li><li>Secret rotation</li><li>External secret management systems</li></ul><h3>Using Secrets as Environment Variables</h3><p>Deployment Example:</p><pre>env:<br>- name: DB_PASSWORD<br>  valueFrom:<br>    secretKeyRef:<br>      name: database-secret<br>      key: password</pre><p>Inside the container:</p><pre>echo $DB_PASSWORD</pre><p>Output:</p><pre>SuperSecret</pre><p>The application can now use the password without hardcoding it.</p><p>This is one of the most common patterns used in production Kubernetes environments.</p><p>Applications receive credentials dynamically during startup, reducing the risk of exposing secrets in source code repositories.</p><h3>Mounting Secrets as Files</h3><p>Secrets can also be mounted as volumes.</p><p>Example:</p><pre>volumes:<br>- name: secret-volume<br>  secret:<br>    secretName: database-secret</pre><p>Mounted directory:</p><pre>/etc/secrets</pre><p>Files created:</p><pre>/etc/secrets/username<br>/etc/secrets/password</pre><p>Applications can read them securely.</p><p>This approach is especially useful for:</p><ul><li>TLS certificates</li><li>SSH keys</li><li>Private keys</li><li>Configuration files containing credentials</li></ul><p>Many applications expect certificates and keys to exist as files rather than environment variables.</p><h3>ConfigMap vs Secret</h3><p>This is one of the most common Kubernetes interview questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*YXju4n352RSdt7hyzZK6HA.png" /></figure><p>Simple rule:</p><pre>Configuration → ConfigMap</pre><pre>Credentials → Secret</pre><p>A useful question to ask yourself is:</p><blockquote><em>“Would I be comfortable displaying this value on a public dashboard?”</em></blockquote><p>If the answer is yes, use a ConfigMap.</p><p>If the answer is no, use a Secret.</p><h3>Real Production Example</h3><p>Imagine an online shopping platform.</p><p>Configuration:</p><pre>APP_ENV=production<br>DATABASE_HOST=mysql-service<br>LOG_LEVEL=info</pre><p>Stored in:</p><pre>ConfigMap</pre><p>Credentials:</p><pre>Database Password<br>AWS Access Key<br>Stripe API Key</pre><p>Stored in:</p><pre>Secret</pre><p>Application:</p><pre>Deployment<br>      │<br>      ├── Reads ConfigMap<br>      └── Reads Secret</pre><p>This keeps configuration and credentials properly separated.</p><p>Benefits include:</p><ul><li>Easier environment management</li><li>Improved security</li><li>Cleaner deployments</li><li>Better compliance practices</li><li>Reduced operational risk</li></ul><h3>Common Mistakes</h3><h3>Storing Passwords in ConfigMaps</h3><p>Never do this:</p><pre>data:<br>  password: MySecretPassword</pre><p>Use Secrets instead.</p><p>Even in development environments, it’s a good habit to separate credentials from configuration.</p><h3>Committing Secrets to Git</h3><p>Many engineers accidentally commit:</p><pre>AWS_KEY=xxxxx<br>PASSWORD=xxxxx</pre><p>to source control.</p><p>This creates security risks.</p><p>Once a secret is committed, it may remain in Git history forever.</p><p>Always use secure secret management practices and rotate exposed credentials immediately.</p><h3>Assuming Base64 Is Encryption</h3><p>Many beginners think:</p><pre>Base64 = Secure</pre><p>It is not.</p><p>Base64 can be decoded easily.</p><p>Additional protections such as encryption at rest and secret management solutions should be used.</p><h3>Using the Same Secret Everywhere</h3><p>Avoid:</p><pre>One Secret<br>     ↓<br>Used By Every Application</pre><p>Instead:</p><pre>Application A → Own Secret</pre><pre>Application B → Own Secret</pre><p>This follows the principle of least privilege.</p><p>If one application is compromised, access to other credentials remains limited.</p><h3>How Kubernetes Uses Secrets Internally</h3><p>Kubernetes itself uses Secrets extensively.</p><p>Examples include:</p><pre>TLS Certificates<br>Service Account Tokens<br>Registry Credentials<br>API Authentication</pre><p>For example, when Kubernetes pulls images from a private container registry, it often uses a Secret containing registry credentials.</p><p>Similarly, TLS certificates used by Ingress controllers are commonly stored as Secrets.</p><p>Without Secrets, many Kubernetes components would not function securely.</p><h3>Security Best Practices for Secrets</h3><p>While Kubernetes Secrets are useful, production environments often require additional protections.</p><p>Recommended practices include:</p><ul><li>Enable encryption at rest for etcd.</li><li>Restrict access using RBAC.</li><li>Rotate secrets regularly.</li><li>Avoid exposing secrets in logs.</li><li>Use dedicated secrets per application.</li><li>Audit secret access frequently.</li></ul><p>Many organizations also integrate Kubernetes with external secret management platforms such as:</p><ul><li>HashiCorp Vault</li><li>AWS Secrets Manager</li><li>Azure Key Vault</li><li>Google Secret Manager</li></ul><p>These solutions provide stronger security controls, auditing, and automated secret rotation.</p><h3>The Mental Model I Use</h3><p>Whenever I think about ConfigMaps and Secrets, I imagine an office.</p><p>ConfigMap:</p><pre>Notice Board</pre><p>Everyone can read:</p><pre>Office Hours<br>WiFi Name<br>Printer Location</pre><p>Secret:</p><pre>Locked Safe</pre><p>Contains:</p><pre>Passwords<br>Keys<br>Financial Information</pre><p>Both contain information.</p><p>One is public.</p><p>One is private.</p><p>This mental model makes it easy to remember when to use each resource.</p><h3>Final Thoughts</h3><p>ConfigMaps and Secrets are fundamental building blocks in Kubernetes.</p><p>They help separate:</p><pre>Application Code<br>        FROM<br>Application Configuration</pre><p>and</p><pre>Configuration<br>        FROM<br>Sensitive Credentials</pre><p>By using ConfigMaps and Secrets correctly, you can:</p><ul><li>Build once and deploy anywhere</li><li>Manage environments efficiently</li><li>Improve security</li><li>Simplify application management</li><li>Follow cloud-native best practices</li><li>Reduce operational complexity</li></ul><p>As Kubernetes environments grow, proper configuration management becomes increasingly important. Understanding ConfigMaps and Secrets early will help you build more secure, flexible, and production-ready applications.</p><p>If you’re learning Kubernetes, mastering these two resources is essential because almost every real-world application depends on them. Whether you’re deploying a simple web application or managing hundreds of microservices, ConfigMaps and Secrets will be part of your daily Kubernetes workflow.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7889c82088b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Deployments Explained]]></title>
            <link>https://medium.com/@shahzadaliahmad/kubernetes-deployments-explained-f46264c2ab6d?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f46264c2ab6d</guid>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[ckad]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Sun, 21 Jun 2026 15:47:33 GMT</pubDate>
            <atom:updated>2026-06-21T15:47:33.875Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SZvZgMa4mD2YID-lKjg5Yg.png" /><figcaption>Learn how Kubernetes manages application updates, scaling, rollbacks, and self-healing to keep production workloads running without downtime.</figcaption></figure><p><em>Understanding how Kubernetes updates, scales, and manages applications without downtime.</em></p><h3>Introduction</h3><p>Imagine you’ve successfully deployed your application on Kubernetes.</p><p>Users are actively using it.</p><p>Everything is running smoothly.</p><p>Then your development team releases a new feature.</p><p>Now you need to deploy a new version of the application.</p><p>Questions immediately arise:</p><ul><li>How do I update the application without downtime?</li><li>What happens if the new version fails?</li><li>How can I roll back to a previous version?</li><li>How does Kubernetes manage multiple copies of my application?</li></ul><p>This is exactly why Kubernetes Deployments exist.</p><p>A Deployment is one of the most commonly used Kubernetes resources because it provides a reliable and declarative way to manage applications in production. Rather than manually creating, updating, and monitoring Pods, you define the desired state of your application, and Kubernetes continuously works to maintain that state.</p><p>In this article, we’ll explore what Deployments are, why they are important, how they work behind the scenes, and how they help Kubernetes deliver applications safely and efficiently.</p><h3>The Problem Before Deployments</h3><p>Let’s imagine you’re running an online shopping application.</p><p>You currently have:</p><pre>Version 1</pre><p>running on three Pods.</p><pre>Pod 1<br>Pod 2<br>Pod 3</pre><p>Everything is healthy.</p><p>Now your team releases:</p><pre>Version 2</pre><p>Without an automated deployment system, updating applications can be risky.</p><p>The traditional approach often looked like this:</p><pre>Stop Version 1<br>       ↓<br>Deploy Version 2<br>       ↓<br>Hope Everything Works</pre><p>If something failed:</p><ul><li>Users experienced downtime</li><li>Customers saw errors</li><li>Engineers worked under pressure</li><li>Rollbacks were often manual and time-consuming</li></ul><p>As applications grew larger and user expectations increased, this approach became unacceptable. Modern applications require continuous delivery, high availability, and rapid recovery from failures.</p><p>This created the need for a system that could automate deployments while minimizing risk.</p><p>Modern applications need a safer solution.</p><h3>What Is a Deployment?</h3><p>A Deployment is a Kubernetes object that manages application updates and desired state.</p><p>Think of a Deployment as a manager responsible for your application.</p><p>Instead of directly managing Pods, you tell the Deployment:</p><blockquote><em>“I want three copies of Version 2 running.”</em></blockquote><p>The Deployment ensures that this happens.</p><p>More specifically, a Deployment allows you to:</p><ul><li>Create and manage Pods</li><li>Scale applications up or down</li><li>Perform rolling updates</li><li>Roll back failed releases</li><li>Maintain application availability</li><li>Recover automatically from Pod failures</li></ul><h3>Deployment Architecture</h3><pre>Deployment<br>     │<br>     ▼<br>ReplicaSet<br>     │<br>     ▼<br>Pods</pre><p>The Deployment doesn’t create Pods directly.</p><p>Instead:</p><ol><li>Deployment creates a ReplicaSet</li><li>ReplicaSet creates Pods</li><li>Pods run containers</li></ol><p>This layered approach allows Kubernetes to perform updates safely.</p><h3>Why Not Create Pods Directly?</h3><p>Technically, you can create Pods directly using a Pod manifest.</p><p>However, Pods are ephemeral by design.</p><p>If a Pod crashes or a node fails:</p><pre>Pod Lost<br>    ↓<br>Application Capacity Reduced</pre><p>A standalone Pod will not automatically be recreated.</p><p>Deployments solve this problem by ensuring the desired number of Pods always exists.</p><p>For production workloads, Deployments are almost always preferred over standalone Pods.</p><h3>Creating a Deployment</h3><p>A simple Deployment might look like this:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: web-app<br>spec:<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: web-app<br>  template:<br>    metadata:<br>      labels:<br>        app: web-app<br>    spec:<br>      containers:<br>      - name: nginx<br>        image: nginx:latest</pre><p>Let’s break down the important sections:</p><h3>replicas</h3><pre>replicas: 3</pre><p>This tells Kubernetes to maintain three running copies of the application.</p><h3>selector</h3><pre>selector:<br>  matchLabels:<br>    app: web-app</pre><p>The selector tells the Deployment which Pods belong to it.</p><h3>template</h3><pre>template:</pre><p>This is the blueprint used to create Pods.</p><p>Every Pod created by the Deployment will follow this template.</p><p>When applied:</p><pre>kubectl apply -f deployment.yaml</pre><p>Kubernetes creates:</p><pre>Deployment<br>     ↓<br>ReplicaSet<br>     ↓<br>3 Pods</pre><p>The application is now running.</p><h3>Understanding Desired State</h3><p>Deployments work using Kubernetes’ core principle:</p><p><strong>Desired State</strong></p><p>Kubernetes is a declarative system.</p><p>Instead of telling Kubernetes <em>how</em> to perform every action, you tell it <em>what</em> you want.</p><p>Suppose you specify:</p><pre>replicas: 3</pre><p>Desired State:</p><pre>3 Pods</pre><p>Current State:</p><pre>3 Pods</pre><p>Everything is healthy.</p><p>Now imagine one Pod crashes.</p><p>Current State becomes:</p><pre>2 Pods</pre><p>But the Deployment still expects:</p><pre>3 Pods</pre><p>Kubernetes notices the difference and immediately creates a replacement Pod.</p><pre>Desired State = 3</pre><pre>Current State = 2</pre><pre>Kubernetes Creates New Pod</pre><pre>Current State = 3</pre><p>This automatic recovery is called:</p><blockquote><em>Self-Healing</em></blockquote><p>The Kubernetes control plane continuously compares the desired state with the actual state and takes corrective actions whenever they differ.</p><p>This reconciliation loop is one of the most important concepts in Kubernetes.</p><h3>Scaling Applications</h3><p>Deployments also make scaling easy.</p><p>Suppose your application receives more traffic.</p><p>You change:</p><pre>replicas: 3</pre><p>to:</p><pre>replicas: 10</pre><p>Kubernetes creates additional Pods.</p><pre>Before<br><br>Pod 1<br>Pod 2<br>Pod 3<br><br>After<br><br>Pod 1<br>Pod 2<br>Pod 3<br>Pod 4<br>Pod 5<br>Pod 6<br>Pod 7<br>Pod 8<br>Pod 9<br>Pod 10</pre><p>Traffic can now be distributed across more application instances.</p><h3>Scaling with kubectl</h3><p>You can also scale directly from the command line:</p><pre>kubectl scale deployment web-app --replicas=10</pre><p>Kubernetes updates the Deployment and creates additional Pods automatically.</p><h3>Why Scaling Matters</h3><p>Imagine:</p><pre>Morning Traffic = 1,000 Users</pre><pre>Evening Traffic = 50,000 Users</pre><p>A single application instance may not be able to handle the increased load.</p><p>By scaling horizontally (adding more Pods), Kubernetes helps distribute traffic and improve application performance and availability.</p><h3>How Rolling Updates Work</h3><p>One of the most powerful Deployment features is:</p><h3>Rolling Updates</h3><p>Let’s say you’re upgrading:</p><pre>Version 1</pre><p>to</p><pre>Version 2</pre><p>Instead of replacing everything at once, Kubernetes updates Pods gradually.</p><p>Example:</p><pre>Version 1<br>Version 1<br>Version 1</pre><p>Step 1:</p><pre>Version 2<br>Version 1<br>Version 1</pre><p>Step 2:</p><pre>Version 2<br>Version 2<br>Version 1</pre><p>Step 3:</p><pre>Version 2<br>Version 2<br>Version 2</pre><p>Users continue accessing the application throughout the update.</p><p>No downtime occurs.</p><h3>What Happens Behind the Scenes?</h3><p>When you update the container image:</p><pre>image: nginx:1.28</pre><p>Kubernetes creates a new ReplicaSet.</p><pre>Old ReplicaSet<br>      ↓<br>New ReplicaSet</pre><p>The Deployment gradually scales down the old ReplicaSet while scaling up the new ReplicaSet.</p><p>This process continues until all Pods are running the new version.</p><h3>Why Rolling Updates Matter</h3><p>Imagine an e-commerce website.</p><p>Thousands of customers are shopping.</p><p>A deployment occurs.</p><p>Without rolling updates:</p><pre>All Pods Stop<br>      ↓<br>New Pods Start</pre><p>Users experience downtime.</p><p>With rolling updates:</p><pre>Old Pods Gradually Replaced<br>      ↓<br>Users Continue Shopping</pre><p>The application remains available.</p><p>This is one of the reasons Kubernetes is trusted for production workloads.</p><p>Rolling updates reduce deployment risk because only a small portion of the application changes at a time. If issues appear, they can often be detected before the entire application is affected.</p><h3>What Happens During a Failed Deployment?</h3><p>Let’s assume Version 2 contains a bug.</p><p>Pods begin failing.</p><p>Kubernetes detects the issue.</p><p>Example:</p><pre>Version 2 Pod<br>      ↓<br>Crash<br>      ↓<br>Crash<br>      ↓<br>Crash</pre><p>The Deployment recognizes that the update is unhealthy.</p><p>Common reasons deployments fail include:</p><ul><li>Application startup failures</li><li>Incorrect environment variables</li><li>Missing secrets or configuration</li><li>Database connectivity issues</li><li>Failed readiness probes</li><li>Container image errors</li></ul><p>At this point, engineers can quickly return to the previous version.</p><h3>Rollbacks Explained</h3><p>One of my favorite Deployment features is:</p><h3>Rollback</h3><p>Kubernetes stores Deployment history.</p><p>Every time a Deployment changes, Kubernetes creates a new revision.</p><p>Suppose:</p><pre>Version 1</pre><p>was working.</p><pre>Version 2</pre><p>fails.</p><p>You can execute:</p><pre>kubectl rollout undo deployment web-app</pre><p>Kubernetes restores:</p><pre>Version 1</pre><p>The application returns to a healthy state.</p><p>This capability dramatically reduces deployment risk.</p><h3>Viewing Revision History</h3><p>You can inspect previous revisions using:</p><pre>kubectl rollout history deployment web-app</pre><p>Example:</p><pre>REVISION<br>1<br>2<br>3</pre><p>This helps teams understand what changes were deployed and when.</p><h3>Viewing Deployment Status</h3><p>You can check Deployment status using:</p><pre>kubectl get deployments</pre><p>Example output:</p><pre>NAME      READY   UP-TO-DATE   AVAILABLE</pre><pre>web-app   3/3     3            3</pre><p>This indicates:</p><ul><li>Desired Pods = 3</li><li>Available Pods = 3</li><li>Deployment is healthy</li></ul><p>For more detailed information:</p><pre>kubectl describe deployment web-app</pre><p>This command displays events, rollout history, conditions, and troubleshooting information.</p><h3>Viewing Rollout Progress</h3><p>To watch an update:</p><pre>kubectl rollout status deployment web-app</pre><p>This shows:</p><pre>Deployment progressing successfully</pre><p>or</p><pre>Waiting for rollout...</pre><p>Very useful during production deployments.</p><p>Monitoring rollout progress helps engineers quickly identify deployment issues before they impact users.</p><h3>Real Production Example</h3><p>Imagine a shopping application during a major sale.</p><p>Current deployment:</p><pre>Version 1</pre><p>Traffic:</p><pre>50,000 Users</pre><p>Developers release:</p><pre>Version 2</pre><p>Deployment performs:</p><pre>Rolling Update</pre><p>Users continue shopping.</p><p>No downtime.</p><p>If problems occur:</p><pre>Rollback</pre><p>Application returns to Version 1.</p><p>Customers never notice.</p><p>This is how many modern applications are updated every day.</p><p>Large organizations such as Netflix, Spotify, Airbnb, and many cloud-native companies rely on deployment strategies like these to release software continuously while maintaining service availability.</p><h3>Common Deployment Mistakes</h3><h3>Using Latest Tag</h3><p>Avoid:</p><pre>image: nginx:latest</pre><p>Use:</p><pre>image: nginx:1.28.0</pre><p>Specific versions make deployments predictable.</p><p>Using latest can lead to unexpected behavior because the image may change without warning.</p><h3>No Health Checks</h3><p>Without probes:</p><p>Kubernetes cannot determine if Pods are healthy.</p><p>Always configure:</p><ul><li>Liveness Probes</li><li>Readiness Probes</li></ul><p>Readiness probes determine whether a Pod can receive traffic.</p><p>Liveness probes determine whether a Pod should be restarted.</p><h3>No Resource Limits</h3><p>Pods may consume excessive resources.</p><p>Always define:</p><pre>resources:</pre><p>for production workloads.</p><p>Resource requests and limits help Kubernetes schedule workloads efficiently and prevent noisy-neighbor problems.</p><h3>Skipping Rollout Verification</h3><p>Always verify deployments after updates.</p><p>Use:</p><pre>kubectl rollout status</pre><p>before declaring success.</p><p>Many deployment failures are discovered only after monitoring rollout status and application health.</p><h3>The Mental Model I Use</h3><p>Whenever I think about Deployments, I imagine:</p><pre>Deployment = Manager</pre><pre>ReplicaSet = Supervisor</pre><pre>Pods = Workers</pre><p>The Deployment decides how many workers should exist.</p><p>The ReplicaSet ensures the workers are present.</p><p>The Pods perform the actual work.</p><p>If a worker disappears:</p><pre>Worker Missing<br>      ↓<br>Supervisor Replaces Worker</pre><p>If the company hires more workers:</p><pre>Manager Requests More Workers<br>      ↓<br>Supervisor Creates Them</pre><p>This simple model makes Deployments much easier to understand.</p><h3>Final Thoughts</h3><p>Deployments are one of the most important Kubernetes resources.</p><p>They allow teams to:</p><ul><li>Deploy applications safely</li><li>Scale workloads easily</li><li>Recover from failures automatically</li><li>Perform rolling updates</li><li>Roll back bad releases</li><li>Maintain application availability</li></ul><p>Without Deployments, managing applications at scale would be far more difficult.</p><p>Understanding Deployments is a major step toward understanding how Kubernetes keeps modern applications reliable, scalable, and highly available.</p><p>As you continue learning Kubernetes, you’ll discover that Deployments are often the foundation for running stateless applications in production. Nearly every Kubernetes cluster contains Deployments because they provide the automation and reliability needed for modern software delivery.</p><p>If you’re learning Kubernetes, this is one concept you should master early because almost every production application relies on Deployments.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f46264c2ab6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Autoscaling Explained: How Kubernetes Handles Growth Automatically]]></title>
            <link>https://medium.com/@shahzadaliahmad/kubernetes-autoscaling-explained-how-kubernetes-handles-growth-automatically-be2f46d4f5ba?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/be2f46d4f5ba</guid>
            <category><![CDATA[kubernetes-autoscaling]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Fri, 19 Jun 2026 13:23:15 GMT</pubDate>
            <atom:updated>2026-06-19T13:23:15.308Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AoCwhjExpLUaZvrxd41rOw.png" /><figcaption><strong>Learn how HPA, VPA, and Cluster Autoscaler work together to automatically scale applications, resources, and infrastructure while balancing performance, availability, and cost.</strong></figcaption></figure><p>One of the biggest promises of Kubernetes is its ability to automatically adapt to changing workloads.</p><p>Imagine your application receives 100 users today and suddenly 100,000 users tomorrow. In a traditional environment, scaling infrastructure often requires manual intervention, additional servers, capacity planning meetings, and careful monitoring to ensure systems do not become overloaded.</p><p>Kubernetes takes a different approach.</p><p>It can automatically increase or decrease resources based on demand, helping applications remain available while optimizing infrastructure costs. Instead of constantly guessing how much infrastructure your application might need, Kubernetes can react to real-world usage patterns and adjust resources dynamically.</p><p>This capability is known as <strong>autoscaling</strong>, and it is one of the key reasons organizations adopt Kubernetes for modern cloud-native applications.</p><p>In this article, we’ll explore how Kubernetes Autoscaling works, the different types of autoscaling available, how they interact with each other, and how they are used in production environments.</p><h3>Why Autoscaling Matters</h3><p>Every application experiences fluctuations in traffic.</p><p>Examples include:</p><ul><li>E-commerce websites during sales events</li><li>Streaming platforms during major sports events</li><li>Banking applications during salary days</li><li>SaaS platforms during business hours</li><li>Gaming platforms during new feature releases</li><li>Social media applications during viral events</li></ul><p>The challenge is that traffic patterns are rarely predictable. Some spikes happen gradually, while others occur within seconds.</p><p>Without autoscaling, you face two major challenges.</p><h3>Under-Provisioning</h3><p>Too few resources can result in:</p><ul><li>Slow application performance</li><li>Increased response times</li><li>Request failures</li><li>Application crashes</li><li>Poor user experience</li><li>Revenue loss</li></ul><p>For example, if an online store cannot handle customer traffic during a flash sale, users may abandon their purchases and move to competitors.</p><h3>Over-Provisioning</h3><p>Too many resources can lead to:</p><ul><li>Higher cloud bills</li><li>Wasted infrastructure</li><li>Low resource utilization</li><li>Inefficient capacity planning</li></ul><p>Many organizations historically solved performance problems by simply adding more servers than necessary. While this approach improves availability, it often results in paying for resources that remain idle most of the time.</p><p>Autoscaling helps strike the balance between performance and cost by ensuring resources are available when needed and removed when demand decreases.</p><h3>The Three Types of Kubernetes Autoscaling</h3><p>Kubernetes provides three major autoscaling mechanisms:</p><h4>1. Horizontal Pod Autoscaler (HPA)</h4><p>Scales the number of Pods.</p><p>Example:</p><ul><li>3 Pods → 10 Pods during traffic spike</li><li>10 Pods → 3 Pods after traffic drops</li></ul><h4>2. Vertical Pod Autoscaler (VPA)</h4><p>Scales CPU and Memory allocated to Pods.</p><p>Example:</p><ul><li>500m CPU → 2 CPU</li><li>512Mi RAM → 2Gi RAM</li></ul><h4>3. Cluster Autoscaler (CA)</h4><p>Scales worker nodes.</p><p>Example:</p><ul><li>3 Nodes → 8 Nodes</li><li>8 Nodes → 3 Nodes</li></ul><p>Each solves a different scaling problem, and in many production environments, all three work together to provide a complete autoscaling solution.</p><h3>Horizontal Pod Autoscaler (HPA)</h3><p>HPA is the most commonly used autoscaling mechanism in Kubernetes.</p><p>Instead of making individual Pods larger, HPA increases or decreases the number of Pod replicas running your application.</p><p>It automatically adjusts the number of Pods based on metrics such as:</p><ul><li>CPU utilization</li><li>Memory utilization</li><li>Custom metrics</li><li>Application metrics</li><li>External metrics</li></ul><p>For stateless applications such as web servers, APIs, and microservices, HPA is usually the preferred scaling strategy.</p><h4>How HPA Works</h4><p>Suppose you have:</p><ul><li>3 Pods</li><li>Target CPU utilization: 70%</li></ul><p>Current CPU usage rises to 90%.</p><p>Kubernetes detects the increase and creates additional Pods.</p><p>Example:</p><p>Before:</p><p>Pod-1<br>Pod-2<br>Pod-3</p><p>After scaling:</p><p>Pod-1<br>Pod-2<br>Pod-3<br>Pod-4<br>Pod-5<br>Pod-6</p><p>Traffic is now distributed across more Pods through a Kubernetes Service, reducing the load on each individual Pod.</p><p>The HPA continuously evaluates metrics at regular intervals. If utilization remains above the configured threshold, additional Pods are created. If utilization drops below the threshold for a sustained period, Pods are removed.</p><p>This process happens automatically without requiring manual intervention.</p><h4>HPA Scaling Formula</h4><p>At a high level, HPA compares:</p><p>Current Metric Value</p><p>vs</p><p>Desired Metric Value</p><p>If the current value exceeds the target, Kubernetes increases replicas.</p><p>If the current value falls below the target, Kubernetes decreases replicas.</p><p>For example:</p><p>Target CPU Utilization = 70%</p><p>Current CPU Utilization = 140%</p><p>Kubernetes may decide to double the number of replicas because the workload is consuming twice the desired CPU capacity.</p><p>This allows applications to respond dynamically to changing demand.</p><h4>Real Production Example</h4><p>Imagine an e-commerce application.</p><p>Normal traffic:</p><ul><li>5 Pods</li><li>CPU Usage: 40%</li></ul><p>Black Friday Sale:</p><ul><li>CPU Usage: 95%</li></ul><p>HPA automatically increases replicas:</p><p>5 Pods → 20 Pods</p><p>As more Pods become available, incoming requests are distributed across them through the Service layer.</p><p>When the sale ends:</p><p>20 Pods → 5 Pods</p><p>No manual intervention required.</p><p>This elasticity allows businesses to handle massive traffic spikes without permanently paying for additional infrastructure.</p><h4>HPA Architecture</h4><p>User Traffic</p><p>↓</p><p>Ingress</p><p>↓</p><p>Service</p><p>↓</p><p>Pods</p><p>↓</p><p>Metrics Server</p><p>↓</p><p>Horizontal Pod Autoscaler</p><p>The Metrics Server continuously collects resource utilization data from worker nodes.</p><p>HPA queries these metrics and compares them against configured thresholds.</p><p>Based on the results, Kubernetes updates the Deployment replica count, which causes new Pods to be created or existing Pods to be terminated.</p><h4>Custom Metrics with HPA</h4><p>CPU and Memory are not the only metrics HPA can use.</p><p>Many production systems scale based on business-specific metrics such as:</p><ul><li>Requests per second</li><li>Queue length</li><li>Active users</li><li>Kafka consumer lag</li><li>Database connections</li></ul><p>For example:</p><p>If a message queue contains 100,000 pending messages, HPA can automatically increase worker Pods to process them faster.</p><p>This makes HPA extremely flexible for real-world workloads.</p><h3>Vertical Pod Autoscaler (VPA)</h3><p>Sometimes adding more Pods is not enough.</p><p>Certain workloads require more CPU or Memory per Pod.</p><p>Examples:</p><ul><li>Machine Learning workloads</li><li>Data processing applications</li><li>Analytics engines</li><li>Batch processing jobs</li><li>Database-related workloads</li></ul><p>This is where VPA helps.</p><p>Instead of increasing the number of Pods, VPA increases the resources assigned to existing Pods.</p><h4>How VPA Works</h4><p>Suppose a Pod currently uses:</p><p>CPU: 500m</p><p>Memory: 512Mi</p><p>After analyzing workload patterns, Kubernetes determines that the Pod needs:</p><p>CPU: 2 vCPU</p><p>Memory: 2Gi</p><p>VPA automatically updates resource requests and limits.</p><p>This gives the application more resources without increasing Pod count.</p><p>VPA continuously observes resource consumption and recommends or applies adjustments based on historical usage patterns.</p><h4>VPA Modes</h4><p>VPA can operate in different modes:</p><h4>Off Mode</h4><p>Only provides recommendations.</p><p>No automatic changes are made.</p><h4>Initial Mode</h4><p>Applies recommendations only when Pods are first created.</p><h4>Auto Mode</h4><p>Automatically updates resource allocations when necessary.</p><p>Organizations often start with recommendation mode before enabling automatic updates in production.</p><h3>HPA vs VPA</h3><p>Many beginners confuse these two.</p><h3>HPA</h3><p>Scales:</p><p>Pods</p><p>Example:</p><p>3 Pods → 10 Pods</p><p>Best for:</p><ul><li>APIs</li><li>Web applications</li><li>Microservices</li></ul><h3>VPA</h3><p>Scales:</p><p>Resources inside Pods</p><p>Example:</p><p>1 CPU → 4 CPU</p><p>Best for:</p><ul><li>Data processing</li><li>Analytics workloads</li><li>Resource-intensive applications</li></ul><p>Think of it this way:</p><p>HPA = More Workers</p><p>VPA = Stronger Workers</p><p>One increases quantity.</p><p>The other increases capacity.</p><h3>Can HPA and VPA Be Used Together?</h3><p>Yes, but with caution.</p><p>Both systems influence resource allocation and can sometimes conflict with each other.</p><p>Modern Kubernetes environments often combine:</p><ul><li>HPA for scaling replicas</li><li>VPA for recommendations</li><li>Cluster Autoscaler for node scaling</li></ul><p>This provides a balanced and efficient scaling strategy.</p><h3>Cluster Autoscaler</h3><p>Now let’s consider another problem.</p><p>What happens if HPA creates more Pods but there is no space available on worker nodes?</p><p>The Pods remain in a Pending state.</p><p>Example:</p><p>Node-1 (Full)</p><p>Node-2 (Full)</p><p>Node-3 (Full)</p><p>New Pods cannot be scheduled.</p><p>Even though Kubernetes wants to create more Pods, there is simply not enough infrastructure available.</p><p>This is where Cluster Autoscaler becomes important.</p><h3>How Cluster Autoscaler Works</h3><p>Cluster Autoscaler monitors:</p><ul><li>Pending Pods</li><li>Available node resources</li><li>Node utilization</li><li>Scheduling failures</li></ul><p>If Pods cannot be scheduled:</p><p>3 Nodes → 6 Nodes</p><p>New worker nodes are automatically added.</p><p>Once demand decreases:</p><p>6 Nodes → 3 Nodes</p><p>Unused nodes are removed.</p><p>This ensures that the cluster itself grows and shrinks according to workload requirements.</p><h3>Cluster Autoscaler Workflow</h3><p>Step 1:</p><p>HPA creates additional Pods.</p><p>Step 2:</p><p>Scheduler attempts to place Pods on worker nodes.</p><p>Step 3:</p><p>No node has sufficient resources.</p><p>Step 4:</p><p>Pods remain Pending.</p><p>Step 5:</p><p>Cluster Autoscaler detects unschedulable Pods.</p><p>Step 6:</p><p>New nodes are provisioned.</p><p>Step 7:</p><p>Pending Pods are scheduled successfully.</p><p>This process allows Kubernetes to scale beyond the limits of existing infrastructure.</p><h3>Real Cloud Example</h3><p>In AWS EKS:</p><p>Cluster Autoscaler works with:</p><ul><li>Auto Scaling Groups</li><li>Managed Node Groups</li></ul><p>When additional capacity is required, AWS automatically launches new EC2 instances.</p><p>In Azure AKS:</p><p>Cluster Autoscaler automatically adds or removes VM nodes based on workload demand.</p><p>In Google GKE:</p><p>Node pools scale automatically, allowing clusters to expand and contract without manual intervention.</p><p>This cloud integration is one of the reasons Kubernetes autoscaling is so powerful.</p><h3>How All Three Work Together</h3><p>Let’s imagine a major product launch.</p><p>Traffic suddenly increases.</p><h4>Step 1</h4><p>CPU usage increases.</p><p>HPA creates more Pods.</p><p>5 Pods → 20 Pods</p><h4>Step 2</h4><p>Nodes become full.</p><p>Cluster Autoscaler adds more worker nodes.</p><p>3 Nodes → 8 Nodes</p><h4>Step 3</h4><p>Some Pods require additional resources.</p><p>VPA increases CPU and Memory allocation.</p><h4>Step 4</h4><p>Traffic stabilizes.</p><p>CPU utilization decreases.</p><p>HPA reduces Pod count.</p><h4>Step 5</h4><p>Unused nodes become empty.</p><p>Cluster Autoscaler removes unnecessary worker nodes.</p><p>Result:</p><ul><li>Application remains healthy</li><li>Users experience no downtime</li><li>Infrastructure scales automatically</li><li>Cloud costs remain optimized</li></ul><p>This coordinated scaling behavior is what makes Kubernetes highly resilient and efficient.</p><h3>Common Production Mistakes</h3><h4>No Resource Requests Defined</h4><p>HPA depends on resource requests.</p><p>Without them:</p><p>Autoscaling becomes inaccurate.</p><p>Always define realistic CPU and Memory requests so Kubernetes can make informed scaling decisions.</p><h4>Aggressive Scaling</h4><p>Scaling too quickly can cause:</p><ul><li>Application instability</li><li>Resource thrashing</li><li>Increased cloud costs</li><li>Frequent Pod restarts</li></ul><p>Scaling policies should be carefully tuned based on workload behavior.</p><h4>Ignoring Cooldown Periods</h4><p>Rapid scaling up and down can create unnecessary churn.</p><p>Always configure stabilization windows and cooldown periods to prevent constant fluctuations.</p><h4>Not Monitoring Scaling Events</h4><p>Autoscaling is not “set and forget.”</p><p>Monitor:</p><ul><li>Scaling frequency</li><li>CPU trends</li><li>Memory usage</li><li>Cost impact</li><li>Node utilization</li><li>Pending Pods</li></ul><p>Observability is critical for understanding whether autoscaling is behaving as expected.</p><h4>Scaling Stateful Applications Incorrectly</h4><p>Not every application scales horizontally.</p><p>Databases and stateful workloads often require special consideration.</p><p>Before enabling autoscaling, understand how your application handles state, sessions, and data consistency.</p><h3>Best Practices</h3><h4>Use HPA for Most Applications</h4><p>It provides the highest value with minimal complexity and works well for stateless workloads.</p><h4>Define Resource Requests and Limits</h4><p>This improves scheduling and scaling accuracy.</p><h4>Enable Cluster Autoscaler</h4><p>Especially in cloud environments where infrastructure can be provisioned automatically.</p><h4>Monitor Scaling Metrics</h4><p>Use:</p><ul><li>Prometheus</li><li>Grafana</li><li>New Relic</li><li>Datadog</li><li>Cloud-native monitoring tools</li></ul><h4>Test Before Production</h4><p>Simulate traffic spikes and observe scaling behavior.</p><p>Load testing helps identify bottlenecks before real users encounter them.</p><h4>Start Small</h4><p>Begin with conservative scaling thresholds and gradually optimize based on observed workload patterns.</p><h3>Final Thoughts</h3><p>Autoscaling is one of Kubernetes’ most powerful capabilities.</p><p>Instead of manually provisioning servers and worrying about traffic spikes, Kubernetes can automatically scale Pods, resources, and nodes based on demand.</p><p>Understanding the relationship between:</p><ul><li>Horizontal Pod Autoscaler (HPA)</li><li>Vertical Pod Autoscaler (VPA)</li><li>Cluster Autoscaler (CA)</li></ul><p>is essential for every Kubernetes Engineer, DevOps Engineer, SRE, and Platform Engineer.</p><p>HPA ensures your applications can handle increased traffic.</p><p>VPA ensures workloads receive the resources they need.</p><p>Cluster Autoscaler ensures the underlying infrastructure can support those workloads.</p><p>Together, they create a highly elastic platform capable of adapting to changing business demands automatically.</p><p>Once you understand autoscaling, Kubernetes starts to feel less like a container orchestration platform and more like a self-managing infrastructure system.</p><p>And that’s where the real power of Kubernetes begins.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be2f46d4f5ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ingress Explained: How Kubernetes Handles HTTP and HTTPS Traffic at Scale]]></title>
            <link>https://medium.com/@shahzadaliahmad/ingress-explained-how-kubernetes-handles-http-and-https-traffic-at-scale-38ec363676d3?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/38ec363676d3</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Fri, 19 Jun 2026 02:19:08 GMT</pubDate>
            <atom:updated>2026-06-19T12:26:06.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LrSIh7_jLdhma4jaEEdjbQ.png" /><figcaption>Every request entering a Kubernetes cluster follows a carefully designed path. And how Ingress Controllers, Load Balancers, Services, and Pods work together to route, secure, and scale traffic for modern cloud-native applications.</figcaption></figure><p>Understanding the traffic gateway that powers modern Kubernetes applications.</p><h3>Introduction</h3><p>When people start learning Kubernetes, one of the first challenges they face is exposing applications so users can access them.</p><p>The typical journey looks something like this:</p><ol><li>Create a Pod</li><li>Create a Deployment</li><li>Create a Service</li></ol><p>At first, everything seems straightforward.</p><p>Your application is running, the Service exposes it, and users can access it.</p><p>However, as your Kubernetes environment grows, things become more complicated.</p><p>Imagine your cluster is running multiple applications:</p><ul><li>A frontend web application</li><li>A backend API</li><li>An admin dashboard</li><li>Monitoring tools like Grafana</li><li>Internal business applications</li></ul><p>Now you start asking questions such as:</p><ul><li>How can I expose multiple applications using a single public IP address?</li><li>How can I route traffic to different applications based on the URL?</li><li>How can I host multiple websites on the same Kubernetes cluster?</li><li>How do I manage HTTPS certificates efficiently?</li><li>How do large organizations expose hundreds of services without creating hundreds of load balancers?</li></ul><p>These are exactly the problems that Kubernetes Ingress was designed to solve.</p><p>Ingress is one of the most important networking components in Kubernetes. It acts as the entry point for external HTTP and HTTPS traffic and provides intelligent routing to services running inside the cluster.</p><p>In this article, we’ll explore:</p><ul><li>Why Ingress exists</li><li>The limitations of Services</li><li>How Ingress works</li><li>What an Ingress Controller does</li><li>Host-based and path-based routing</li><li>HTTPS and TLS termination</li><li>Real-world production use cases</li></ul><p>By the end, you’ll have a clear understanding of how Kubernetes handles web traffic at scale.</p><h3>The Problem with Services</h3><p>Before understanding Ingress, it’s important to understand the limitations of Services.</p><p>Suppose you have three applications running inside your cluster:</p><pre>Frontend Application<br>Backend API<br>Monitoring Dashboard</pre><p>Each application is exposed using a Kubernetes Service:</p><pre>frontend-service<br>api-service<br>grafana-service</pre><p>One common way to expose these services externally is by using:</p><pre>type: LoadBalancer</pre><p>In most cloud providers, Kubernetes automatically creates a cloud load balancer and assigns a public IP address.</p><p>You might end up with something like:</p><pre>35.10.10.1 → Frontend<br>35.10.10.2 → API<br>35.10.10.3 → Grafana</pre><p>Technically, this works.</p><p>Users can access each application independently.</p><p>However, several problems quickly appear.</p><h4>Problem 1: Too Many Public IP Addresses</h4><p>Every service gets its own external IP.</p><pre>Frontend → Public IP<br>API → Public IP<br>Grafana → Public IP</pre><p>Managing dozens or hundreds of IP addresses becomes difficult.</p><h4>Problem 2: Increased Cloud Costs</h4><p>Cloud load balancers are not free.</p><p>If every application requires its own load balancer, costs can increase significantly.</p><p>For example:</p><pre>100 Applications<br>=<br>100 Load Balancers</pre><p>This can become expensive very quickly.</p><h4>Problem 3: DNS Management Becomes Complex</h4><p>You must manage DNS records for every application.</p><pre>frontend.company.com<br>api.company.com<br>grafana.company.com</pre><p>Each record points to a different IP address.</p><p>As applications grow, DNS management becomes harder.</p><h4>Problem 4: SSL Certificate Management</h4><p>Every application may require its own HTTPS certificate.</p><p>Managing certificates individually creates operational overhead.</p><h4>Problem 5: Poor Scalability</h4><p>As the number of applications increases, managing separate load balancers becomes inefficient.</p><p>There needs to be a centralized way to manage incoming traffic.</p><p>This is where Ingress becomes valuable.</p><h3>Enter Ingress</h3><p>Ingress allows multiple applications to share a single external entry point.</p><p>Instead of creating separate load balancers:</p><pre>app1.example.com → LB1<br>app2.example.com → LB2<br>app3.example.com → LB3</pre><p>You can use a single load balancer:</p><pre>Single Load Balancer<br>        |<br>        |<br>     Ingress<br>        |<br>--------------------------------<br>|            |                |<br>app1       app2           app3</pre><p>Now all incoming traffic enters through one gateway.</p><p>Ingress examines each request and decides where it should go.</p><p>Think of Ingress as a receptionist at the entrance of a large office building.</p><p>Everyone enters through the same door.</p><p>The receptionist checks where visitors need to go and directs them to the correct department.</p><p>Ingress performs the same role for HTTP and HTTPS traffic.</p><h3>What Is Kubernetes Ingress?</h3><p>Ingress is a Kubernetes API resource that defines rules for routing external traffic to services inside the cluster.</p><p>It does not expose Pods directly.</p><p>Instead, it exposes Services.</p><p>Think of Ingress as a collection of routing rules.</p><p>For example:</p><pre>https://company.com<br>        |<br>     Ingress<br>      /   \<br>     /     \<br>frontend   api</pre><p>The Ingress resource tells Kubernetes:</p><pre>company.com        → Frontend Service<br>company.com/api    → API Service<br>company.com/admin  → Admin Service</pre><p>When a request arrives, Ingress evaluates the rules and forwards traffic to the correct service.</p><p>This allows multiple applications to share the same public endpoint.</p><h3>Ingress vs Service</h3><p>Many Kubernetes beginners confuse Services and Ingress because both are involved in networking.</p><p>Let’s clearly separate their responsibilities.</p><h3>What Does a Service Do?</h3><p>A Service provides a stable way to access Pods.</p><pre>Pods<br> ↓<br>Service</pre><p>Services solve several problems:</p><ul><li>Pods are temporary</li><li>Pod IPs change</li><li>Applications need a stable endpoint</li></ul><p>A Service provides:</p><ul><li>Stable virtual IP</li><li>Service discovery</li><li>Internal load balancing</li></ul><p>For example:</p><pre>frontend-service</pre><p>may distribute traffic across:</p><pre>Pod A<br>Pod B<br>Pod C</pre><p>without users knowing which Pod handled the request.</p><h3>What Does Ingress Do?</h3><p>Ingress sits above Services.</p><pre>Pods<br> ↓<br>Service<br> ↓<br>Ingress<br> ↓<br>Internet</pre><p>Ingress provides:</p><ul><li>HTTP routing</li><li>HTTPS support</li><li>Domain-based routing</li><li>URL-based routing</li><li>SSL termination</li><li>Traffic management</li></ul><p>A simple way to remember this is:</p><pre>Service = Exposes Pods</pre><pre>Ingress = Exposes Services</pre><h3>The Missing Piece: Ingress Controller</h3><p>One of the most important concepts to understand is:</p><blockquote><em>An Ingress resource by itself does nothing.</em></blockquote><p>Many beginners create an Ingress object and expect traffic to start flowing automatically.</p><p>But Ingress is only a configuration.</p><p>Something must read those rules and enforce them.</p><p>That “something” is called an Ingress Controller.</p><p>Without an Ingress Controller:</p><pre>kind: Ingress</pre><p>is simply a YAML object stored in Kubernetes.</p><p>No traffic routing occurs.</p><h3>What Is an Ingress Controller?</h3><p>An Ingress Controller is software running inside the cluster that watches Ingress resources and configures traffic routing accordingly.</p><p>Popular Ingress Controllers include:</p><ul><li>NGINX Ingress Controller</li><li>Traefik</li><li>HAProxy</li><li>Kong</li><li>Istio Gateway</li><li>AWS Load Balancer Controller</li><li>Azure Application Gateway</li></ul><p>Think of it this way:</p><pre>Ingress Resource<br>      ↓<br>Configuration</pre><pre>Ingress Controller<br>      ↓<br>Traffic Processing</pre><p>A useful analogy:</p><pre>Ingress = Map</pre><pre>Ingress Controller = Driver</pre><p>A map tells you where to go.</p><p>The driver actually moves the vehicle.</p><p>Similarly, Ingress defines routing rules, while the controller performs the routing.</p><h3>How Traffic Flows Through Ingress</h3><p>Let’s follow a real request from a user.</p><p>Suppose someone opens:</p><pre>https://app.company.com</pre><p>The request travels through several layers before reaching the application.</p><pre>User<br> ↓<br>DNS<br> ↓<br>Load Balancer<br> ↓<br>Ingress Controller<br> ↓<br>Service<br> ↓<br>Pod</pre><p>Let’s examine each step.</p><h4>Step 1: DNS Resolution</h4><p>The browser first asks DNS:</p><pre>Where is app.company.com?</pre><p>DNS responds with a public IP address.</p><pre>app.company.com<br>      ↓<br>35.10.10.1</pre><h4>Step 2: Request Reaches the Load Balancer</h4><p>The browser sends the request to the public IP.</p><p>The cloud load balancer receives the traffic.</p><h4>Step 3: Load Balancer Forwards Traffic</h4><p>The load balancer forwards traffic to the Ingress Controller running inside the cluster.</p><h4>Step 4: Ingress Controller Evaluates Rules</h4><p>The controller examines the request.</p><p>For example:</p><pre>host: app.company.com</pre><p>It checks whether a matching rule exists.</p><h4>Step 5: Traffic Is Sent to the Correct Service</h4><p>If a matching rule is found:</p><pre>app.company.com<br>      ↓<br>frontend-service</pre><p>the request is forwarded to that Service.</p><h4>Step 6: Service Selects a Pod</h4><p>The Service chooses one of the healthy Pods.</p><pre>frontend-service<br>      ↓<br>Pod A</pre><p>or</p><pre>frontend-service<br>      ↓<br>Pod B</pre><h4>Step 7: Pod Processes the Request</h4><p>The application processes the request and generates a response.</p><p>The response travels back through the same path:</p><pre>Pod<br> ↓<br>Service<br> ↓<br>Ingress Controller<br> ↓<br>Load Balancer<br> ↓<br>User</pre><h3>Host-Based Routing</h3><p>Host-based routing is one of the most common Ingress features.</p><p>Suppose your company owns:</p><pre>app.company.com<br>api.company.com<br>grafana.company.com</pre><p>You want each hostname to reach a different application.</p><p>Ingress rules might look like:</p><pre>rules:<br>- host: app.company.com<br>  service: frontend</pre><pre>- host: api.company.com<br>  service: api</pre><pre>- host: grafana.company.com<br>  service: grafana</pre><p>Result:</p><pre>app.company.com      → Frontend<br>api.company.com      → API<br>grafana.company.com  → Grafana</pre><p>All applications share the same Ingress infrastructure while appearing as separate websites to users.</p><h3>Path-Based Routing</h3><p>Sometimes multiple applications share the same domain.</p><p>Instead of routing by hostname, you route by URL path.</p><p>Example:</p><pre>company.com/<br>company.com/api<br>company.com/admin</pre><p>Ingress rules:</p><pre>/<br>→ Frontend</pre><pre>/api<br>→ Backend API</pre><pre>/admin<br>→ Admin Portal</pre><p>Traffic flow:</p><pre>company.com/<br>      ↓<br>Frontend</pre><pre>company.com/api<br>      ↓<br>API Service</pre><pre>company.com/admin<br>      ↓<br>Admin Service</pre><p>Users see a single website, but Ingress distributes requests to different backend services.</p><h3>HTTPS and SSL Termination</h3><p>Today, almost every production application uses HTTPS.</p><p>HTTPS provides:</p><ul><li>Encryption</li><li>Data integrity</li><li>Authentication</li><li>User trust</li></ul><p>Without HTTPS, sensitive information can be intercepted during transmission.</p><h4>The Challenge Without Ingress</h4><p>Imagine three applications:</p><pre>Frontend<br>API<br>Grafana</pre><p>Each application requires:</p><pre>SSL Certificate<br>Private Key<br>Certificate Renewal</pre><p>Managing certificates separately becomes difficult.</p><h4>The Ingress Solution</h4><p>Ingress centralizes HTTPS management.</p><pre>Internet<br>   ↓<br>HTTPS<br>   ↓<br>Ingress Controller<br>   ↓<br>Services</pre><p>The Ingress Controller handles certificates and encrypted connections.</p><p>Applications behind the controller don’t need to manage certificates individually.</p><h4>What Is SSL Termination?</h4><p>SSL termination means the encrypted HTTPS connection ends at the Ingress Controller.</p><pre>Browser<br>   ↓ HTTPS<br>Ingress Controller<br>   ↓ HTTP<br>Application</pre><p>The controller decrypts traffic and forwards it internally.</p><p>Benefits include:</p><ul><li>Easier certificate management</li><li>Reduced application complexity</li><li>Centralized security controls</li><li>Simplified operations</li></ul><h3>TLS Example</h3><p>A simple TLS configuration looks like this:</p><pre>tls:<br>- hosts:<br>  - app.company.com<br>  secretName: app-tls</pre><p>The certificate is stored inside a Kubernetes Secret.</p><pre>Secret<br>  ↓<br>TLS Certificate<br>  ↓<br>Ingress Controller</pre><p>When users visit:</p><pre>https://app.company.com</pre><p>the controller automatically serves the correct certificate.</p><h3>Why Ingress Scales So Well</h3><p>Ingress was designed for large-scale environments.</p><p>Imagine a company running:</p><pre>100 Microservices</pre><p>Without Ingress:</p><pre>100 Load Balancers</pre><p>With Ingress:</p><pre>1 Load Balancer<br>       ↓<br>Ingress Controller<br>       ↓<br>100 Services</pre><p>This architecture provides several advantages.</p><h4>Lower Costs</h4><p>Fewer load balancers mean lower cloud expenses.</p><h4>Easier Operations</h4><p>Traffic management becomes centralized.</p><h4>Better Security</h4><p>Security policies can be enforced in one place.</p><h4>Better Monitoring</h4><p>All incoming traffic passes through a common entry point.</p><h4>Simplified Certificate Management</h4><p>Certificates can be managed centrally.</p><p>This is why Ingress is widely used in production Kubernetes environments.</p><h3>Common Production Features</h3><p>Modern Ingress Controllers provide much more than simple routing.</p><h4>Rate Limiting</h4><p>Protect applications from abuse.</p><p>Example:</p><pre>100 requests/sec per user</pre><p>This helps prevent denial-of-service attacks and excessive traffic.</p><h4>Authentication</h4><p>Require users to authenticate before accessing applications.</p><p>Examples:</p><ul><li>OAuth</li><li>OpenID Connect</li><li>LDAP</li><li>SSO</li></ul><h4>IP Whitelisting</h4><p>Allow access only from approved IP addresses.</p><p>Example:</p><pre>Office Network Only</pre><p>Useful for internal dashboards and administrative tools.</p><h4>Redirects</h4><p>Automatically redirect:</p><pre>http://</pre><p>to:</p><pre>https://</pre><p>ensuring secure communication.</p><h4>Canary Releases</h4><p>Gradually release new versions.</p><p>Example:</p><pre>90% → Version 1<br>10% → Version 2</pre><p>This reduces deployment risk.</p><h4>Traffic Splitting</h4><p>Distribute traffic between multiple versions of an application.</p><p>Useful for:</p><ul><li>Blue-Green Deployments</li><li>A/B Testing</li><li>Progressive Delivery</li></ul><h3>When Should You Use Ingress?</h3><p>Ingress is a great choice when:</p><p>✅ Multiple applications need external access</p><p>✅ You need HTTPS support</p><p>✅ You want host-based routing</p><p>✅ You want path-based routing</p><p>✅ You want centralized certificate management</p><p>✅ You want centralized traffic control</p><p>✅ You need production-grade web traffic handling</p><p>For simple internal workloads, a Service may be sufficient.</p><p>For internet-facing applications, Ingress is usually the preferred solution.</p><h3>The Mental Model I Use</h3><p>Whenever I think about Ingress, I visualize the complete request path:</p><pre>Internet<br>   ↓<br>Load Balancer<br>   ↓<br>Ingress Controller<br>   ↓<br>Service<br>   ↓<br>Pod</pre><p>And I remember this simple rule:</p><pre>Service = Exposes Pods</pre><pre>Ingress = Exposes Services</pre><p>If you understand that relationship, Kubernetes networking becomes much easier to reason about.</p><h3>Final Thoughts</h3><p>Ingress is one of the most important networking components in Kubernetes.</p><p>It acts as the front door of your cluster, receiving HTTP and HTTPS requests from users and routing them to the correct applications.</p><p>By introducing a centralized entry point, Ingress helps organizations:</p><ul><li>Reduce infrastructure costs</li><li>Simplify DNS management</li><li>Manage HTTPS certificates efficiently</li><li>Improve security</li><li>Scale to hundreds of applications</li><li>Implement advanced traffic management strategies</li></ul><p>While Services provide connectivity to Pods, Ingress provides intelligent routing and traffic control for external users.</p><p>Once you understand how Ingress works, many Kubernetes production architectures become much easier to understand because you’ll recognize the common pattern used by most organizations:</p><pre>Internet<br>   ↓<br>Load Balancer<br>   ↓<br>Ingress Controller<br>   ↓<br>Services<br>   ↓<br>Pods</pre><p>Ingress is not just another Kubernetes resource — it’s the gateway that makes large-scale Kubernetes applications accessible, secure, and manageable.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38ec363676d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Kubernetes Control Plane Like a DevOps Engineer]]></title>
            <link>https://medium.com/@shahzadaliahmad/understanding-the-kubernetes-control-plane-like-a-devops-engineer-40cf5ed3a097?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/40cf5ed3a097</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 01:52:15 GMT</pubDate>
            <atom:updated>2026-06-18T01:52:15.280Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mi-qoaeRDK1bIR2Ex3FR0A.png" /><figcaption>The Kubernetes Control Plane is the brain of the cluster — handling scheduling, orchestration, self-healing, and state management behind every application you deploy. Understanding these components is the key to becoming a better Kubernetes and DevOps engineer.</figcaption></figure><p>Kubernetes Control Plane explained in a practical way for engineers who manage real-world clusters.</p><h3>Introduction</h3><p>When I first started learning Kubernetes, I could create Pods, Deployments, and Services without much trouble.</p><p>I learned the commands, deployed applications, exposed services, and even scaled workloads.</p><p>But there was one thing that always felt like a black box:</p><p><strong>The Kubernetes Control Plane.</strong></p><p>Everyone says:</p><blockquote><em>“The Control Plane manages the cluster.”</em></blockquote><p>But what does that actually mean?</p><p>What happens behind the scenes when you run a simple command like:</p><pre>kubectl apply -f deployment.yaml</pre><p>How does Kubernetes know where to place Pods?</p><p>Who decides which node should run them?</p><p>Who notices when a Pod crashes?</p><p>Who creates a replacement Pod?</p><p>Who ensures that the cluster always matches what you defined in your YAML files?</p><p>The answer to all these questions lies inside the Kubernetes Control Plane.</p><p>Understanding the Control Plane is one of the biggest steps toward becoming a confident Kubernetes engineer. Once you understand how these components work together, troubleshooting becomes easier, cluster behavior becomes more predictable, and many Kubernetes concepts suddenly make sense.</p><p>In this article, I’ll explain the Kubernetes Control Plane in a practical and beginner-friendly way, focusing on what each component does and how they work together to keep your applications running.</p><h3>What Is the Kubernetes Control Plane?</h3><p>Think of Kubernetes as a city.</p><p>The worker nodes are the buildings where people live and work.</p><p>The applications running inside Pods are the citizens.</p><p>The Control Plane is the city administration.</p><p>The administration doesn’t do the actual work happening inside the buildings. Instead, it manages the city, enforces rules, allocates resources, and ensures everything operates smoothly.</p><p>Similarly, the Kubernetes Control Plane does not run your application containers directly.</p><p>Instead, it:</p><ul><li>Receives instructions from users</li><li>Stores cluster information</li><li>Decides where workloads should run</li><li>Monitors cluster health</li><li>Replaces failed workloads</li><li>Maintains the desired state of the cluster</li></ul><p>Without the Control Plane:</p><ul><li>No Pods would be scheduled</li><li>No Deployments would be created</li><li>No scaling would occur</li><li>No self-healing would exist</li><li>No cluster management would be possible</li></ul><p>The Control Plane is essentially the brain of Kubernetes.</p><p>Its primary responsibility is to continuously compare what the cluster <strong>should look like</strong> with what it <strong>currently looks like</strong>, and then take actions to eliminate any differences.</p><h3>The Main Components of the Control Plane</h3><p>The Kubernetes Control Plane is made up of several components that work together.</p><p>Each component has a specific responsibility, and together they create the automation that Kubernetes is famous for.</p><h4>1. API Server</h4><p>The API Server is the most important component of the Control Plane.</p><p>It acts as the central communication hub for the entire cluster.</p><p>Every interaction with Kubernetes goes through the API Server.</p><p>Examples:</p><pre>kubectl get pods</pre><pre>kubectl apply -f deployment.yaml</pre><pre>kubectl delete pod nginx</pre><p>Even when internal Kubernetes components communicate with each other, they usually do so through the API Server.</p><h4>What Does the API Server Do?</h4><p>The API Server performs several critical tasks:</p><ul><li>Receives requests from users and components</li><li>Authenticates users</li><li>Authorizes actions</li><li>Validates resource definitions</li><li>Processes API requests</li><li>Stores and retrieves data from etcd</li></ul><p>For example, when you create a Deployment, the API Server checks whether the YAML file is valid and whether you have permission to create that resource.</p><p>Only after validation does it save the information into Kubernetes.</p><p>Think of the API Server as the receptionist and gatekeeper of the cluster.</p><p>Nothing enters or leaves Kubernetes without passing through it.</p><h4>2. etcd</h4><p>If the API Server is the front door, then <strong>etcd</strong> is the storage room where all cluster information is kept.</p><p>etcd is a distributed key-value database used by Kubernetes.</p><p>It stores the entire state of the cluster.</p><p>This includes:</p><ul><li>Pods</li><li>Deployments</li><li>Services</li><li>Secrets</li><li>ConfigMaps</li><li>Nodes</li><li>Namespaces</li><li>Persistent Volumes</li><li>Cluster configuration</li></ul><p>Every important piece of information about your cluster lives inside etcd.</p><h4>Why Is etcd So Important?</h4><p>Imagine your cluster suddenly loses its etcd database.</p><p>Even if your worker nodes are still running, Kubernetes would lose knowledge about:</p><ul><li>Which Deployments exist</li><li>Which Services exist</li><li>Desired replica counts</li><li>Cluster configuration</li></ul><p>This is why etcd backups are considered one of the most important parts of Kubernetes disaster recovery.</p><h4>Example</h4><p>When you run:</p><pre>kubectl apply -f deployment.yaml</pre><p>the Deployment definition is ultimately stored inside etcd.</p><p>From that point onward, Kubernetes treats that stored definition as the desired state of the cluster.</p><p>You can think of etcd as Kubernetes’ memory.</p><p>Without memory, the brain cannot function.</p><h4>3. Scheduler</h4><p>Once Kubernetes knows that a Pod needs to be created, another question arises:</p><blockquote><em>Where should this Pod run?</em></blockquote><p>This decision is made by the Kubernetes Scheduler.</p><p>The Scheduler’s job is to find the most suitable worker node for every unscheduled Pod.</p><p>Suppose you create a Deployment with:</p><pre>replicas: 3</pre><p>Kubernetes now needs three Pods.</p><p>The Scheduler evaluates all available nodes and determines the best placement.</p><h4>What Does the Scheduler Consider?</h4><p>The Scheduler looks at many factors, including:</p><ul><li>Available CPU resources</li><li>Available memory resources</li><li>Resource requests and limits</li><li>Node selectors</li><li>Affinity and anti-affinity rules</li><li>Taints and tolerations</li><li>Node health</li><li>Existing workloads</li></ul><p>For example, if a node does not have enough memory available, the Scheduler may choose another node.</p><p>If a Pod requires a specific label such as:</p><pre>nodeSelector:<br>  environment: production</pre><p>the Scheduler will only consider nodes matching that label.</p><h4>What Happens Without the Scheduler?</h4><p>Without the Scheduler, Pods would remain stuck in:</p><pre>Pending</pre><p>because Kubernetes would know that Pods need to exist but would have no idea where to place them.</p><p>The Scheduler is essentially the decision-maker responsible for workload placement.</p><h4>4. Controller Manager</h4><p>Controllers are arguably the most powerful part of Kubernetes.</p><p>They are responsible for maintaining the desired state of the cluster.</p><p>Their logic is simple:</p><blockquote><em>Observe the current state, compare it with the desired state, and take corrective action if they differ.</em></blockquote><p>This process runs continuously.</p><h4>Desired State vs Actual State</h4><p>Suppose your Deployment specifies:</p><pre>replicas: 3</pre><p>This means your desired state is:</p><pre>running pods: 3</pre><p>Now imagine one Pod crashes.</p><p>The actual state becomes:</p><pre>running pods: 2</pre><p>The Controller notices the mismatch.</p><p>It immediately creates another Pod to restore the desired state.</p><p>This automatic correction is what we call <strong>self-healing</strong>.</p><h4>Why Controllers Matter</h4><p>Without Controllers:</p><ul><li>Failed Pods would never be replaced</li><li>Scaling would not work</li><li>Deployments would not progress</li><li>Cluster state would drift over time</li></ul><p>Controllers are constantly watching the cluster and making adjustments whenever necessary.</p><p>They are the reason Kubernetes can operate with minimal human intervention.</p><h3>Common Controllers</h3><p>The Controller Manager runs multiple controllers, each responsible for a specific resource type.</p><h4>Deployment Controller</h4><p>The Deployment Controller manages Deployments.</p><p>It ensures that the correct ReplicaSets exist and that rolling updates happen correctly.</p><h4>ReplicaSet Controller</h4><p>The ReplicaSet Controller ensures that the required number of Pod replicas are running.</p><p>If a Pod disappears, it creates a replacement.</p><h4>Node Controller</h4><p>The Node Controller monitors worker nodes.</p><p>If a node becomes unreachable, Kubernetes can take corrective actions and reschedule workloads elsewhere.</p><h4>Job Controller</h4><p>The Job Controller manages batch workloads and ensures that Jobs complete successfully.</p><h4>Endpoint Controller</h4><p>The Endpoint Controller updates Service endpoints whenever Pods are added or removed.</p><p>Together, these controllers continuously monitor cluster resources and keep everything aligned with the desired state.</p><h4>5. Cloud Controller Manager</h4><p>When Kubernetes runs in cloud environments such as AWS, Azure, or Google Cloud, it needs a way to interact with cloud-specific services.</p><p>This responsibility belongs to the Cloud Controller Manager.</p><p>It acts as a bridge between Kubernetes and the cloud provider.</p><h4>Common Tasks</h4><p>The Cloud Controller Manager can:</p><ul><li>Create cloud load balancers</li><li>Manage cloud networking routes</li><li>Attach and detach storage volumes</li><li>Manage cloud-based node information</li></ul><p>For example, when you create a Service of type LoadBalancer:</p><pre>type: LoadBalancer</pre><p>Kubernetes communicates with the cloud provider through the Cloud Controller Manager.</p><p>The cloud provider then creates an actual load balancer and assigns a public IP address.</p><p>Without this component, Kubernetes would not know how to interact with cloud infrastructure.</p><h3>What Happens When You Create a Deployment?</h3><p>Let’s walk through the complete lifecycle of a Deployment request.</p><p>You execute:</p><pre>kubectl apply -f deployment.yaml</pre><h4>Step 1</h4><p>kubectl sends the Deployment definition to the API Server.</p><h4>Step 2</h4><p>The API Server authenticates the request, validates the YAML, and checks permissions.</p><h4>Step 3</h4><p>The Deployment definition is stored inside etcd.</p><p>At this point, Kubernetes knows what the desired state should be.</p><h4>Step 4</h4><p>The Deployment Controller notices that a new Deployment has been created.</p><h4>Step 5</h4><p>The Deployment Controller creates a ReplicaSet.</p><h4>Step 6</h4><p>The ReplicaSet Controller creates the required Pods.</p><h4>Step 7</h4><p>The Scheduler detects Pods that have not yet been assigned to any node.</p><h4>Step 8</h4><p>The Scheduler evaluates available nodes and selects the most suitable ones.</p><h4>Step 9</h4><p>The selected nodes receive instructions through their Kubelets.</p><h4>Step 10</h4><p>Kubelet pulls the container image and starts the containers.</p><h4>Step 11</h4><p>The Pods become healthy and transition to the Running state.</p><p>Your application is now live.</p><p>Although this process involves multiple components, it usually completes within seconds.</p><h3>How Self-Healing Actually Works</h3><p>Self-healing is one of Kubernetes’ most valuable features.</p><p>Let’s see how it works in practice.</p><p>Imagine you have a Deployment configured with:</p><pre>replicas: 3</pre><p>The cluster currently has:</p><pre>Desired Pods = 3<br>Actual Pods = 3</pre><p>Everything is healthy.</p><p>Now suppose one Pod crashes unexpectedly.</p><p>The cluster state becomes:</p><pre>Desired Pods = 3<br>Actual Pods = 2</pre><p>The Controller immediately notices the difference.</p><p>It creates a replacement Pod.</p><p>The Scheduler assigns the new Pod to a suitable node.</p><p>The Kubelet starts the container.</p><p>After a short period, the cluster returns to:</p><pre>Desired Pods = 3<br>Actual Pods = 3</pre><p>No administrator needs to log in.</p><p>No manual restart is required.</p><p>Kubernetes automatically restores the desired state.</p><p>This continuous reconciliation process is the foundation of Kubernetes automation.</p><h3>Why DevOps Engineers Must Understand the Control Plane</h3><p>Many engineers know how to use Kubernetes commands.</p><p>Far fewer understand what happens behind those commands.</p><p>Understanding the Control Plane provides significant advantages.</p><h4>Faster Troubleshooting</h4><p>When Pods remain stuck in:</p><pre>Pending</pre><p>you immediately know to investigate the Scheduler.</p><p>When Deployments fail to maintain replicas:</p><p>Think Controllers.</p><p>When cluster data disappears:</p><p>Think etcd.</p><p>When API requests fail:</p><p>Think API Server.</p><p>Understanding component responsibilities dramatically reduces troubleshooting time.</p><h4>Better Cluster Design</h4><p>Knowledge of the Control Plane helps you design more reliable clusters.</p><p>You’ll make better decisions regarding:</p><ul><li>High availability</li><li>Multi-control-plane architectures</li><li>Backup strategies</li><li>Disaster recovery planning</li><li>Cluster scaling</li></ul><h4>Better Interviews</h4><p>Many Kubernetes interviews focus heavily on Control Plane concepts.</p><p>Questions such as:</p><ul><li>What is etcd?</li><li>What does the Scheduler do?</li><li>How does the API Server work?</li><li>What are Controllers?</li><li>How does Kubernetes self-heal workloads?</li></ul><p>become much easier to answer when you understand the architecture behind the platform.</p><h3>The Mental Model I Use</h3><p>Whenever I work with Kubernetes, I remember this simple flow:</p><pre>User<br> ↓<br>API Server<br> ↓<br>etcd<br> ↓<br>Controllers<br> ↓<br>Scheduler<br> ↓<br>Worker Nodes<br> ↓<br>Pods</pre><p>Here’s how I interpret it:</p><ul><li>Users submit requests.</li><li>The API Server receives them.</li><li>etcd stores the desired state.</li><li>Controllers monitor and enforce that state.</li><li>The Scheduler decides placement.</li><li>Worker nodes run the workloads.</li><li>Pods deliver the application.</li></ul><p>The Control Plane continuously watches every step of this process and ensures reality matches the desired state.</p><p>That single idea explains most of Kubernetes.</p><h3>Final Thoughts</h3><p>The Kubernetes Control Plane is what transforms Kubernetes from a simple container platform into a powerful orchestration system.</p><p>The API Server acts as the communication hub.</p><p>etcd stores the cluster’s source of truth.</p><p>Controllers continuously reconcile desired and actual states.</p><p>The Scheduler determines where workloads should run.</p><p>The Cloud Controller Manager integrates Kubernetes with cloud infrastructure.</p><p>Together, these components create the automation, scalability, resilience, and self-healing capabilities that make Kubernetes so powerful.</p><p>Once you truly understand the Control Plane, Kubernetes stops feeling like magic.</p><p>Instead, it becomes a system whose behavior you can predict, troubleshoot, and confidently operate in production.</p><p>And that’s the point where you stop being just a Kubernetes user and start thinking like a Kubernetes engineer.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><p>If you found this article helpful, consider following, clapping, and sharing it with others in the Kubernetes community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40cf5ed3a097" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Kubernetes Networking Without Getting Lost]]></title>
            <link>https://medium.com/@shahzadaliahmad/understanding-kubernetes-networking-without-getting-lost-c20047adfc40?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c20047adfc40</guid>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 01:30:32 GMT</pubDate>
            <atom:updated>2026-06-18T01:30:32.672Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XaCY4wDSeGLjJ7XSL2wl3g.png" /><figcaption>Kubernetes networking doesn’t have to be complicated. Understanding Pods, Services, DNS, Ingress, and Load Balancers through a simple traffic flow model can transform one of Kubernetes’ most confusing topics into one of its easiest to understand.</figcaption></figure><p><em>Kubernetes networking is one of the most important — and often most confusing — topics for beginners. Pods have IP addresses, Services have virtual IPs, DNS magically resolves names, Ingress routes traffic, and Load Balancers expose applications to the outside world. At first, it can feel like a lot of moving pieces. But once you understand the purpose of each component and how they work together, Kubernetes networking becomes surprisingly logical.</em></p><p>When I first started learning Kubernetes, networking was the area that confused me the most.</p><p>Questions like:</p><ul><li>How do Pods communicate with each other?</li><li>Why can’t applications just use Pod IP addresses?</li><li>What exactly is a Service?</li><li>How does Kubernetes DNS work?</li><li>What is the difference between Ingress and a Load Balancer?</li><li>How does traffic travel from a user’s browser all the way to a Pod?</li></ul><p>kept appearing throughout my learning journey.</p><p>In this article, we’ll break Kubernetes networking down into simple concepts and build a mental model that helps you understand how everything fits together.</p><h3>Understanding the Kubernetes Networking Model</h3><p>Before diving into Services and Ingress, it’s important to understand one of Kubernetes’ core networking principles:</p><blockquote><em>Every Pod gets its own IP address, and every Pod can communicate directly with every other Pod in the cluster.</em></blockquote><p>Unlike traditional container environments where containers often share a host network or require Network Address Translation (NAT), Kubernetes treats Pods as first-class network citizens.</p><p>This means:</p><ul><li>Pods can communicate across nodes.</li><li>Pods don’t need port mapping to talk to each other.</li><li>Applications can assume network connectivity exists between Pods.</li></ul><p>To make this possible, Kubernetes relies on a Container Network Interface (CNI) plugin such as:</p><ul><li>Calico</li><li>Cilium</li><li>Flannel</li><li>Weave Net</li></ul><p>The CNI plugin is responsible for assigning Pod IP addresses and ensuring traffic can flow between Pods across different nodes.</p><p>Without a CNI plugin, Kubernetes networking simply wouldn’t work.</p><h3>Start With a Simple Application</h3><p>Imagine you deploy a web application.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: web-app<br>spec:<br>  replicas: 3</pre><p>Kubernetes creates three Pods:</p><pre>web-app-pod-1<br>web-app-pod-2<br>web-app-pod-3</pre><p>Each Pod receives its own IP address.</p><pre>10.244.1.10<br>10.244.1.11<br>10.244.1.12</pre><p>These IP addresses are assigned by the cluster’s networking layer.</p><p>Now imagine another Pod wants to communicate with one of these Pods.</p><p>It can directly send traffic to:</p><pre>10.244.1.10</pre><p>or</p><pre>10.244.1.11</pre><p>without any special configuration.</p><p>This direct Pod-to-Pod communication is one of Kubernetes’ most powerful networking features.</p><h3>The First Problem: Pod IPs Are Not Permanent</h3><p>While Pod IPs are useful, they introduce a major challenge.</p><p>Pods are ephemeral.</p><p>If a Pod crashes, gets rescheduled, or is replaced during a deployment, Kubernetes creates a new Pod.</p><p>For example:</p><pre>Old Pod IP:<br>10.244.1.10</pre><p>After recreation:</p><pre>New Pod IP:<br>10.244.1.25</pre><p>The application is still running, but its IP address has changed.</p><p>Imagine hundreds of applications depending on that IP.</p><p>Everything would break.</p><p>This is why applications should never depend directly on Pod IP addresses.</p><p>We need a stable endpoint that remains consistent even when Pods come and go.</p><h3>Enter Kubernetes Services</h3><p>A Kubernetes Service solves this problem.</p><p>A Service provides:</p><ul><li>A stable virtual IP address</li><li>A stable DNS name</li><li>Load balancing across Pods</li></ul><p>Let’s create a Service.</p><pre>kind: Service<br>metadata:<br>  name: web-service</pre><p>Kubernetes assigns a virtual IP:</p><pre>10.96.15.20</pre><p>Unlike Pod IPs, this IP remains stable.</p><p>Applications now communicate with:</p><pre>web-service</pre><p>instead of individual Pods.</p><p>Think of a Service as a permanent front door that always knows which Pods are currently available.</p><p>Even if Pods are recreated, the Service remains unchanged.</p><h3>How Services Find Pods</h3><p>Services don’t magically know where Pods are.</p><p>They use labels and selectors.</p><p>Suppose your Pods have the label:</p><pre>labels:<br>  app: web-app</pre><p>The Service might use:</p><pre>selector:<br>  app: web-app</pre><p>Kubernetes continuously watches for Pods matching this selector.</p><p>Whenever Pods are added or removed, Kubernetes updates the Service endpoints automatically.</p><p>For example:</p><pre>web-service<br>    ↓<br>+----------------+<br>| Pod 1          |<br>| Pod 2          |<br>| Pod 3          |<br>+----------------+</pre><p>If Pod 2 crashes:</p><pre>web-service<br>    ↓<br>+----------------+<br>| Pod 1          |<br>| Pod 3          |<br>+----------------+</pre><p>Traffic continues flowing without interruption.</p><h3>How Traffic Reaches a Pod</h3><p>Let’s say a frontend application sends a request.</p><pre>Frontend → web-service</pre><p>The request doesn’t go directly to a Pod.</p><p>Instead, Kubernetes performs several steps:</p><pre>Frontend<br>    ↓<br>Service<br>    ↓<br>Endpoints<br>    ↓<br>Selected Pod</pre><p>Example:</p><pre>Frontend<br>    ↓<br>web-service<br>    ↓<br>web-app-pod-2</pre><p>The frontend doesn’t care which Pod receives the request.</p><p>The Service handles load balancing automatically.</p><p>This abstraction is what allows Kubernetes applications to scale seamlessly.</p><h3>Understanding Endpoints</h3><p>Behind every Service is an Endpoint object.</p><p>Endpoints contain the actual Pod IP addresses associated with the Service.</p><p>Example:</p><pre>web-service</pre><p>might map to:</p><pre>10.244.1.10<br>10.244.1.11<br>10.244.1.12</pre><p>You can view them using:</p><pre>kubectl get endpoints</pre><p>When troubleshooting networking issues, checking endpoints is often one of the first things you should do.</p><p>If a Service has no endpoints, traffic has nowhere to go.</p><h3>Kubernetes DNS Makes Service Discovery Easy</h3><p>Imagine managing hundreds of Services.</p><p>Remembering IP addresses would be impossible.</p><p>This is where CoreDNS comes in.</p><p>CoreDNS runs inside the cluster and provides service discovery.</p><p>When a Service is created:</p><pre>web-service</pre><p>Kubernetes automatically creates a DNS record:</p><pre>web-service.default.svc.cluster.local</pre><p>Applications can simply use:</p><pre>http://web-service</pre><p>instead of IP addresses.</p><p>DNS resolves the name to the Service IP automatically.</p><p>This allows microservices to communicate using meaningful names rather than constantly changing addresses.</p><h3>Understanding DNS Resolution</h3><p>Suppose a Pod sends:</p><pre>http://web-service</pre><p>The process looks like this:</p><pre>Application<br>      ↓<br>CoreDNS<br>      ↓<br>Service IP<br>      ↓<br>Service<br>      ↓<br>Pod</pre><p>Everything happens automatically.</p><p>Most developers never need to think about the underlying DNS mechanics because Kubernetes handles it for them.</p><h3>Types of Kubernetes Services</h3><p>Not all Services are designed for the same purpose.</p><p>Kubernetes provides several Service types.</p><h4>ClusterIP</h4><p>This is the default Service type.</p><pre>type: ClusterIP</pre><p>Traffic flow:</p><pre>Pod<br> ↓<br>ClusterIP Service<br> ↓<br>Pod</pre><p>Characteristics:</p><ul><li>Internal only</li><li>Not accessible from outside the cluster</li><li>Most commonly used Service type</li></ul><p>Ideal for:</p><ul><li>Databases</li><li>Internal APIs</li><li>Backend services</li></ul><h4>NodePort</h4><p>NodePort exposes an application on every Kubernetes node.</p><pre>type: NodePort</pre><p>Example:</p><pre>192.168.1.10:30080</pre><p>Traffic flow:</p><pre>User<br> ↓<br>Node IP:30080<br> ↓<br>Service<br> ↓<br>Pod</pre><p>Advantages:</p><ul><li>Simple</li><li>Useful for testing</li></ul><p>Disadvantages:</p><ul><li>Limited port range</li><li>Not ideal for production</li><li>Difficult to manage at scale</li></ul><h4>LoadBalancer</h4><p>LoadBalancer is commonly used in cloud environments.</p><pre>type: LoadBalancer</pre><p>When created, Kubernetes asks the cloud provider to provision an external load balancer.</p><p>Example:</p><pre>Internet<br>    ↓<br>AWS ELB<br>    ↓<br>Service<br>    ↓<br>Pods</pre><p>Supported by:</p><ul><li>Amazon EKS</li><li>Azure AKS</li><li>Google GKE</li></ul><p>Advantages:</p><ul><li>Production-ready</li><li>Automatically managed</li><li>Provides external access</li></ul><p>Disadvantages:</p><ul><li>Additional cloud costs</li><li>One load balancer per Service</li></ul><h3>Why We Need Ingress</h3><p>Imagine deploying multiple applications.</p><pre>shop.example.com<br>api.example.com<br>admin.example.com</pre><p>Without Ingress, you might create three separate LoadBalancers.</p><pre>LoadBalancer #1 → Shop<br>LoadBalancer #2 → API<br>LoadBalancer #3 → Admin</pre><p>This quickly becomes expensive and difficult to manage.</p><p>Ingress solves this problem.</p><h3>What Is Ingress?</h3><p>Ingress is an API object that defines routing rules for HTTP and HTTPS traffic.</p><p>Example:</p><pre>shop.example.com → Shop Service<br>api.example.com → API Service<br>admin.example.com → Admin Service</pre><p>Traffic flow:</p><pre>Internet<br>      ↓<br>Ingress Controller<br>      ↓<br>+-------------------+<br>| shop.example.com  |<br>| api.example.com   |<br>| admin.example.com |<br>+-------------------+</pre><p>One external endpoint can serve multiple applications.</p><h3>Ingress Controllers</h3><p>An Ingress resource by itself does nothing.</p><p>You need an Ingress Controller to implement the routing rules.</p><p>Popular options include:</p><ul><li>NGINX Ingress Controller</li><li>Traefik</li><li>HAProxy</li><li>Kong</li><li>AWS Load Balancer Controller</li></ul><p>Think of the Ingress resource as configuration and the Ingress Controller as the actual software performing the routing.</p><h3>The Complete Journey of a Request</h3><p>Let’s follow a request from a user’s browser.</p><p>Suppose a user visits:</p><pre>https://shop.example.com</pre><p>The request travels through multiple layers.</p><pre>User<br> ↓<br>DNS<br> ↓<br>Load Balancer<br> ↓<br>Ingress Controller<br> ↓<br>Service<br> ↓<br>Pod<br> ↓<br>Application</pre><p>Let’s break this down.</p><h4>Step 1: DNS Resolution</h4><p>DNS resolves:</p><pre>shop.example.com</pre><p>to the external IP address of the load balancer.</p><h4>Step 2: Load Balancer</h4><p>The cloud load balancer receives the request and forwards it to the Ingress Controller.</p><h4>Step 3: Ingress Controller</h4><p>The Ingress Controller examines:</p><pre>Host: shop.example.com</pre><p>and determines which Service should receive the request.</p><h4>Step 4: Service</h4><p>The Service selects a healthy Pod.</p><h4>Step 5: Pod</h4><p>The Pod processes the request and generates a response.</p><h4>Step 6: Response</h4><p>The response travels back through the same path.</p><pre>Application<br> ↓<br>Pod<br> ↓<br>Service<br> ↓<br>Ingress<br> ↓<br>Load Balancer<br> ↓<br>User</pre><p>Understanding this flow is the key to understanding Kubernetes networking.</p><h3>Network Policies: Controlling Traffic</h3><p>By default, Kubernetes networking is very open.</p><p>Pods can generally communicate with each other.</p><p>Sometimes that’s not desirable.</p><p>For example:</p><pre>Frontend → Backend ✅<br>Frontend → Database ✅<br>Random Pod → Database ❌</pre><p>Network Policies allow you to restrict traffic.</p><p>Example use cases:</p><ul><li>Allow only frontend Pods to access backend Pods</li><li>Restrict database access</li><li>Enforce zero-trust networking</li></ul><p>Network Policies act like Kubernetes firewalls for Pods.</p><h3>Common Kubernetes Networking Issues</h3><p>When troubleshooting networking problems, I usually investigate these areas first.</p><h4>Pod Not Running</h4><pre>kubectl get pods</pre><p>If the Pod isn’t healthy, networking won’t matter.</p><h4>Service Not Matching Labels</h4><pre>kubectl get endpoints</pre><p>No endpoints usually means the Service selector doesn’t match any Pods.</p><h4>DNS Problems</h4><pre>kubectl exec -it pod -- nslookup web-service</pre><p>Verify DNS resolution inside the cluster.</p><h4>Ingress Misconfiguration</h4><pre>kubectl describe ingress</pre><p>Check routing rules and events.</p><h4>Network Policies Blocking Traffic</h4><pre>kubectl get networkpolicy</pre><p>A restrictive policy may be preventing communication.</p><h4>Connectivity Testing</h4><p>Use tools like:</p><pre>curl<br>wget<br>ping</pre><p>from inside Pods to verify connectivity.</p><h3>The Mental Model That Changed Everything</h3><p>Instead of memorizing Kubernetes networking components individually, think of them as layers that solve specific problems.</p><pre>User<br> ↓<br>Load Balancer<br> ↓<br>Ingress<br> ↓<br>Service<br> ↓<br>Pod</pre><p>Each layer adds a capability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*JR6zf1JFPqpNr0riy1GicA.png" /></figure><p>Once this model clicks, Kubernetes networking becomes much easier to reason about.</p><h3>Final Thoughts</h3><p>Networking is often the topic that intimidates Kubernetes beginners the most, but the underlying concepts are actually straightforward.</p><p>Pods provide compute.</p><p>Services provide stable connectivity.</p><p>DNS provides service discovery.</p><p>Ingress provides intelligent routing.</p><p>Load Balancers provide external access.</p><p>Network Policies provide security.</p><p>Together, these components create a powerful networking model that allows applications to communicate reliably, scale dynamically, and remain resilient even as Pods are constantly created and destroyed.</p><p>The next time someone says Kubernetes networking is complicated, remember:</p><blockquote><em>Kubernetes networking is simply a collection of layers working together to move traffic from a user to a Pod — and back again.</em></blockquote><p>Once you understand the role of each layer, everything starts to make sense.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><p>If you found this article helpful, consider following, clapping, and sharing it with others in the Kubernetes community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c20047adfc40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Life of a Request Inside Kubernetes]]></title>
            <link>https://medium.com/@shahzadaliahmad/the-life-of-a-request-inside-kubernetes-753a3a81b61d?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/753a3a81b61d</guid>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Tue, 16 Jun 2026 16:57:46 GMT</pubDate>
            <atom:updated>2026-06-16T16:57:46.799Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTenr85snBhrvDJ9_oRnVw.png" /><figcaption>A single user request travels through multiple Kubernetes components before reaching your application. Understanding this journey is the key to mastering how cloud-native systems actually work.</figcaption></figure><p>One of the most common questions developers ask when they start working with Kubernetes is:</p><blockquote><em>“What actually happens when a user sends a request to my application?”</em></blockquote><p>We deploy Pods, create Services, configure Ingress resources, and expose applications to the internet. But once a request enters a Kubernetes cluster, it travels through several layers before finally reaching the application container.</p><p>Understanding this journey is one of the most important Kubernetes concepts because it connects networking, services, load balancing, and application delivery into a single picture.</p><p>Let’s follow a request from a user’s browser all the way to a running container.</p><h3>The Scenario</h3><p>Imagine you’ve deployed a simple web application.</p><pre>User<br>  |<br>  v<br>Ingress<br>  |<br>  v<br>Service<br>  |<br>  v<br>Pod</pre><p>Your application is accessible at:</p><pre>https://shop.example.com</pre><p>The user opens the website and clicks a product page.</p><p>What happens next?</p><h3>Step 1: The Browser Sends a Request</h3><p>The journey starts on the user’s device.</p><p>The browser sends an HTTPS request:</p><pre>GET /products<br>Host: shop.example.com</pre><p>Before the request reaches Kubernetes, DNS resolution occurs.</p><p>The browser asks:</p><pre>Where is shop.example.com?</pre><p>DNS responds with an IP address.</p><pre>203.0.113.10</pre><p>This IP typically belongs to:</p><ul><li>Load Balancer</li><li>Cloud Load Balancer</li><li>Ingress Controller</li></ul><p>The browser now knows where to send the request.</p><h3>Step 2: The Load Balancer Receives the Request</h3><p>In cloud environments such as:</p><ul><li>AWS</li><li>Azure</li><li>Google Cloud</li></ul><p>an external Load Balancer is often the first Kubernetes component that receives traffic.</p><p>Example:</p><pre>Internet<br>    |<br>    v<br>Load Balancer</pre><p>The Load Balancer acts as the entry point into the cluster.</p><p>Its responsibilities include:</p><ul><li>Accepting incoming traffic</li><li>Health checking backend nodes</li><li>Distributing traffic across nodes</li></ul><p>The request is then forwarded into the Kubernetes cluster.</p><h3>Step 3: The Ingress Controller Takes Over</h3><p>The request reaches an Ingress Controller.</p><p>Popular examples include:</p><ul><li>NGINX Ingress Controller</li><li>Traefik</li><li>HAProxy</li><li>Kong</li></ul><p>The Ingress Controller examines:</p><pre>Host Header<br>Path<br>Protocol</pre><p>Example:</p><pre>Host: shop.example.com</pre><p>Based on Ingress rules:</p><pre>rules:<br>- host: shop.example.com<br>  http:<br>    paths:<br>    - path: /<br>      backend:<br>        service:<br>          name: web-service</pre><p>the controller determines which Service should receive the request.</p><p>Think of Ingress as a smart traffic director.</p><h3>Step 4: The Service Receives Traffic</h3><p>The request is now forwarded to:</p><pre>web-service</pre><p>The Service acts as a stable networking endpoint.</p><p>This is important because Pods are temporary.</p><p>Today a Pod may be:</p><pre>10.1.0.15</pre><p>Tomorrow it may be:</p><pre>10.1.0.27</pre><p>Applications cannot rely on Pod IP addresses.</p><p>The Service solves this problem by providing a permanent virtual IP.</p><p>Example:</p><pre>kind: Service<br>spec:<br>  selector:<br>    app: web</pre><p>The Service continuously tracks matching Pods.</p><h3>Step 5: kube-proxy Performs Load Balancing</h3><p>The Service itself does not forward traffic.</p><p>Instead, Kubernetes uses:</p><pre>kube-proxy</pre><p>running on every node.</p><p>kube-proxy maintains networking rules using:</p><ul><li>iptables</li><li>IPVS</li><li>nftables</li></ul><p>When traffic arrives at the Service IP:</p><pre>10.96.0.25</pre><p>kube-proxy selects one healthy Pod.</p><p>Example:</p><pre>Pod A<br>Pod B<br>Pod C</pre><p>The request may be routed to:</p><pre>Pod B</pre><p>This provides built-in load balancing.</p><h3>Step 6: The Pod Receives the Request</h3><p>The request finally reaches the target Pod.</p><p>Inside the Pod, the container receives:</p><pre>GET /products</pre><p>Your application processes the request.</p><p>For example:</p><pre>Spring Boot<br>Node.js<br>Python Flask<br>Go Application<br>.NET API</pre><p>The application performs business logic.</p><p>Typical actions include:</p><ul><li>Database queries</li><li>API calls</li><li>Cache lookups</li><li>Authentication checks</li></ul><p>The application generates a response.</p><h3>Step 7: The Response Travels Back</h3><p>The response now travels in reverse.</p><pre>Application<br>    |<br>    v<br>Pod<br>    |<br>    v<br>Service<br>    |<br>    v<br>Ingress<br>    |<br>    v<br>Load Balancer<br>    |<br>    v<br>Browser</pre><p>Example response:</p><pre>200 OK</pre><p>with product information.</p><p>The browser renders the page.</p><p>The user sees the results.</p><p>The entire process typically takes milliseconds.</p><h3>What Happens If the Pod Fails?</h3><p>Suppose the selected Pod crashes.</p><pre>Pod B</pre><p>becomes unavailable.</p><p>Kubernetes immediately removes it from the Service endpoints.</p><p>Future requests are routed to:</p><pre>Pod A<br>Pod C</pre><p>instead.</p><p>Users continue accessing the application without noticing the failure.</p><p>This is one of the reasons Kubernetes provides high availability.</p><h3>What Happens When Traffic Increases?</h3><p>Imagine traffic suddenly jumps from:</p><pre>100 requests/sec</pre><p>to:</p><pre>5,000 requests/sec</pre><p>The Horizontal Pod Autoscaler may create additional Pods.</p><p>Example:</p><pre>Pod A<br>Pod B<br>Pod C<br>Pod D<br>Pod E<br>Pod F</pre><p>The Service automatically discovers the new Pods.</p><p>No configuration changes are required.</p><p>Traffic begins flowing to the new instances immediately.</p><h3>A Simple Visualization</h3><p>The complete request journey looks like this:</p><pre>User Browser<br>      |<br>      v<br>DNS<br>      |<br>      v<br>Load Balancer<br>      |<br>      v<br>Ingress Controller<br>      |<br>      v<br>Service<br>      |<br>      v<br>kube-proxy<br>      |<br>      v<br>Pod<br>      |<br>      v<br>Application<br>      |<br>      v<br>Response</pre><p>Every Kubernetes application follows some variation of this path.</p><h3>Why Understanding This Matters</h3><p>Many Kubernetes troubleshooting scenarios become easier once you understand where requests travel.</p><p>For example:</p><h4>DNS Issue</h4><p>Request never reaches the cluster.</p><h4>Ingress Misconfiguration</h4><p>Request reaches cluster but cannot find the Service.</p><h4>Service Selector Issue</h4><p>Service cannot find Pods.</p><h4>Pod Failure</h4><p>Request reaches Service but no healthy backend exists.</p><h4>Application Bug</h4><p>Request reaches the Pod but returns an error.</p><p>Understanding the request path helps you identify where problems occur.</p><h3>Final Thoughts</h3><p>When users access a Kubernetes-hosted application, much more happens than simply reaching a container.</p><p>A single request may pass through:</p><ul><li>DNS</li><li>Load Balancer</li><li>Ingress Controller</li><li>Service</li><li>kube-proxy</li><li>Pod</li><li>Application</li></ul><p>before returning a response.</p><p>Kubernetes abstracts much of this complexity, making applications easier to deploy and scale. However, understanding these layers is essential for debugging, performance tuning, and operating production workloads.</p><p>The next time you open an application running on Kubernetes, remember that every request is taking a carefully orchestrated journey through multiple components before reaching the code you’ve written.</p><p>And that’s one of the reasons Kubernetes is such a powerful platform for modern cloud-native applications.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><p>If you found this article helpful, consider following, clapping, and sharing it with others in the Kubernetes community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=753a3a81b61d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When a Pod Crashes?]]></title>
            <link>https://medium.com/@shahzadaliahmad/what-happens-when-a-pod-crashes-fed3b6f0639a?source=rss-1a09a3d5d4e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/fed3b6f0639a</guid>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubestronaut]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <dc:creator><![CDATA[Shahzad Ali Ahmad]]></dc:creator>
            <pubDate>Tue, 16 Jun 2026 16:40:38 GMT</pubDate>
            <atom:updated>2026-06-16T16:40:38.115Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6WAnQBUdZ3qr1gHkHA2UA.png" /><figcaption>A deep dive into Kubernetes self-healing capabilities — understanding what happens when a Pod crashes, how Kubernetes detects failures, and how it automatically restores application health.</figcaption></figure><p>Most developers know that Kubernetes can automatically restart failed applications. But have you ever wondered what actually happens behind the scenes when a Pod crashes?</p><p>When I first started learning Kubernetes, I assumed that if an application failed, Kubernetes would somehow magically fix everything. The reality is much more interesting.</p><p>Understanding what happens during a Pod failure is one of the most important concepts for Kubernetes developers, operators, and certification candidates.</p><p>Let’s break it down step by step.</p><h3>The Life of a Running Pod</h3><p>Imagine you have deployed a simple application:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: web-app<br>spec:<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: web-app<br>  template:<br>    metadata:<br>      labels:<br>        app: web-app<br>    spec:<br>      containers:<br>      - name: web-app<br>        image: nginx</pre><p>This Deployment creates three Pods.</p><p>Users send requests to the application, and everything works normally.</p><p>Then suddenly, one of the Pods crashes.</p><p>What happens next?</p><h3>Step 1: The Container Process Exits</h3><p>Every container has a main process.</p><p>For example:</p><ul><li>Nginx runs the nginx process</li><li>Java applications run the JVM</li><li>Node.js applications run node</li><li>Python applications run python</li></ul><p>If this process exits unexpectedly, Kubernetes considers the container unhealthy.</p><p>Common reasons include:</p><ul><li>Application bugs</li><li>Out of memory errors</li><li>Unhandled exceptions</li><li>Misconfigurations</li><li>Failed startup logic</li></ul><p>At this point, the container stops running.</p><h3>Step 2: The Kubelet Detects the Failure</h3><p>Every Kubernetes node runs an agent called the Kubelet.</p><p>The Kubelet continuously monitors all Pods running on its node.</p><p>When the container exits, the Kubelet immediately notices the state change.</p><p>The Pod status changes from:</p><pre>Running</pre><p>to:</p><pre>Error</pre><p>or</p><pre>CrashLoopBackOff</pre><p>depending on the situation.</p><p>The Kubelet now decides what action to take based on the Pod’s restart policy.</p><h3>Step 3: Kubernetes Attempts a Restart</h3><p>Most workloads use the default restart policy:</p><pre>restartPolicy: Always</pre><p>This means Kubernetes will automatically restart the failed container.</p><p>The container runtime:</p><ul><li>containerd</li><li>CRI-O</li><li>Docker (older environments)</li></ul><p>creates a fresh container instance.</p><p>The application starts again.</p><p>If the issue was temporary, users may never notice anything happened.</p><h3>Step 4: What If the Application Keeps Crashing?</h3><p>Sometimes the application crashes immediately after startup.</p><p>Example:</p><pre>Container Started<br>Application Error<br>Container Exited</pre><p>Kubernetes tries again.</p><pre>Container Started<br>Application Error<br>Container Exited</pre><p>Again.</p><pre>Container Started<br>Application Error<br>Container Exited</pre><p>Again.</p><p>This creates a restart loop.</p><p>To prevent endless rapid restarts, Kubernetes introduces a backoff delay.</p><p>This is known as:</p><pre>CrashLoopBackOff</pre><p>You might see:</p><pre>kubectl get pods</pre><p>Output:</p><pre>NAME                     READY   STATUS             RESTARTS<br>web-app-abc123           0/1     CrashLoopBackOff   8</pre><p>This is Kubernetes telling you:</p><blockquote><em>“I keep restarting this container, but it keeps failing.”</em></blockquote><h3>Step 5: Deployment Notices the Problem</h3><p>Now let’s look at the bigger picture.</p><p>Remember:</p><pre>replicas: 3</pre><p>The Deployment wants three healthy Pods.</p><p>If one Pod becomes permanently unhealthy, the Deployment controller begins reconciliation.</p><p>Kubernetes constantly compares:</p><pre>Desired State</pre><p>with</p><pre>Actual State</pre><p>If they don’t match, Kubernetes takes action.</p><p>This is one of the core principles behind Kubernetes.</p><h3>Step 6: Kubernetes Creates a Replacement Pod</h3><p>Suppose a node crashes completely.</p><p>The Pod disappears.</p><p>The Deployment notices:</p><pre>Desired Pods: 3<br>Actual Pods: 2</pre><p>Kubernetes immediately schedules a replacement Pod on another available node.</p><p>Users continue accessing the application while Kubernetes restores the desired state.</p><p>This self-healing capability is one of the biggest reasons Kubernetes became the standard platform for modern applications.</p><h3>Understanding CrashLoopBackOff</h3><p>Many beginners think CrashLoopBackOff is the problem.</p><p>It’s not.</p><p>CrashLoopBackOff is actually a symptom.</p><p>The real issue is usually one of the following:</p><h4>Application Bug</h4><pre>Unhandled Exception<br>Segmentation Fault<br>Runtime Error</pre><h4>Missing Configuration</h4><pre>Database URL missing<br>API key missing<br>Environment variable missing</pre><h4>Failed Dependencies</h4><pre>Database unavailable<br>External API unreachable<br>Message queue unavailable</pre><h4>Resource Limits</h4><pre>Out Of Memory<br>CPU starvation</pre><p>The first thing you should do is inspect the logs.</p><pre>kubectl logs pod-name</pre><p>For previously crashed containers:</p><pre>kubectl logs pod-name --previous</pre><h3>How Readiness and Liveness Probes Help</h3><p>Kubernetes doesn’t just wait for containers to crash.</p><p>It can proactively monitor application health.</p><h4>Liveness Probe</h4><p>Checks:</p><blockquote><em>Is the application still alive?</em></blockquote><p>If the probe fails repeatedly:</p><pre>Container Restarted</pre><h4>Readiness Probe</h4><p>Checks:</p><blockquote><em>Can the application serve traffic?</em></blockquote><p>If the probe fails:</p><pre>Pod Removed From Service Endpoints</pre><p>Traffic stops flowing to that Pod until it becomes healthy again.</p><p>This prevents users from hitting unhealthy applications.</p><h3>A Real Production Scenario</h3><p>Imagine an e-commerce application.</p><p>One Pod develops a memory leak.</p><p>Memory usage increases until the process crashes.</p><p>Kubernetes detects the failure.</p><p>The container restarts.</p><p>The Service automatically routes traffic to healthy Pods.</p><p>Users continue shopping.</p><p>A replacement Pod becomes available.</p><p>The platform heals itself.</p><p>Without Kubernetes, an engineer might need to wake up at 2 AM and manually restart the application.</p><p>With Kubernetes, most failures are handled automatically.</p><h3>Key Lessons</h3><p>When a Pod crashes, Kubernetes follows a predictable process:</p><ol><li>Container process exits</li><li>Kubelet detects the failure</li><li>Kubernetes attempts a restart</li><li>CrashLoopBackOff appears if failures continue</li><li>Deployment compares desired state with actual state</li><li>Replacement Pods are created if needed</li><li>Services continue routing traffic to healthy Pods</li></ol><p>This entire workflow happens automatically and often within seconds.</p><p>That’s the power of Kubernetes.</p><p>It isn’t just a container orchestration platform.</p><p>It’s a self-healing system designed to keep applications running even when individual components fail.</p><p>The next time you see a Pod enter CrashLoopBackOff, don’t panic.</p><p>Instead, remember that Kubernetes is already doing its job — the real task is finding out why the application keeps crashing.</p><h3>Final Thoughts</h3><p>One of the biggest lessons I learned while working with Kubernetes is that failures are expected.</p><p>Containers crash.<br>Nodes fail.<br>Applications encounter bugs.</p><p>Kubernetes was designed with this reality in mind.</p><p>Rather than trying to prevent every failure, Kubernetes focuses on detecting problems quickly, recovering automatically, and maintaining the desired state of the system.</p><p>Understanding what happens when a Pod crashes helps you move beyond simply deploying applications and start thinking like a Kubernetes operator.</p><p>The next time you see a Pod restart or enter a CrashLoopBackOff state, you’ll know exactly what’s happening behind the scenes — and more importantly, where to begin troubleshooting.</p><p>That’s one of the key skills that separates Kubernetes beginners from engineers who can confidently run production workloads.</p><h3>Connect With Me</h3><p>If you’re preparing for Kubernetes certifications, pursuing the Kubestronaut journey, or working in the cloud-native ecosystem, I’d love to connect.</p><p>Follow me on Medium for more articles on Kubernetes, CNCF certifications, DevOps, Platform Engineering, and Cloud-Native technologies.</p><p>LinkedIn: <a href="https://www.linkedin.com/in/shahzadaliahmad/">https://www.linkedin.com/in/shahzadaliahmad/</a></p><p>LFX Profile: <a href="https://openprofile.dev/profile/shahzadahmad91">https://openprofile.dev/profile/shahzadahmad91</a></p><p>Credly: <a href="https://www.credly.com/users/shahzadahmad">https://www.credly.com/users/shahzadahmad</a></p><p>Website: <a href="https://shahzadahmad.dev/">https://shahzadahmad.dev/</a></p><p>If you found this article helpful, consider following, clapping, and sharing it with others in the Kubernetes community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fed3b6f0639a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>