<?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 Tanmay Batham on Medium]]></title>
        <description><![CDATA[Stories by Tanmay Batham on Medium]]></description>
        <link>https://medium.com/@tanmaybatham?source=rss-8fdae21a7b45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TRSaFDbxcrXVzt4hIRsEJg.jpeg</url>
            <title>Stories by Tanmay Batham on Medium</title>
            <link>https://medium.com/@tanmaybatham?source=rss-8fdae21a7b45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:23:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanmaybatham/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[What Happens When You Create a CronJob in Kubernetes — A Deep, Internal-Level Breakdown]]></title>
            <link>https://tanmaybatham.medium.com/what-happens-when-you-create-a-cronjob-in-kubernetes-a-deep-internal-level-breakdown-70797edda81b?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/70797edda81b</guid>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[kubernetes-cronjob]]></category>
            <category><![CDATA[etcd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Fri, 05 Dec 2025 12:41:25 GMT</pubDate>
            <atom:updated>2025-12-05T12:41:25.382Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happens When You Create a CronJob in Kubernetes — A Deep, Internal-Level Breakdown</h3><p>Kubernetes Series — K008</p><p>CronJobs are one of the most powerful — but least understood — features in Kubernetes.<br> They look deceptively simple: define a schedule, give it a Job template, and Kubernetes runs the Job automatically at the right time.</p><p>But under the hood, CronJobs involve:</p><ul><li>the CronJob controller,</li><li>the Job controller,</li><li>time-based reconciliation loops,</li><li>concurrency policies,</li><li>missed-run policies,</li><li>history limits,</li><li>mounting, scheduling, Pod creation, and</li><li>the complex choreography between multiple control-plane subsystems.</li></ul><p>If Deployments manage long-running Pods, and Jobs ensure Pods run-to-completion, then CronJobs coordinate <strong>time itself</strong> — they are the automation layer that decides <em>when</em> Jobs start, how many can run, what happens during overlap, and how to handle failure.</p><p>But what actually happens inside Kubernetes when you run:</p><pre>kubectl apply -f cronjob.yaml</pre><p>This deep dive walks through the entire lifecycle — <br>from kubectl to the API Server, into the CronJob controller, down to Jobs and Pods — <br>revealing exactly how Kubernetes turns a time schedule into reliable execution.</p><p>Let’s begin.</p><h3>kubectl Submits the CronJob</h3><p>When you apply a CronJob manifest:</p><pre>kubectl apply -f cronjob.yaml</pre><p>kubectl:</p><ol><li>loads your kubeconfig</li><li>parses and normalizes the YAML</li><li>performs client-side schema validation</li><li>serializes it into a CronJob object (batch/v1)</li><li>sends it to the API Server:</li></ol><pre>POST /apis/batch/v1/namespaces/&lt;ns&gt;/cronjobs</pre><p>No schedules are evaluated yet — this step simply publishes the object.</p><h3>API Server: Authentication, Authorization, and Admission</h3><p>Once the CronJob hits the API Server:</p><h4>Authentication</h4><p>Verifies your identity (certs, tokens, OIDC, cloud auth providers, etc.).</p><h4>Authorization (RBAC)</h4><p>Checks that you are allowed to:</p><pre>create cronjobs</pre><p>If not → 403 Forbidden.</p><h4>Admission Controllers</h4><p>Mutating and validating plugins may:</p><ul><li>inject or validate labels</li><li>enforce PodSecurity policies</li><li>check cron syntax validity</li><li>validate image policies</li><li>enforce concurrency restrictions</li><li>apply defaults and annotations</li></ul><h4>Schema Validation</h4><p>The API Server ensures the CronJob’s fields are valid:</p><ul><li>cron syntax</li><li>Job template validity</li><li>concurrencyPolicy</li><li>history limits</li><li>suspend flag</li><li>successful/failed history limits</li></ul><p>Once validated → CronJob is stored in etcd.</p><h3>etcd Stores the CronJob</h3><p>CronJobs are stored under:</p><pre>/registry/cronjobs/&lt;namespace&gt;/&lt;name&gt;</pre><p>The stored object includes:</p><ul><li>schedule</li><li>concurrency policy</li><li>jobTemplate</li><li>suspend flag</li><li>history limits</li><li>timezone (if set)</li><li>lastScheduleTime (set later)</li><li>startingDeadlineSeconds</li></ul><p>Once stored, the CronJob exists — but has not triggered anything yet.</p><h3>The CronJob Controller Takes Over</h3><p>Inside the kube-controller-manager, a dedicated <strong>CronJob controller</strong> runs a timed reconciliation loop.</p><p>It watches all CronJobs and evaluates each schedule every <strong>10 seconds</strong> by default.</p><p>Key responsibilities:</p><ul><li>Determine <em>when</em> a Job should be created</li><li>Handle missed runs</li><li>Enforce concurrency policies</li><li>Maintain history limits</li><li>Create new Jobs on time</li><li>Update CronJob status fields</li></ul><p>CronJob controllers are time-driven — this makes them unique in Kubernetes.</p><h3>Evaluating the Schedule</h3><p>Cron syntax example:</p><pre>*/5 * * * *</pre><p>Meaning: Run every 5 minutes.</p><p>The CronJob controller:</p><ol><li>Parses the cron expression</li><li>Checks the lastScheduleTime</li><li>Determines if it’s time to create a new Job</li><li>Handles edge cases like:</li></ol><ul><li>controller downtime</li><li>cluster clock drift</li><li>long-running Jobs</li><li>overlapping schedules</li></ul><p>5. Evaluates missed schedules using startingDeadlineSeconds</p><p>If a run is due → the CronJob controller triggers Job creation.</p><h3>Concurrency Policies Come Into Play</h3><p>Before creating a Job, Kubernetes checks:</p><p>1. Allow (default)</p><p>Multiple Jobs may run simultaneously.</p><p>2. Forbid</p><p>If the previous Job is still running → skip this run.</p><p>3. Replace</p><p>If a Job is still running → delete it and start a new one.</p><p>These policies heavily influence Job lifecycle behavior.</p><h3>The CronJob Controller Creates a Job</h3><p>When it’s time to run:</p><ol><li>The controller takes .spec.jobTemplate</li><li>Clones it into a new Job object</li><li>Gives it a unique name:</li></ol><pre>&lt;prefix&gt;-&lt;timestamp-suffix&gt;</pre><p>Example:</p><pre>backup-database-27364789</pre><ol><li>Sets OwnerReference back to the CronJob</li><li>Sets creationTimestamp</li><li>Sends Job to the API Server</li></ol><p>Now the Job controller and scheduler take over.</p><h3>The Job Controller Takes the Baton</h3><p>From this point, Job lifecycle = what you learned in the “Job deep dive”.</p><p><strong>The Job controller:</strong></p><ul><li>creates Pods</li><li>handles retries</li><li>tracks completions</li><li>enforces backoffLimit</li><li>marks Job as Succeeded or Failed</li></ul><p>Each CronJob run is a new Job and each Job may create many Pods.</p><h3>Pods Are Created and Scheduled</h3><p>Each Job spawns one or more Pods, determined by:</p><ul><li>.spec.completions</li><li>.spec.parallelism</li><li>.spec.completionMode</li></ul><p>Pods follow the standard scheduling pipeline:</p><ul><li>scheduler filters nodes</li><li>scheduler scores nodes</li><li>scheduler binds Pods to nodes</li><li>kubelet runs them</li></ul><p>Pod outcomes:</p><ul><li><strong>Succeeded</strong> → counts toward Job completion</li><li><strong>Failed</strong> → triggers retry</li><li><strong>Evicted</strong> → retried</li><li><strong>Timeout</strong> → retried or failed</li></ul><p>When all completions are met → Job becomes Succeeded.</p><h3>CronJob Status Updates</h3><p>CronJob controller updates:</p><p><strong>lastScheduleTime<br></strong>Indicates the last time the schedule triggered.</p><p><strong>active jobs list<br></strong>Shows currently running Jobs.</p><p><strong>conditions<br></strong>Tracks failures or suspensions.</p><p>These updates are written to the CronJob .status field.</p><h3>Job History Limits &amp; Cleanup</h3><p>CronJobs support:</p><pre>successfulJobsHistoryLimit:<br>failedJobsHistoryLimit:</pre><p>Example:</p><pre>successfulJobsHistoryLimit: 3<br>failedJobsHistoryLimit: 1</pre><p>CronJob controller:</p><ul><li>keeps recent N successful Jobs</li><li>keeps recent M failed Jobs</li><li>deletes older Jobs AND their Pods</li></ul><p>This avoids cluttering the cluster with old Jobs.</p><h3>Missed Schedules (Very Important)</h3><p>Kubernetes checks startingDeadlineSeconds.<br>If the controller was down or the cluster was overloaded, some schedules may be missed.</p><p>If startingDeadlineSeconds is set:</p><ul><li>missed runs within deadline → executed</li><li>missed runs beyond deadline → skipped</li></ul><p>If unset:</p><ul><li>Kubernetes executes exactly ONE missed run when controller resumes, to avoid bursts.</li></ul><p>This is a critical design choice to prevent <strong>“cron storms.”</strong></p><h3>Clock Skew and Time Zone Handling</h3><p>CronJobs support:</p><pre>timezone: &quot;America/New_York&quot;</pre><p>The controller:</p><ul><li>uses timezone for schedule evaluation</li><li>handles Daylight Savings Time</li><li>adjusts for leap seconds</li><li>avoids duplicate or skipped runs on DST boundaries</li></ul><p>Time zone support was added in Kubernetes v1.27+.</p><h3>What Happens When You Delete a CronJob?</h3><p>Deleting:</p><pre>kubectl delete cronjob mycron</pre><p>Does <strong>not</strong> delete:</p><ul><li>currently running Jobs</li><li>completed Jobs (unless TTL is enabled)</li><li>old Pods</li></ul><p>But it does stop new schedules from triggering.</p><p>If you want all Jobs deleted:</p><pre>kubectl delete cronjob mycron --cascade=foreground</pre><h3>Flow Diagram</h3><pre>kubectl apply<br>     |<br>     v<br>API Server (Auth → RBAC → Admission → Validation)<br>     |<br>     v<br>etcd (CronJob stored)<br>     |<br>     v<br>CronJob Controller (15s cycle)<br>     |<br>     +-- check schedule<br>     |     |<br>     |     v<br>     |   time to run?<br>     |       |<br>     |       +-- Yes --&gt; create Job<br>     |               |<br>     |               v<br>     |         Job Controller<br>     |               |<br>     +--&gt; updates status and history</pre><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*szvqWVAY_J4QgA0yHE9g1A.png" /><figcaption>Kubenetes CronJob Overview</figcaption></figure><h3>Job lifecycle:</h3><pre>Job --&gt; Pods --&gt; Scheduler --&gt; kubelet --&gt; completion or retry</pre><h3>When Should You Use a CronJob?</h3><p><strong>Perfect for:</strong></p><ul><li>backups</li><li>log cleanup</li><li>database vacuuming</li><li>report generation</li><li>recurring ETL jobs</li><li>scanning tasks</li><li>recurring ML inference</li><li>maintenance scripts</li><li>periodic API calls</li><li>file compression or archival</li><li>recurring notifications</li></ul><p><strong>Not suitable for:</strong></p><ul><li>long-running tasks (use Job)</li><li>high-frequency tasks (&lt; 1 minute reliably)</li><li>real-time workloads</li><li>streaming or push-based systems</li><li>workloads requiring stable identity (StatefulSet)</li><li>services (Deployment)</li></ul><h3>Common Misunderstandings</h3><p><strong>“CronJobs run Pods directly.”</strong><br>No — they always create Jobs, which create Pods.</p><p><strong>“If a CronJob misses 10 minutes of runs, Kubernetes executes all of them later.”</strong><br>False — it executes at most one missed run unless configured otherwise.</p><p><strong>“Time zones don’t matter.”</strong><br>They do, especially with DST.</p><p><strong>“Deleting a CronJob deletes all Jobs and Pods.”</strong><br>Not unless cascade deletion is used.</p><p><strong>“CronJobs run exactly on time.”</strong><br>They run within the controller’s reconciliation window (~10–15 seconds).</p><h3>Kubernetes Workload Comparison Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fnhhLjRFS1KrxcPe.png" /><figcaption>Kubernetes Workload Comparison Table</figcaption></figure><h3>Real-Life Example: When You Would Create a CronJob</h3><p>CronJobs are the right choice when you need a <strong>task to run automatically on a schedule</strong>, without human intervention — daily, hourly, weekly, or at any fixed interval.</p><p>They are perfect for recurring maintenance, cleanup, backup, and batch workflows that must run at a specific time.</p><p>Here’s a real, production-ready example.</p><h4>Example: Automatically Backing Up a Database Every Night at 2 AM</h4><p>Your production application stores important customer data in a database.<br>You must back it up every night and upload the backup to object storage (S3, GCS, Azure Blob).</p><p>You create a <strong>CronJob</strong> to run the backup script on a strict schedule:</p><pre>apiVersion: batch/v1<br>kind: CronJob<br>metadata:<br>  name: nightly-backup<br>spec:<br>  schedule: &quot;0 2 * * *&quot;   # every day at 2 AM<br>  successfulJobsHistoryLimit: 3<br>  failedJobsHistoryLimit: 1<br>  jobTemplate:<br>    spec:<br>      template:<br>        spec:<br>          restartPolicy: OnFailure<br>          containers:<br>          - name: backup<br>            image: myorg/db-backup:v1<br>            command: [&quot;sh&quot;, &quot;-c&quot;, &quot;python backup_and_upload.py&quot;]</pre><h4>Why a CronJob?</h4><p>Because the task must:</p><h4>1. Run on a schedule (no manual triggers)</h4><p>Every night at 2 AM — CronJob guarantees timely execution.</p><h4>2. Run to completion</h4><p>CronJobs create Jobs, which ensure the backup finishes successfully.</p><h4>3. Retry automatically if something fails</h4><p>If the database is temporarily unavailable, the Job retries using backoff logic.</p><h4>4. Keep limited history of successful and failed runs</h4><p>Ops teams can check if backups succeeded.</p><h4>5. Run exactly once per schedule</h4><p>CronJobs prevent accidental double-execution.</p><h4>6. Not restart automatically like a Deployment</h4><p>You don’t want a backup script running forever.</p><h3>Conclusion</h3><p>Creating a CronJob triggers a multi-layer orchestration:</p><ul><li>kubectl submits the object</li><li>API Server authenticates and validates</li><li>CronJob stored in etcd</li><li>CronJob controller evaluates schedule continuously</li><li>concurrency policies are enforced</li><li>missed runs are handled intelligently</li><li>Jobs are created based on schedule</li><li>Job controller spawns Pods and tracks success</li><li>history limits prune old runs</li></ul><p>CronJobs turn Kubernetes into a cluster-wide automation platform — a distributed, fault-tolerant scheduler that blends cron-style execution with Kubernetes resilience and retry logic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70797edda81b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Create a DaemonSet in Kubernetes — A Deep, Internal-Level Breakdown]]></title>
            <link>https://tanmaybatham.medium.com/what-happens-when-you-create-a-daemonset-in-kubernetes-a-deep-internal-level-breakdown-002f3f0485eb?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/002f3f0485eb</guid>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[kubernetes-daemonset]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[etcd]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 12:39:29 GMT</pubDate>
            <atom:updated>2025-12-04T12:39:29.719Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happens When You Create a DaemonSet in Kubernetes — A Deep, Internal-Level Breakdown</h3><p>Kubernetes Series — K006</p><p>Kubernetes DaemonSets power some of the most critical components of a cluster:<br>network plugins, logging agents, monitoring collectors, security scanners, and node-level utilities.</p><p>They are everywhere — running invisibly on every node you have — yet very few engineers truly understand what happens behind the scenes when you create one.</p><p>What makes a DaemonSet so different from a Deployment?<br>How does Kubernetes ensure one Pod per node?<br>What happens when you add new nodes?<br>Why doesn’t the scheduler handle DaemonSet Pods the way it handles other workloads?<br>And what really happens when you run:</p><pre>kubectl apply -f daemonset.yaml</pre><p>This deep dive walks you through every internal step — from kubectl to the API Server, through the DaemonSet controller, across node joins, down to the kubelet and Pod lifecycle — revealing the orchestration that ensures a Pod runs on <em>every</em> node, <em>exactly once</em>, <em>always</em>.</p><p>Let’s explore.</p><h3>It Begins With kubectl apply</h3><p>You apply a DaemonSet manifest:</p><pre>kubectl apply -f daemonset.yaml</pre><p>kubectl performs its usual client-side responsibilities:</p><ul><li>loads kubeconfig</li><li>parses and validates the manifest</li><li>merges last-applied configuration</li><li>serializes the DaemonSet object to JSON</li><li>sends an HTTP request:</li></ul><pre>POST /apis/apps/v1/namespaces/&lt;ns&gt;/daemonsets</pre><p>It’s just an API request — the orchestration hasn’t started yet.</p><h3>API Server: Authentication, Authorization &amp; Admission</h3><p>The request reaches the API Server, which runs the standard pipeline.</p><h4>Authentication</h4><p>Verifies identity:</p><ul><li>client cert</li><li>token</li><li>OIDC credentials</li><li>exec plugin, etc.</li></ul><p>If failed → 401 Unauthorized.</p><h4>Authorization (RBAC)</h4><p>Checks:</p><pre>verbs: [&quot;create&quot;]<br>resources: [&quot;daemonsets&quot;]</pre><p>If failed → 403 Forbidden.</p><h4>Admission Controllers</h4><p>Mutating and validating webhooks may:</p><ul><li>add labels</li><li>inject sidecar containers</li><li>enforce PodSecurity</li><li>validate container image policies</li><li>require resource limits</li><li>prevent privileged DaemonSet Pods</li></ul><p>After admission, the object is verified against schema and accepted.</p><h3>etcd: Persisting the DaemonSet</h3><p>Once validated, the DaemonSet is written to etcd under:</p><pre>/registry/daemonsets/&lt;namespace&gt;/&lt;name&gt;</pre><p>etcd stores:</p><ul><li>metadata</li><li>PodTemplate</li><li>update strategy</li><li>selectors</li><li>desired node-to-pod mapping logic</li></ul><p>This write triggers <strong>watch events</strong>, notifying the DaemonSet controller.</p><h3>The DaemonSet Controller Comes to Life</h3><p>Unlike Deployments or StatefulSets, the DaemonSet controller is responsible for placing Pods <em>directly onto nodes</em> — bypassing the default scheduler for most cases.</p><p>The DaemonSet controller continuously watches:</p><ul><li>all Nodes</li><li>all DaemonSets</li><li>all DaemonSet-managed Pods</li></ul><p>When it detects your new DaemonSet, it starts reconciling.</p><h3>What Makes DaemonSets Different?</h3><p>DaemonSets follow <strong>“one Pod per node”</strong> semantics.</p><p>For every node, the controller decides:</p><pre>Should a DaemonSet Pod run here?</pre><p>This depends on:</p><h4>1. Node Selectors</h4><p>Your Pod template may include:</p><pre>nodeSelector:<br>  disktype: ssd</pre><p>Only matching nodes get Pods.</p><h4>2. Node Affinity / Anti-affinity</h4><p>Advanced placement logic.</p><h4>3. Taints &amp; Tolerations</h4><p>DaemonSet Pods often include tolerations like:</p><pre>tolerations:<br>- operator: Exists</pre><p>Meaning:<br> “They should run on <em>all</em> nodes, even tainted ones.”</p><h4>4. Critical Add-ons</h4><p>Some system DaemonSets run with:</p><ul><li>priorityClass: system-node-critical</li><li>tolerations for master/control-plane nodes</li></ul><p>This allows them onto every node, including control-plane nodes.</p><h3>DaemonSet Pod Placement: Scheduler vs Controller?</h3><p>This is one of the most misunderstood aspects.</p><blockquote>DaemonSets do NOT normally use the default Kubernetes scheduler.</blockquote><p>Instead:</p><ul><li>the DaemonSet controller places Pods directly</li><li>it sets pod.spec.nodeName = &lt;node&gt; itself</li><li>this bypasses the scheduler binding step</li></ul><p>Scheduler involvement is only needed if:</p><ul><li>the DaemonSet Pod does not tolerate a node’s taints</li><li>the Pod has nodeAffinity the controller cannot satisfy</li><li>feature gates require scheduler involvement</li><li>pod.spec.affinity demands scheduler logic</li></ul><p>But in most clusters, 99% of DaemonSet Pods never hit the scheduler.</p><p>This is intentional:<br>DaemonSets should run everywhere, not “best-effort scheduled.”</p><h3>The Pod Template Expands into Node-Specific Pods</h3><p>Assume your cluster has 5 worker nodes.</p><p>Your DaemonSet requests:</p><pre>One Pod per Node</pre><p>DaemonSet controller creates:</p><pre>mydaemon-&lt;node1&gt;<br>mydaemon-&lt;node2&gt;<br>mydaemon-&lt;node3&gt;<br>mydaemon-&lt;node4&gt;<br>mydaemon-&lt;node5&gt;</pre><p>Each Pod:</p><ul><li>has the same spec</li><li>is tied to a specific node</li><li>is managed with an OwnerReference to the DaemonSet</li></ul><p>There is no ReplicaSet involved — DaemonSets manage Pods directly.</p><h3>kubelet Begins Pod Creation</h3><p>Once a Pod is assigned to a node (via controller or scheduler), the kubelet responsible for that node takes over:</p><h4>1. Storage setup (if used)</h4><p>Most DaemonSets are stateless — log shippers, CNI agents, metrics collectors.</p><p>But if they require hostPath volumes:</p><pre>volumeMounts:<br>- mountPath: /var/lib/docker/containers<br>  name: logs</pre><p>kubelet ensures safe mounts and permission handling.</p><h4>2. Pod sandbox creation</h4><p>The container runtime creates:</p><ul><li>network namespace</li><li>PID namespace</li><li>mount namespace</li><li>cgroups</li><li>pause container</li></ul><h4>3. Container creation</h4><p>kubelet pulls images and starts:</p><ul><li>the main container</li><li>init containers</li><li>sidecars (if injected)</li></ul><h4>4. Health checks</h4><p>DaemonSets frequently use liveness probes to ensure continuous operation.</p><h3>Node Add Events: DaemonSets Automatically Deploy to New Nodes</h3><p>This is a defining feature of DaemonSets.</p><p>When a new node joins the cluster:</p><ol><li>A Node object is registered with the API Server</li><li>etcd stores the new node</li><li>DaemonSet controller sees the new node via watch event</li><li>Controller checks:<br> “Does this DaemonSet apply to this node?”</li><li>If yes → Creates a new DaemonSet Pod on the node</li><li>kubelet on that node runs the Pod</li></ol><p>Deployments don’t do this. StatefulSets don’t do this. Jobs don’t do this.</p><p>This behavior is exclusive to DaemonSets.</p><h3>Node Removal, Drain, and DaemonSet Behavior</h3><p>When a node is:</p><ul><li>drained</li><li>cordoned</li><li>unreachable</li><li>deleted</li></ul><p>The DaemonSet controller reacts:</p><h4>Cordoned node</h4><p>Pod remains but Kubernetes won’t schedule <em>new</em> Pods onto it.</p><h4>Drained node</h4><p>DaemonSet Pods are allowed to be evicted <em>if</em>:</p><pre>spec:<br>  updateStrategy:<br>    rollingUpdate:<br>      maxUnavailable: &lt;value&gt;</pre><p>DaemonSets traditionally ignore evictions, but newer Kubernetes versions support:</p><ul><li><strong>DaemonSet-aware eviction</strong></li><li>PodDisruptionBudgets for DaemonSets</li></ul><h4>Node deleted</h4><p>DaemonSet controller deletes the orphaned Pod entry.</p><h3>DaemonSet Update Strategies</h3><p>DaemonSets support two update strategies:</p><h4>1. RollingUpdate (default)</h4><p>Pods are updated one node at a time.</p><pre>mydaemon-node1 updated<br>mydaemon-node2 updated<br>...</pre><p>MaxUnavailable determines how many nodes can have unavailable Pods during an update.</p><h4>2. OnDelete</h4><p>Pods only update when manually deleted:</p><pre>kubectl delete pod mydaemon-node3</pre><p>Useful for:</p><ul><li>manual maintenance windows</li><li>disruptive updates</li><li>kernel-level agents</li><li>CNI plugins</li><li>node-critical software</li></ul><h3>Kubernetes Workload Comparison Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UFFfC1umHMsxVJ2xuvFfdA.png" /><figcaption>Kubernetes Workload Comparison Table</figcaption></figure><p>DaemonSets solve scheduling at the <strong>node level</strong>, not the cluster level.</p><h3>DaemonSet Without Node Storage or Privileges</h3><p>Not all DaemonSets are privileged agents or CNI plugins.</p><p>You can use DaemonSets for:</p><ul><li>log forwarders</li><li>metrics collectors</li><li>filebeat, fluentbit</li><li>GPU monitoring</li><li>host sensor agents</li><li>node-level security scanners</li></ul><p>Even completely <strong>stateless</strong> node routines can run as DaemonSets because:</p><ul><li>every node must have one</li><li>Pods follow node lifecycle</li><li>updates roll out predictably</li></ul><h3>Flow Diagram</h3><pre>kubectl apply<br>     |<br>     v<br>API Server<br>(Auth → RBAC → Admission → Validation)<br>     |<br>     v<br>etcd (store DaemonSet)<br>     |<br>     v<br>DaemonSet Controller<br>     |<br>     +-- List all nodes<br>     |<br>     +-- For each node:<br>             Should a Pod run here?<br>                  |<br>        +---------+---------+<br>        |                   |<br>       Yes                 No<br>        |                   |<br>  Create Pod on node     Skip<br>        |<br>        v<br>kubelet starts Pod</pre><p>Architecture Diagram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQTcsSujRB-YnpIxBLTMjw.png" /><figcaption>Kubernetes DeamonSet Diagram</figcaption></figure><p>Node join:</p><pre>New node → DaemonSet controller detects → creates Pod → kubelet runs it</pre><h3>Real-Life Example: When You Would Create a DaemonSet</h3><p>DaemonSets are used when you need <strong>exactly one Pod running on every node</strong> — or on a specific subset of nodes — to perform node-level operations.<br> Unlike Deployments or StatefulSets, DaemonSets follow nodes, not replicas.</p><p>Here’s a real, practical production example.</p><h4>Example: Deploying a Log Collector or Monitoring Agent on Every Node</h4><p>Imagine your platform needs to collect:</p><ul><li>node metrics</li><li>container logs</li><li>audit logs</li><li>disk usage</li><li>network statistics</li><li>application traces</li></ul><p>These must be collected <strong>from every single node</strong>, no matter how many nodes join or leave the cluster.</p><p>You deploy a DaemonSet to ensure each node runs <em>one copy</em> of the log/metrics agent:</p><pre>apiVersion: apps/v1<br>kind: DaemonSet<br>metadata:<br>  name: node-logger<br>spec:<br>  selector:<br>    matchLabels:<br>      name: node-logger<br>  template:<br>    metadata:<br>      labels:<br>        name: node-logger<br>    spec:<br>      containers:<br>      - name: fluentbit<br>        image: fluent/fluent-bit:latest<br>        volumeMounts:<br>        - mountPath: /var/log<br>          name: logs<br>      volumes:<br>      - name: logs<br>        hostPath:<br>          path: /var/log</pre><h4>Why a DaemonSet?</h4><p>Because a node-level agent must:</p><h4>1. Run on Every Node (Automatically)</h4><p>New node joins the cluster → agent Pod automatically appears.<br> Node deleted → Pod disappears with it.</p><h4>2. Have Direct Access to Node Resources</h4><p>Log collectors and monitoring agents often need:</p><ul><li>/var/log</li><li>/proc</li><li>/sys</li><li>container runtime sockets</li><li>host network information</li></ul><p>DaemonSets make privileged access simple and standard.</p><h4>3. Not Run More Than One Copy Per Node</h4><p>Scaling replicas (like a Deployment) would create random distribution.<br> DaemonSets guarantee exactly <strong>one</strong> (or more, if you choose) per node.</p><h4>4. Support Node Affinity / Node Labels</h4><p>Example: only run on worker nodes, GPU nodes, or storage nodes.</p><h4>5. Run Cluster Infrastructure Services</h4><p>Core components like:</p><ul><li>CNI network plugins (Calico, Cilium, Flannel)</li><li>log shippers (Fluent Bit, Filebeat)</li><li>monitoring agents (Prometheus Node Exporter, Datadog Agent)</li><li>security agents (Falco, Sysdig)</li><li>storage daemons (Rook, Ceph OSDs)</li></ul><p>All run as DaemonSets.</p><h3>Conclusion</h3><p>Creating a DaemonSet triggers a beautifully orchestrated sequence across the control plane:</p><ul><li>kubectl sends the manifest</li><li>API Server authenticates, validates, admits, and stores it</li><li>DaemonSet controller evaluates every node</li><li>one Pod is placed on each eligible node</li><li>kubelet creates and runs the Pod</li><li>new nodes automatically get new Pods</li><li>updates roll out in controlled fashion</li><li>node failures gracefully adjust Pod count</li></ul><p>DaemonSets are the backbone of node-level operations in Kubernetes — the invisible operators that keep the cluster logging, networking, monitoring, tracing, and securing itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=002f3f0485eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Create a StatefulSet in Kubernetes — A Deep, Internal-Level Breakdown]]></title>
            <link>https://tanmaybatham.medium.com/what-happens-when-you-create-a-statefulset-in-kubernetes-a-deep-internal-level-breakdown-3afc23b5a816?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/3afc23b5a816</guid>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[kubernetes-statefulset]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[etcd]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 06:34:48 GMT</pubDate>
            <atom:updated>2025-12-04T06:34:48.488Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happens When You Create a StatefulSet in Kubernetes — A Deep, Internal-Level Breakdown</h3><p>Kubernetes Series — K005</p><p>StatefulSets are one of the most powerful — and misunderstood — workload types in Kubernetes. They look similar to Deployments at first glance, but behind the scenes they behave very differently. StatefulSets guarantee <em>identity</em>, <em>ordering</em>, <em>stable storage</em>, and <em>predictable network names</em> for each Pod.</p><p>If Deployment Pods are cattle, StatefulSet Pods are closer to pets — each one has a name, a history, and its own home.</p><p>But what actually happens inside Kubernetes when you create a StatefulSet?</p><p>This deep dive follows a StatefulSet’s story end-to-end: it begins with a simple kubectl command, passes through the API Server’s pipeline, is stamped into etcd, moves through the StatefulSet controller’s strict ordering logic, and ultimately reaches kubelet and the persistent volumes that power each Pod into life—always in the exact, deterministic order Kubernetes promises.</p><p>Let’s explore the entire journey.</p><h3>It All Begins With kubectl apply</h3><p>When you create a StatefulSet:</p><pre>kubectl apply -f statefulset.yaml</pre><p>kubectl:</p><ol><li>Loads your kubeconfig</li><li>Validates the YAML (client-side)</li><li>Converts it into a Kubernetes StatefulSet object</li><li>Sends it to the API Server through:</li></ol><pre>POST /apis/apps/v1/namespaces/&lt;ns&gt;/statefulsets</pre><p>This is the <em>submission</em> phase — nothing is running yet.</p><h3>API Server: The StatefulSet’s First Checkpoint</h3><p>Once the request hits the cluster, the API Server takes over.</p><h4>Authentication</h4><p>Are you who you say you are?</p><h4>Authorization (RBAC)</h4><p>Are you allowed to create StatefulSets?</p><h4>Admission Controllers</h4><p>Here’s where Kubernetes or custom organizational policies may:</p><ul><li>Add default labels</li><li>Enforce Pod security</li><li>Validate volumeClaimTemplates</li><li>Enforce naming, image policies, resource policies</li><li>Reject invalid StatefulSet specs</li></ul><h3>Schema Validation</h3><p>The API Server verifies:</p><ul><li>The Pod template is valid</li><li>volumeClaimTemplates have valid storage classes</li><li>serviceName exists (important requirement)</li><li>Update strategy matches StatefulSet rules</li><li>Replicas are valid numbers</li></ul><p>If everything checks out, the StatefulSet is persisted into <strong>etcd</strong>.</p><h3>etcd: The Source of Truth</h3><p>etcd stores:</p><ul><li>The StatefulSet definition</li><li>Pod template</li><li>replica count</li><li>updates/strategy</li><li>volume templates</li></ul><p>At this stage, nothing is created yet — no Pods, no PVCs.</p><p>But etcd emits a <strong>watch event</strong>, and that’s what wakes up the StatefulSet controller.</p><h3>The StatefulSet Controller Wakes Up</h3><p>The StatefulSet controller (running inside the kube-controller-manager) continuously watches for:</p><pre>New StatefulSets<br>Updated StatefulSets<br>Deleted StatefulSets</pre><p>When your object is created, the controller begins reconciliation.</p><p>Here’s where the behavior diverges dramatically from Deployments and ReplicaSets.</p><h3>Identity, Order, and Predictability: The Three Rules of StatefulSets</h3><p>StatefulSets enforce three guarantees that no other workload type offers:</p><h4>1. Stable Network Identity</h4><p>Pods are named deterministically:</p><pre>&lt;statefulset-name&gt;-0<br>&lt;statefulset-name&gt;-1<br>&lt;statefulset-name&gt;-2</pre><p>Each one gets a predictable DNS entry via the headless service.</p><h4>2. Stable Storage</h4><p>Each Pod gets its own PersistentVolumeClaim (PVC):</p><pre>data-&lt;statefulset-name&gt;-0<br>data-&lt;statefulset-name&gt;-1<br>data-&lt;statefulset-name&gt;-2</pre><p>And these PVCs <em>never</em> get deleted automatically — even if the Pod is deleted.</p><h4>3. Ordered Creation, Ordered Termination, Ordered Updates</h4><p>Pods are created <strong>one at a time</strong>:</p><pre>Pod-0 → Pod-1 → Pod-2</pre><p>And deleted or updated in reverse order:</p><pre>Pod-2 → Pod-1 → Pod-0</pre><p>This is unique to StatefulSets.</p><h3>StatefulSets Without Databases — When Identity Matters Even Without Storage</h3><p>It’s easy to associate StatefulSets exclusively with databases like Cassandra, Kafka, or MongoDB. But StatefulSets are not “database controllers.” They are <strong>identity controllers</strong>.</p><p>There are many situations where you absolutely need a StatefulSet even when <strong>no database</strong> or <strong>persistent volume</strong> is involved.</p><p>Let’s look at the most important cases.</p><h4>1. Workloads That Need Predictable Network Identity</h4><p>Distributed systems that rely on stable node names, peer lists, or cluster membership often break when Pods get random names.</p><p>Examples:</p><ul><li>HashiCorp Consul servers</li><li>Etcd clusters</li><li>Custom control-plane components</li><li>Gossip/mesh-based distributed services</li><li>Systems with leader election tied to Pod identifiers</li></ul><p>Even with <em>no persistent storage</em>, stable names matter.</p><h4>2. Legacy or Enterprise Apps Expecting “Node-like” Behavior</h4><p>Some older or monolithic apps:</p><ul><li>assume fixed hostnames</li><li>hardcode node names</li><li>store identity in memory</li><li>require ordered startup</li></ul><p>These run perfectly with a StatefulSet — not a Deployment.</p><h4>3. Sharded Stateless Workloads</h4><p>Some stateless systems partition work by Pod index:</p><ul><li>shard-0 handles IDs 0–99</li><li>shard-1 handles IDs 100–199</li><li>shard-2 handles IDs 200–299</li></ul><p>These workloads need predictable ordinals.<br>Deployments cannot guarantee that.</p><h4>4. Distributed Caches or Brokers With Ephemeral State</h4><p>Examples:</p><ul><li>Redis shards without persistence</li><li>NATS clusters that rebuild state on boot</li><li>In-memory analytics engines</li><li>Real-time streaming workers with bootstrap logic</li></ul><p>Their runtime <em>state</em> is important — even if not stored on disk.</p><h4>5. Ordered Rollouts or Graceful Restart Requirements</h4><p>Some systems require:</p><ul><li>start in order</li><li>update in reverse order</li><li>stop carefully and sequentially</li></ul><p>This is exactly how StatefulSets behave.</p><h4>6. StatefulSet Without Storage Is Perfectly Valid</h4><p>A StatefulSet with:</p><pre>volumeClaimTemplates: []</pre><p>is still a fully functional StatefulSet.</p><p>You still get:</p><ul><li>stable names</li><li>predictable DNS</li><li>ordered creation and updates</li><li>controlled Pod identity</li></ul><p>Storage is optional.<br>Identity is the key value StatefulSets provide.</p><h3>How the Controller Creates Pods</h3><p>Let’s assume your StatefulSet requests 3 replicas.<br>The controller begins with index 0.</p><h4>Step 1: Check if Pod-0 exists</h4><p>If not, it creates:</p><pre>pod: <br>  name: &lt;statefulset&gt;-0<br>  ownerReference: StatefulSet<br>  volumeClaimTemplates: PVC-0</pre><h4>Step 2: Wait until Pod-0 is Ready</h4><p>The controller will <strong>not create Pod-1</strong> until Pod-0’s status is Ready.</p><p>This readiness-gating is essential for databases, distributed systems, and consensus clusters.</p><h4>Step 3: Create PVC-0</h4><p>For each volumeClaimTemplate, the controller generates:</p><pre>&lt;claim-name&gt;-&lt;statefulset-name&gt;-0</pre><p>This triggers the PV provisioner (CSI controller) to create physical storage.</p><p>Only once <strong>PVC-0 is bound and Pod-0 is running</strong>, the controller proceeds to Pod-1.</p><p>The loop continues until all Pod indices up to .spec.replicas - 1 are created.</p><h3>The Under-the-Hood Magic of PVC Creation</h3><p>When you specify:</p><pre>volumeClaimTemplates:<br>- metadata:<br>    name: data<br>  spec:<br>    accessModes: [&quot;ReadWriteOnce&quot;]<br>    storageClassName: fast-ssd<br>    resources:<br>      requests:<br>        storage: 20Gi</pre><p>Kubernetes automatically generates <strong>one PVC per Pod index</strong>:</p><pre>data-web-0<br>data-web-1<br>data-web-2</pre><p>The CSI controller provisions PersistentVolumes (PVs) that back these claims:</p><pre>pv-1234 (for Pod-0)<br>pv-5678 (for Pod-1)<br>pv-91011 (for Pod-2)</pre><h4>This storage is:</h4><ul><li>exclusive (per Pod)</li><li>persistent</li><li>never automatically deleted</li><li>reused by the same Pod identity</li></ul><p>Deleting the Pod does <strong>not</strong> delete the PVC.<br>Deleting the StatefulSet does <strong>not</strong> delete the PVC.</p><p>This preserves identity across crashes, restarts, and rescheduling.</p><h3>Scheduler: Picking Nodes for Each Pod</h3><p>The Scheduler sees a Pod like:</p><pre>spec.nodeName = &quot;&quot;</pre><p>And goes through its multi-step process:</p><ul><li>filtering</li><li>scoring</li><li>selecting best node</li><li>binding Pod to the node</li></ul><p>But with StatefulSets, storage topology matters:</p><ul><li>some CSI drivers pin volumes to zones</li><li>volumes must attach to nodes in the same zone</li><li>if a Pod moves zones, Kubernetes may not be able to mount its storage</li></ul><p>This is why StatefulSet Pods often get “sticky” node assignments.</p><h3>kubelet: Creating Pod-0 (and every Pod after)</h3><p>Once the scheduler assigns Pod-0 to a node:</p><p>kubelet:</p><ol><li>Mounts the PVC for Pod-0</li><li>Prepares the container image(s)</li><li>Pulls the images</li><li>Creates the Pod sandbox</li><li>Configures CNI networking</li><li>Starts the container(s)</li><li>Runs readiness/liveness probes</li><li>Updates Pod status in the API Server</li></ol><p>Only after kubelet marks the Pod as <strong>Ready</strong>, the StatefulSet controller allows Pod-1 creation.</p><h3>How Updates Work (A Beautiful, Ordered Dance)</h3><p>When you update the Pod template (e.g., new image tag):</p><p><strong>With the default strategy: </strong>RollingUpdate</p><p>StatefulSet controller performs:</p><pre>Update Pod-2<br>Wait for Ready<br>Update Pod-1<br>Wait for Ready<br>Update Pod-0</pre><p>Pods are updated <strong>in reverse ordinal order</strong>, ensuring:</p><ul><li>quorum safety for databases</li><li>consistent rolling upgrades</li><li>cluster-aware restarts</li></ul><p>This is mandatory for distributed systems like:</p><ul><li>Cassandra</li><li>Kafka</li><li>Zookeeper</li><li>MongoDB replica sets</li></ul><h3>What Happens on Pod Deletion?</h3><p>Deleting pod-1 manually results in:</p><ul><li>Pod-1 being deleted</li><li><strong>StatefulSet controller immediately recreating it</strong></li><li>Pod-1 receiving the same PVC (data-&lt;name&gt;-1)</li><li>same network identity</li><li>same ordinal number</li></ul><p>Deleting the StatefulSet leaves all PVCs intact.</p><p>This is by design: StatefulSets assume data MUST survive.</p><h3>Flow Diagram</h3><pre>kubectl apply<br>    |<br>    v<br>API Server (Auth → RBAC → Admission → Validation)<br>    |<br>    v<br>etcd (StatefulSet stored)<br>    |<br>    v<br>StatefulSet Controller<br>    |<br>    v<br>Creates PVC-0<br>Wait for PVC-0 bound<br>Create Pod-0<br>Wait until Pod-0 Ready<br>    |<br>    v<br>Create PVC-1 → Pod-1<br>Create PVC-2 → Pod-2</pre><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNi3BmD6wfm3fvob7863Yw.png" /><figcaption>Kubernetes StateFulSet Diagram</figcaption></figure><p>For updates:</p><pre>Reverse order:<br>Pod-N → Pod-(N-1) → … → Pod-0</pre><h3>Why StatefulSets Are Used for Databases (and Why Deployments Fail)</h3><p>StatefulSets provide:</p><ul><li>stable storage</li><li>stable Pod names</li><li>predictable DNS records</li><li>ordered scaling (up and down)</li><li>ordered rolling updates</li><li>PVC persistence</li></ul><p>Deployments provide:</p><ul><li>stateless replicas</li><li>random Pod names</li><li>no stable identity</li><li>no ordered restarts</li></ul><p>StatefulSets solve problems Deployments were never meant to solve.</p><h3>Common Misunderstandings Engineers Often Have</h3><h4>“StatefulSet Pods can be recreated anywhere.”</h4><p>Not always. Volume topology constraints apply.</p><h4>“Deleting the StatefulSet deletes the data.”</h4><p>It does not. PVCs stay.</p><h4>“Pods update in parallel.”</h4><p>Never. Always ordered.</p><h4>“You can scale down and reuse Pod names differently later.”</h4><p>No. Ordinals and PVC identities remain consistent.</p><h3>Debugging StatefulSets Like a Pro</h3><h4>Check pod ordering:</h4><pre>kubectl get pods -l app=mydb</pre><h4>Check PVC assignments:</h4><pre>kubectl get pvc | grep mydb</pre><h4>Check PV topology:</h4><pre>kubectl describe pv pv-xxxx</pre><h4>Check StatefulSet update status:</h4><pre>kubectl rollout status sts/myapp</pre><h4>Inspect ordered readiness:</h4><pre>kubectl describe sts/myapp</pre><h4>Look at events:</h4><pre>kubectl describe pod myapp-0</pre><h3>Kubernetes Workload Comparison Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Ci2V6c_uJgnLO0O6.png" /><figcaption>Kubernetes Workload Comparison Table</figcaption></figure><h3>Real-Life Example: When You Would Create a StatefulSet</h3><p>StatefulSets are the right choice when your application needs <strong>stable identity, ordered Pod startup, and persistent storage that sticks to each Pod</strong> — things Deployments cannot guarantee.</p><p>Here’s a real, practical example you’ll see in production.</p><h4>Example: Running a Database Cluster That Requires Stable Storage &amp; Predictable Pod Names</h4><p>Imagine you’re deploying a <strong>MongoDB Replica Set</strong>, <strong>Cassandra Ring</strong>, or <strong>Kafka Broker Cluster</strong>.<br>Each database node needs:</p><ul><li>its <strong>own persistent volume</strong> that never gets mixed with others</li><li>a <strong>predictable hostname</strong> (like db-0, db-1, db-2)</li><li>ordered startup (primary first, then followers)</li><li>predictable shutdown and update behavior</li><li>a volume that stays attached even if the Pod restarts or moves nodes</li></ul><p>A Deployment <strong>cannot</strong> provide these guarantees.<br>But a StatefulSet can — automatically.</p><p>Example:</p><pre>apiVersion: apps/v1<br>kind: StatefulSet<br>metadata:<br>  name: mongo<br>spec:<br>  serviceName: &quot;mongo&quot;<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: mongo<br>  template:<br>    metadata:<br>      labels:<br>        app: mongo<br>    spec:<br>      containers:<br>      - name: mongo<br>        image: mongo:6<br>        volumeMounts:<br>        - name: data<br>          mountPath: /data/db<br>  volumeClaimTemplates:<br>  - metadata:<br>      name: data<br>    spec:<br>      accessModes: [&quot;ReadWriteOnce&quot;]<br>      resources:<br>        requests:<br>          storage: 20Gi</pre><h3>Why a StatefulSet?</h3><h4>1. Each Pod Gets Its Own Persistent Volume</h4><p>The StatefulSet creates:</p><pre>data-mongo-0<br>data-mongo-1<br>data-mongo-2</pre><p>These volumes never get deleted automatically.</p><h4>2. Stable, Predictable Pod Hostnames</h4><p>Pods come up as:</p><pre>mongo-0<br>mongo-1<br>mongo-2</pre><p>Database clusters depend heavily on predictable names.</p><h4>3. Ordered Startup &amp; Shutdown</h4><p>StatefulSets ensure:</p><ul><li>mongo-0 starts first</li><li>then mongo-1</li><li>then mongo-2</li></ul><p>Perfect for leader election and replication.</p><h4>4. Ordered Rolling Updates</h4><p>Updates happen in reverse order:</p><pre>mongo-2 → mongo-1 → mongo-0</pre><p>Safest strategy for distributed systems.</p><h4>5. Identity Survives Restarts</h4><p>If mongo-1 crashes, it always returns as mongo-1, with the same storage attached.</p><h3>Conclusion</h3><p>Creating a StatefulSet triggers a sophisticated chain of events:</p><ul><li>kubectl submits the object</li><li>API Server authenticates, validates and stores it</li><li>StatefulSet controller assigns deterministic identities</li><li>PVCs are created per Pod index</li><li>Scheduler binds Pods considering storage and topology</li><li>kubelet mounts volumes and launches Pods</li><li>Updates roll out in reverse order</li><li>Deletions respect ordering and identity</li><li>PVCs remain long after Pods or StatefulSets are gone</li></ul><p>StatefulSets are not simply Deployments with volumes — they are carefully engineered orchestration mechanisms built for consistency, identity, and order.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3afc23b5a816" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Create a Secret in Kubernetes — A Deep, Internal-Level Breakdown]]></title>
            <link>https://tanmaybatham.medium.com/what-happens-when-you-create-a-secret-in-kubernetes-a-deep-internal-level-breakdown-c3918f5af71f?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3918f5af71f</guid>
            <category><![CDATA[kubernetes-secret]]></category>
            <category><![CDATA[etcd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[k8s]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 11:34:36 GMT</pubDate>
            <atom:updated>2025-12-03T11:34:36.423Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happens When You Create a Secret in Kubernetes — A Deep, Internal-Level Breakdown</h3><p>Kubernetes Series — K004</p><p>Kubernetes Secrets feel simple on the surface:<br>store passwords, tokens, certificates, or keys — and reference them from Pods.</p><p>But behind the scenes, creating a Secret triggers a surprisingly sophisticated chain of operations involving authentication, admission control, validation, base64 encoding, etcd encryption, kubelet syncing, volume projection, and Pod consumption semantics.</p><p>Even though the API is almost identical to ConfigMaps, Secrets behave differently in many subtle — and critically important — ways.</p><p>Think of this guide as a backstage tour of what happens after you create a Secret. We’ll trace its path from your terminal, through the API Server’s layers of checks, into etcd’s vault, across the control plane’s moving parts, and ultimately to the kubelet, where your applications finally receive it.</p><p>This is the “Secret lifecycle” as Kubernetes <em>actually</em> implements it.</p><p>Let’s begin.</p><h3>You Create a Secret — or So You Think</h3><p>When you run:</p><pre>kubectl create secret generic db-creds --from-literal=username=admin --from-literal=password=Passw0rd!</pre><p>or:</p><pre>kubectl apply -f secret.yaml</pre><p>The cluster does not immediately “create” anything. First, kubectl prepares a Kubernetes Secret object.</p><h3>What kubectl does:</h3><ul><li>Loads your kubeconfig</li><li>Validates the manifest</li><li>Converts the Secret into a Kubernetes API object</li><li>Base64-encodes all data: fields (client-side)</li><li>Sends a REST request:</li></ul><pre>POST /api/v1/namespaces/&lt;ns&gt;/secrets</pre><p>This is where the real processing starts.</p><h3><strong>API Server: The Security Gateway</strong></h3><p>The Secret request journeys through multiple layers of the API Server.</p><h3>1. Authentication</h3><p>The API Server identifies the client:</p><ul><li>TLS certificates</li><li>ServiceAccount tokens</li><li>OAuth/OIDC</li><li>Cloud-provider auth providers</li><li>Exec credential plugins</li></ul><p>If identity fails → 401 Unauthorized.</p><h3>2. Authorization (RBAC)</h3><p>The API Server verifies:</p><pre>verbs: [&quot;create&quot;]<br>resources: [&quot;secrets&quot;]</pre><p>If not permitted → 403 Forbidden.</p><h3>3. Admission Controllers</h3><h4>Mutating Admission Webhooks</h4><p>Rare for Secrets, but possible:</p><ul><li>Add security annotations</li><li>Strip dangerous fields</li><li>Apply labeling conventions</li></ul><h4>Validating Admission Webhooks</h4><p>Common in security-focused clusters:</p><ul><li>Enforce encryption policies</li><li>Require certain annotations</li><li>Validate certificate/key format</li><li>Restrict sizes or key names</li><li>Enforce secret types</li></ul><h4>PodSecurity / PSA</h4><p>May deny mounting certain secret types in restricted contexts.</p><h3>4. Schema validation</h3><p>Ensures:</p><ul><li>type: field is allowed</li><li>base64-decoded value is valid</li><li>size does not exceed limits</li></ul><p>If everything passes → the Secret is accepted.</p><h3>The Critical Part: etcd Storage (and Encryption)</h3><p>Secrets are stored in etcd under:</p><pre>/registry/secrets/&lt;namespace&gt;/&lt;name&gt;</pre><p>This is where the <em>major difference</em> between ConfigMaps and Secrets begins.</p><h3>By default, Secrets in etcd are:</h3><ul><li>Base64-encoded (always)</li><li><strong>NOT encrypted at rest</strong> unless encryption is explicitly enabled</li><li>Versioned</li><li>Watchable</li><li>Stored in structured JSON/Protobuf</li></ul><h3>With encryption enabled</h3><p>The API Server encrypts only the .data portion of Secrets.</p><p>An example encryption config:</p><pre>apiVersion: apiserver.config.k8s.io/v1<br>kind: EncryptionConfiguration<br>resources:<br>- resources:<br>  - secrets<br>  providers:<br>  - aescbc:<br>      keys:<br>      - name: key1<br>        secret: &lt;BASE64-KEY&gt;<br>  - identity: {}</pre><p>This means:</p><ul><li>A Secret is decrypted only in-memory inside the API Server</li><li>etcd only stores ciphertext</li><li>Unauthorized access to etcd doesn’t expose Secret plaintext</li></ul><p>If encryption is not configured — <strong>your Secrets are only base64-encoded, not secure</strong>.</p><p>This is one of Kubernetes’ most misunderstood facts.</p><h3>After Storage: Who Reacts to a New Secret?</h3><p>Unlike Deployments or StorageClasses, the Secret object itself doesn’t trigger controllers.</p><p>There is no “Secret controller.”</p><p>Instead:</p><ul><li>Pods reference Secrets</li><li>kubelet reacts when Pods need Secrets</li><li>CSI drivers may react for Secret-backed volumes</li><li>Admission controllers may check for required Secrets</li></ul><p>Secrets are <em>passive</em> until consumed.</p><h3>How Pods Consume Secrets</h3><p>Secrets can be used in three main ways:</p><h4>1. Environment Variables (static)</h4><pre>env:<br>- name: DB_PASSWORD<br>  valueFrom:<br>    secretKeyRef:<br>      name: db-creds<br>      key: password</pre><p>At Pod startup:</p><ul><li>kubelet fetches the Secret from the API Server</li><li>value is injected into the environment</li><li>value remains static for the lifetime of that container</li></ul><p>Even if you update the Secret, <strong>the environment variable doesn’t change</strong>.</p><h4>2. Mounted Secret Volumes (dynamic file system projection)</h4><pre>volumes:<br>- name: secret-vol<br>  secret:<br>    secretName: db-creds</pre><pre>volumeMounts:<br>- name: secret-vol<br>  mountPath: /etc/creds</pre><p>With this, each Secret key becomes a file:</p><pre>/etc/creds/username<br>/etc/creds/password</pre><p>These files <strong>can update automatically</strong> when the Secret changes, thanks to kubelet.</p><p>But we’ll go deeper into how that works.</p><h4>3. Secret-based imagePullSecrets</h4><p>These Secrets store Docker registry credentials.</p><pre>imagePullSecrets:<br>- name: registry-creds</pre><p>Used by:</p><ul><li>kubelet</li><li>container runtime (containerd, CRI-O)</li></ul><p>Secrets used for pulling images are fetched before containers start.</p><h3>The Hidden Engine: kubelet’s Secret Volume Manager</h3><p>This is one of the most important parts of this whole story — and one that trips up many engineers.</p><p>When a Pod that references a Secret is scheduled to a node, kubelet:</p><ul><li>Fetches the Secret from its local cache or API Server</li><li>Writes the Secret to a local node directory:</li></ul><pre>/var/lib/kubelet/pods/&lt;pod-uid&gt;/volumes/kubernetes.io~secret/&lt;secret-name&gt;/</pre><ul><li>Writes each key as a file</li><li>Sets correct permissions (0400 by default)</li><li>Atomically mounts it into the container’s filesystem via symlink:</li></ul><pre>current -&gt; data_56789</pre><p>When the Secret is updated:</p><ul><li>kubelet receives a watch event</li><li>rewrites the local data directory</li><li>updates the symlink atomically</li><li>the Pod’s filesystem instantly reflects the new values</li></ul><p>However — and this is critical —</p><p><strong>your application must re-read the new files. Kubernetes does NOT restart your Pods.</strong></p><h3>The Subtle Differences: Secrets vs. ConfigMaps</h3><p>Although both are volume-projected objects, their behavior differs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*OyT7d-fRjFlK6ml-GVfOjg.png" /><figcaption>Secrets vs. ConfigMaps</figcaption></figure><p>Secrets have stricter permission and security semantics.</p><h3>Why a Secret Update Doesn’t Restart Your Pods</h3><p>This is a common misunderstanding.</p><p>When a Secret changes:</p><ul><li>Mounted Secret volumes update automatically</li><li>Environment variables do not</li><li>Applications must detect the changes</li><li>Kubernetes does not restart containers</li><li>Deployments do not roll Pods unless you explicitly trigger a rollout</li></ul><p>Most people assume a Secret update forces a rolling restart.</p><p>It does not.</p><h3>The Security Footprint: Who Can See Your Secret?</h3><p>A Secret can be read by:</p><ul><li>users with RBAC get secrets permission</li><li>Pods referencing the Secret</li><li>kubelet on the node running those Pods</li><li>CSI drivers (if using CSI SecretStore)</li><li>API Server (decrypts stored ciphertext)</li><li>etcd (if encryption disabled → plaintext)</li></ul><p>To reduce exposure:</p><ul><li>enable encryption at rest</li><li>limit RBAC permissions</li><li>avoid debugging containers with secrets in env</li><li>avoid logging secrets accidentally</li></ul><p>Secrets are not “high-security” by default — they become secure only when the cluster is configured securely.</p><h3>Flow Diagram</h3><pre>kubectl apply<br>     |<br>     v<br>API Server<br>  Auth → RBAC → Admission → Validation<br>     |<br>     v<br>etcd (encrypted or base64 only)<br>     |<br>     |<br>Pods reference Secret?<br>     |<br>     +-- NO → nothing happens<br>     |<br>     +-- YES → kubelet consumes Secret<br>                   |<br>                   v<br>         writes files with 0400 perms<br>                   |<br>                   v<br>         mounts into Pod filesystem<br>                   |<br>                   v<br>      application reads secret values</pre><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFQAtqX6kRaBpprOdfnpXw.png" /><figcaption>Kubernetes Sectrets Flow</figcaption></figure><h3>The Full Secret Lifecycle</h3><ol><li>You create a Secret using kubectl</li><li>kubectl base64-encodes the data</li><li>API Server authenticates &amp; authorizes you</li><li>Admission webhooks mutate or validate the Secret</li><li>API Server encrypts the Secret (if configured)</li><li>etcd stores the Secret versioned</li><li>Pods that reference it trigger kubelet to fetch it</li><li>kubelet writes &amp; mounts the Secret as a volume</li><li>Updates propagate through kubelet</li><li>Your application controls whether and how it reloads configuration</li></ol><p>Secrets are not “magic”; they are simply versioned key-value pairs paired with strict storage and permission semantics.</p><h3>Real-Life Example: When You Would Create a Secret</h3><p>Secrets are used when your application needs <strong>sensitive data</strong> that must not be exposed in plain text, checked into Git, or baked into images.</p><p>They store confidential values securely and deliver them to Pods in a controlled way.</p><p>Here’s a real, production example.</p><h4>Example: Storing Database Credentials for a Production Application</h4><p>Imagine your microservice connects to a production database.<br> You must provide:</p><ul><li>DB_USERNAME</li><li>DB_PASSWORD</li><li>DB_CONNECTION_STRING</li></ul><p>These values are <strong>confidential</strong> and cannot be stored:</p><ul><li>in container images</li><li>inside ConfigMaps</li><li>in plain-text YAML files</li><li>in Git repositories</li><li>inside environment-specific manifests</li></ul><p>You create a Kubernetes Secret instead:</p><pre>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: db-credentials<br>type: Opaque<br>data:<br>  username: bXlkYl91c2Vy    # base64 encoded<br>  password: c2VjdXJlUGFzcw==  # base64 encoded<br>  connection: ZGI0LnByb2QuY29tcGFueS5jb206NTQzMg==</pre><p>Your Deployment injects the Secret as environment variables:</p><pre>env:<br>- name: DB_USERNAME<br>  valueFrom:<br>    secretKeyRef:<br>      name: db-credentials<br>      key: username<br>- name: DB_PASSWORD<br>  valueFrom:<br>    secretKeyRef:<br>      name: db-credentials<br>      key: password<br>- name: DB_CONNECTION<br>  valueFrom:<br>    secretKeyRef:<br>      name: db-credentials<br>      key: connection</pre><h4>Why a Secret?</h4><p>Because sensitive data must:</p><h4>1. Never Be Stored in Plaintext</h4><p>Secrets are base64-encoded and can be encrypted at rest (via KMS or etcd encryption).</p><h4>2. Be Protected From Unauthorized Access</h4><p>RBAC ensures only specific service accounts or teams can read the Secret.</p><h4>3. Be Mounted or Injected Safely</h4><p>Secrets can be delivered as:</p><ul><li>environment variables</li><li>mounted files</li><li>volume-mounted certificates</li><li>TLS keys</li><li>OIDC tokens</li></ul><h4>4. Be Rotatable Without Rebuilding Images</h4><p>Changing database credentials should not require a new Docker image or code change.</p><h4>5. Stay Separate From Non-Sensitive Config (ConfigMaps)</h4><p>Password → Secret<br>Log level / feature flags → ConfigMap</p><h4>6. Support Certificates, TLS Keys, SSH Keys, Tokens</h4><p>Secrets support multiple type: fields:</p><ul><li>kubernetes.io/tls</li><li>kubernetes.io/dockerconfigjson</li><li>bootstrap-token</li><li>Opaque custom secrets</li></ul><h3>Conclusion</h3><p>Creating a Secret might feel like a small action — but inside Kubernetes, it activates many subsystems:</p><ul><li>client-side encoding</li><li>API Server pipelines</li><li>admission-based governance</li><li>etcd storage and encryption</li><li>kubelet’s volume manager</li><li>Pod injection flows</li><li>mounted file updates</li><li>application reload behavior</li></ul><p>This deep dive reveals the truth:<br>Kubernetes Secrets are only as secure and functional as the <em>cluster configuration</em> and <em>application behavior</em> that surrounds them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3918f5af71f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Create a ConfigMap in Kubernetes — A Deep, Internal-Level Breakdown]]></title>
            <link>https://tanmaybatham.medium.com/what-happens-when-you-create-a-configmap-in-kubernetes-a-deep-internal-level-breakdown-390051d71463?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/390051d71463</guid>
            <category><![CDATA[kubebernetes-internal]]></category>
            <category><![CDATA[kubernetes-configmap]]></category>
            <category><![CDATA[kubenetes]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[etcd]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 06:13:14 GMT</pubDate>
            <atom:updated>2025-12-03T06:13:14.357Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happens When You Create a ConfigMap in Kubernetes — A Deep, Internal-Level Breakdown</h3><p>Kubernetes Series — K003</p><p>ConfigMaps look harmless.<br>A few key-value pairs, some JSON, a handful of environment variables — and your application magically receives its configuration.</p><p>But behind the scenes, something much deeper happens.</p><p>Creating a ConfigMap kicks off a chain of interactions involving</p><ul><li>the API Server’s security pipeline,</li><li>etcd’s storage engine,</li><li>kubelet’s volume manager,</li><li>the container runtime,</li><li>the projected volume system,</li><li>and the Pod’s execution lifecycle.</li></ul><p>Most engineers think “ConfigMap = dictionary stored in Kubernetes,” but the internals reveal far more complexity, especially when Pods mount ConfigMaps as volumes or consume them as environment variables.</p><p>Let’s walk through the entire journey of a ConfigMap — from the moment you run kubectl apply to the instant your application reads the configuration file.</p><h3>The Story Begins: You Create a ConfigMap</h3><p>You start with something like this:</p><pre>kubectl create configmap app-config --from-file=config.json</pre><p>Or:</p><pre>kubectl apply -f configmap.yaml</pre><p>At this moment, Kubernetes isn’t storing your configuration yet.<br>kubectl first prepares the ground.</p><h3>What kubectl actually does</h3><p>kubectl:</p><ol><li>Loads your kubeconfig</li><li>Determines the current context</li><li>Reads the ConfigMap source (literal, file, env, etc.)</li><li>Creates a ConfigMap API object in JSON</li><li>Sends a REST request to the API Server</li></ol><p>The request looks like:</p><pre>POST /api/v1/namespaces/&lt;ns&gt;/configmaps</pre><p>This initiates the entire lifecycle.</p><h3>Crossing the Gatehouse: The API Server Path</h3><p>Once the request hits the cluster, the API Server applies three layers of checks.</p><h3>1. Authentication</h3><p>The cluster identifies who you are:</p><ul><li>TLS client cert</li><li>Token / ServiceAccount token</li><li>OIDC identity</li><li>Cloud provider auth</li><li>Exec plugin</li></ul><p>If identity verification fails → <strong>401 Unauthorized</strong>.</p><h3>2. Authorization (RBAC)</h3><p>The API Server checks if your identity has permission:</p><pre>verbs: [&quot;create&quot;]<br>resources: [&quot;configmaps&quot;]</pre><p>If not → <strong>403 Forbidden</strong>.</p><h3>3. Admission Controls</h3><p>This is the most extensible and powerful part of Kubernetes.</p><p>Before writing the ConfigMap to etcd, the API Server runs it through:</p><h4>Mutating Webhooks</h4><p>Rare for ConfigMaps, but possible:</p><ul><li>Add labels</li><li>Add annotations</li><li>Normalize keys</li><li>Enforce naming conventions</li></ul><h4>Validating Webhooks</h4><p>Much more common:</p><ul><li>Enforce ConfigMap size limits</li><li>Block certain patterns</li><li>Enforce governance policies</li><li>Validate structure of embedded files</li></ul><h4>Kubernetes built-in schema checks</h4><ul><li>Keys must be valid</li><li>Size must not exceed etcd limits</li><li>binaryData must be base64</li></ul><p>Only if all succeed, the ConfigMap is ready to be persisted.</p><h3>The Heart of the Cluster: Storing a ConfigMap in etcd</h3><p>ConfigMaps are stored as objects under:</p><pre>/registry/configmaps/&lt;namespace&gt;/&lt;name&gt;</pre><p>etcd stores:</p><ul><li>metadata (labels, annotations)</li><li>the data map</li><li>binaryData (if any)</li><li>timestamps</li><li>resourceVersion</li><li>UID</li></ul><p>This makes ConfigMaps:</p><ul><li>strongly consistent</li><li>versioned</li><li>watchable</li><li>atomic on update</li></ul><p>This is important:<br><strong>ConfigMaps are not “applied” to any Pod automatically.</strong><br>They are just stored — nothing more.</p><h3>So Who Actually Uses the ConfigMap?</h3><p>This is where many people misunderstand Kubernetes.</p><p>A ConfigMap alone does nothing.<br> It becomes meaningful only when <strong>a Pod references it</strong>.</p><p>Pods can consume ConfigMaps in three ways:</p><h4>1. Environment Variables (copy-on-start)</h4><p>Example:</p><pre>envFrom:<br>- configMapRef:<br>    name: app-config</pre><p>OR:</p><pre>env:<br>- name: DB_URL<br>  valueFrom:<br>    configMapKeyRef:<br>      name: app-config<br>      key: url</pre><p>In this model:</p><ul><li>kubelet injects values into environment variables <strong>at Pod startup</strong></li><li>After container starts, these values <strong>never update</strong>, even if ConfigMap changes</li></ul><p>This surprises many engineers.</p><h4>2. Command-line arguments (also static)</h4><p>Some apps read configuration via arguments:</p><pre>args:<br>  - &quot;--config=$(CONFIG_URL)&quot;</pre><p>Again — <strong>static</strong>.<br>Never refreshed.</p><h4>3. Mounted Files via ConfigMap Volumes (dynamic)</h4><p>This is where things get interesting.</p><pre>volumes:<br>- name: config<br>  configMap:<br>    name: app-config</pre><pre>volumeMounts:<br>- mountPath: /etc/config<br>  name: config</pre><p>This creates files inside the Pod:</p><pre>/etc/config/key1<br>/etc/config/key2<br>...</pre><p>Unlike env vars, these <em>can</em> update dynamically — depending on kubelet and how your application handles updates.</p><h3>Where the Magic Happens: kubelet’s Volume Manager</h3><p>When a Pod with a ConfigMap volume is assigned to a node, kubelet begins a series of steps:</p><h4>1. Kubelet fetches the ConfigMap</h4><p>From its local API cache or from the API Server.</p><h4>2. Writes ConfigMap data to a special directory</h4><p>Example path:</p><pre>/var/lib/kubelet/pods/&lt;pod-uid&gt;/volumes/kubernetes.io~configmap/&lt;volume-name&gt;/</pre><p>Inside this directory:</p><ul><li>Each ConfigMap key becomes a file</li><li>File contents are written atomically</li><li>Permissions default to 0644</li></ul><h4>3. Creates an atomic symlink</h4><p>Kubelet uses a “shadow directory + symlink” pattern:</p><pre>/volumes/.../configmap/<br>    current -&gt; data_123456/<br>    data_123456/<br>         key1<br>         key2</pre><p>When ConfigMap updates:</p><ul><li>new directory gets created</li><li>kubelet atomically switches current symlink</li></ul><p>This makes updates:</p><ul><li>safe</li><li>atomic</li><li>no partial writes</li><li>zero downtime</li></ul><h3>BUT — your container still needs to detect changes itself</h3><p>Kubernetes does <strong>not</strong> restart the container when ConfigMaps update.</p><h3>The Reality of ConfigMap Updates: Why Apps Don’t Auto-Reload</h3><p>ConfigMap update flow:</p><pre>ConfigMap updated<br>       ↓<br>API Server updates etcd<br>       ↓<br>Watch event sent to kubelet<br>       ↓<br>kubelet rewrites volume directory<br>       ↓<br>Container filesystem updates<br>       ↓<br>Application... maybe reloads?</pre><p>Key point:</p><h3>Kubernetes updates the files — but does NOT restart your app.</h3><p>Your application must:</p><ul><li>poll for changes</li><li>watch file changes</li><li>reload config on SIGHUP</li><li>use a reloader sidecar</li><li>use Reloader/ConfigMap-Reload operators</li></ul><p>This distinction is often missed.</p><h3>The Edge Case: Immutable ConfigMaps</h3><p>Immutable ConfigMaps were introduced for:</p><ul><li>performance</li><li>stability</li><li>protection against accidental mutation</li><li>simplifying caching in kubelet and controllers</li></ul><pre>immutable: true</pre><p>Effects:</p><ul><li>no more updates allowed</li><li>kubelet stops watching changes</li><li>volume syncs disabled</li><li>updates require creating a new ConfigMap</li></ul><p>This pattern is common in production systems for safety and performance.</p><h3>Why ConfigMap Changes Sometimes Don’t Show Up in Running Pods</h3><p>Many engineers encounter this:</p><blockquote>“I updated the ConfigMap but Pods still have old data!”</blockquote><p>Possible reasons:</p><h4>1. You’re using environment variables</h4><p>These never update.</p><h4>2. Application does not re-read files</h4><p>Most frameworks load config only once.</p><h4>3. Kubelet sync period</h4><p>File update interval is not instant (default ~60 seconds).</p><h4>4. You’re using immutable ConfigMaps</h4><h4>5. Your Pod mounts ConfigMap using subPath</h4><p>This is a known caveat — subPath mounts do <strong>not</strong> update.</p><h3>Practical Debugging Checklist</h3><p><strong>Check the ConfigMap content:</strong></p><pre>kubectl get cm app-config -o yaml</pre><p><strong>Check Pod mounts:</strong></p><pre>kubectl describe pod &lt;pod&gt; | grep -i config</pre><p><strong>Check file inside container:</strong></p><pre>kubectl exec &lt;pod&gt; -- ls -R /etc/config<br>kubectl exec &lt;pod&gt; -- cat /etc/config/key1</pre><p><strong>Check kubelet logs for update issues:</strong></p><pre>journalctl -u kubelet -f</pre><p><strong>Check if using subPath:</strong><br> If yes — file updates won’t propagate.</p><h3>Flow Diagram</h3><pre>kubectl apply<br>     |<br>     v<br>API Server<br>(Auth → RBAC → Admission → Validation)<br>     |<br>     v<br>etcd (persist ConfigMap)<br>     |<br>     v<br>Pods referencing ConfigMap?<br>     |<br>     +-- NO ---&gt; Nothing happens<br>     |<br>     +-- YES ---&gt; kubelet manages volume<br>                      |<br>                      v<br>         writes files → updates symlink → mounts into container<br>                      |<br>                      v<br>             application reads config</pre><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ZPwiRTJLvfvB9zqfe3MNA.png" /><figcaption>Kubectl ConfigMap Architecture</figcaption></figure><h3>Real-Life Example: When You Would Create a ConfigMap</h3><p>ConfigMaps are the right choice whenever your application needs <strong>externalized configuration</strong> — settings that should not be baked into the container image, and must be changeable without rebuilding the application.</p><p>Here’s a real, production-grade example.</p><h3>Example: Storing Application Configuration That Must Change Across Environments</h3><p>Imagine you’re running a backend API that must behave differently in <strong>dev</strong>, <strong>staging</strong>, and <strong>production</strong> environments.</p><p>You want to externalize environment-specific configuration like:</p><ul><li>feature flags</li><li>API base URLs</li><li>log levels</li><li>cache timeouts</li><li>rate-limit thresholds</li><li>non-sensitive connection settings</li></ul><p>Instead of hardcoding these values inside the container image, you store them in a <strong>ConfigMap</strong>:</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: api-config<br>data:<br>  LOG_LEVEL: &quot;info&quot;<br>  FEATURE_X_ENABLED: &quot;true&quot;<br>  CACHE_TTL: &quot;300&quot;<br>  BASE_API_URL: &quot;https://api.prod.company.com&quot;</pre><p>Your Deployment consumes the ConfigMap:</p><pre>envFrom:<br>- configMapRef:<br>    name: api-config</pre><h4>Why a ConfigMap?</h4><p>Because configuration must be:</p><h4>1. Editable Without Rebuilding Images</h4><p>Changing LOG_LEVEL or CACHE_TTL should NOT require rebuilding the Docker image.</p><h4>2. Environment-Specific</h4><p>Different environments (dev/staging/prod) need different configs without rewriting code.</p><h4>3. Non-Sensitive</h4><p>Secrets belong in Secrets.<br>Configs belong in ConfigMaps.</p><h4>4. Mounted or Injected Cleanly Into Pods</h4><p>You can deliver configs via:</p><ul><li>environment variables</li><li>files mounted inside containers</li><li>configmapRef / envFrom</li></ul><h4>5. Changeable Without Redeploying the App (If Mounted as Volumes)</h4><p>Mounted ConfigMap volumes update automatically (most cases), enabling “dynamic config reloading.”</p><h4>6. Versioned and Tracked by GitOps</h4><p>Teams track config changes over time.</p><h3>Conclusion</h3><p>Creating a ConfigMap is deceptively simple, but the internal machinery powering it is anything but:</p><ul><li>kubectl creates and sends the object</li><li>API Server validates and persists it</li><li>etcd safely stores versioned configuration</li><li>kubelet maintains mounted files on each node</li><li>updated ConfigMaps propagate through watch events</li><li>applications must decide how to react to changes</li></ul><p>ConfigMaps embody Kubernetes’ declarative model: <em>you declare configuration once, and the system keeps it consistent across the cluster.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=390051d71463" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Create a Job in Kubernetes — A Deep, Internal-Level Breakdown]]></title>
            <link>https://tanmaybatham.medium.com/what-happens-when-you-create-a-job-in-kubernetes-a-deep-internal-level-breakdown-2257fa53381d?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/2257fa53381d</guid>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[etcd]]></category>
            <category><![CDATA[kubernetes-job]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Tue, 02 Dec 2025 10:06:06 GMT</pubDate>
            <atom:updated>2025-12-03T06:10:48.386Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happens When You Create a Job in Kubernetes — A Deep, Internal-Level Breakdown</h3><p>Kubernetes Series — K007</p><p>Kubernetes Jobs are one of the most misunderstood workload types.<br>They look simple — you define a Pod template, Kubernetes runs it, the Pod completes — but under the hood, Jobs drive a complex orchestration spanning the API Server, controllers, retries, parallelism logic, completions tracking, and failure handling.</p><p>Unlike Deployments or StatefulSets, Jobs don’t create long-running Pods.<br>They create Pods that must <strong>run to completion</strong>, and Kubernetes must <strong>guarantee</strong> that the workload finishes successfully — even in the face of Pod failures, node crashes, restarts, preemptions, or backoff delays.</p><p>So what <em>really</em> happens when you run:</p><pre>kubectl apply -f job.yaml</pre><p>This deep dive walks through the entire lifecycle — <br>from the moment your kubectl command leaves your terminal,<br>through the API Server pipeline, into etcd storage, through the Job controller’s reconciliation logic and finally to how kubelet ensures your Pod actually finishes.</p><p>Let’s follow the Job’s journey end-to-end.</p><h3>It Begins With kubectl apply</h3><p>You apply a Job definition:</p><pre>kubectl apply -f job.yaml</pre><p>kubectl:</p><ol><li>loads kubeconfig</li><li>validates the YAML (client-side)</li><li>constructs a Job API object</li><li>serializes it to JSON</li><li>sends an HTTP request to the API Server:</li></ol><pre>POST /apis/batch/v1/namespaces/&lt;ns&gt;/jobs</pre><p>Job creation hasn’t actually happened yet — this is just the submission.</p><h3>API Server: Authentication, Authorization &amp; Admission</h3><p>The created object travels through the API Server pipeline.</p><h4>Authentication</h4><p>Verifies the client identity via:</p><ul><li>certificates</li><li>Tokens</li><li>OIDC</li><li>cloud provider auth</li><li>exec plugins</li></ul><p>Fail → 401 Unauthorized.</p><h4>Authorization (RBAC)</h4><p>Checks:</p><pre>verbs: [&quot;create&quot;]<br>resources: [&quot;jobs&quot;]</pre><p>Fail → 403 Forbidden.</p><h4>Admission Controllers</h4><p>Mutating and validating plugins may:</p><ul><li>add defaults</li><li>validate job spec</li><li>enforce parallelism limits</li><li>enforce PodSecurity</li><li>restrict container images</li><li>modify labels/annotations</li></ul><h4>Schema validation</h4><p>Ensures the manifest is structurally correct:</p><ul><li>spec.template is a valid Pod template</li><li>pec.completions and spec.parallelism are non-negative</li><li>selectors are valid</li><li>backoffLimit is valid</li><li>TTLSecondsAfterFinished is acceptable</li></ul><p>After all checks, the Job is accepted and persisted.</p><h3>etcd: The Persistent Record of the Job</h3><p>The Job is stored in etcd under:</p><pre>/registry/jobs/&lt;namespace&gt;/&lt;name&gt;</pre><p>All metadata, status, and templates are stored in structured form.</p><p>Once stored, the Job is now “visible” to the Job controller via watch events.</p><h3>The Job Controller Wakes Up</h3><p>The Job controller is responsible for:</p><ul><li>creating Pods</li><li>tracking their status</li><li>ensuring successful completion</li><li>retrying failures</li><li>enforcing backoff behavior</li><li>handling parallelism</li><li>updating .status fields</li><li>cleaning up finished Pods (TTL policy)</li></ul><p>As soon as the controller receives the watch event:</p><pre>New Job: &lt;job-name&gt;</pre><p>It begins its reconciliation loop.</p><h3>How a Job Actually Runs Pods</h3><p>Unlike Deployments (ReplicaSets) and StatefulSets, Jobs create Pods <strong>directly</strong> (like DaemonSets do).<br>There is no ReplicaSet involved.</p><p>Job controller logic uses three main fields:</p><ul><li>.spec.completions</li><li>.spec.parallelism</li><li>.spec.backoffLimit</li></ul><p>Let’s break down how Pods get created.</p><h4>1. Sequential Jobs (default)</h4><p>If you do not set completions or parallelism, defaults are:</p><pre>completions = 1<br>parallelism = 1</pre><p>Meaning:</p><ul><li>one Pod runs</li><li>that Pod must complete successfully</li><li>if it fails → retry until backoffLimit reached</li></ul><h4>2. Parallel Jobs</h4><p>If your Job defines:</p><pre>parallelism: 5<br>completions: 20</pre><p>The controller will run up to 5 Pods simultaneously until 20 successful completions occur.</p><p>This requires:</p><ul><li>tracking each Pod’s status</li><li>maintaining an internal count</li><li>ensuring no more than parallelism active Pods exist</li></ul><p>Parallel Jobs require complex orchestration — including creating multiple Pods with deterministic names.</p><h4>3. Indexed Parallel Jobs (Advanced Use Case)</h4><p>Using:</p><pre>completionMode: Indexed</pre><p>Kubernetes creates Pods with indices:</p><pre>pod-0<br>pod-1<br>pod-2<br>...</pre><p>This is ideal for:</p><ul><li>sharded processing</li><li>chunked batch jobs</li><li>per-record indexing</li><li>distributed processing</li></ul><p>Each Pod receives an environment variable:</p><pre>JOB_COMPLETION_INDEX=&lt;i&gt;</pre><p>Which allows deterministic shard mapping.</p><h3>How the Job Controller Creates Pods</h3><p>When the reconciliation loop runs:</p><h4>It calculates:</h4><ul><li>desiredPods = min(parallelism, completions — succeeded)</li></ul><h4>Then:</h4><ul><li>creates the required number of Pods</li><li>ensures Pods match labels/selector</li><li>sets ownerReferences to the Job</li><li>records Pod UIDs for tracking</li><li>pushes them to the API Server</li></ul><p>Then the Pods are scheduled normally using the default scheduler.</p><h3>Scheduler: Placing Job Pods onto Nodes</h3><p>Job Pods flow through the normal scheduling lifecycle:</p><ol><li>scheduler picks them up</li><li>filters eligible nodes</li><li>scores candidates</li><li>binds Pod to a node</li></ol><p>For large Jobs (hundreds or thousands of Pods), this process becomes heavy — and Kubernetes throttles Pod creation to avoid overload.</p><h3>kubelet: Running the Job Pods</h3><p>Once a Job Pod is assigned to a node, kubelet:</p><ul><li>pulls the image</li><li>mounts volumes</li><li>runs init containers</li><li>creates sandbox</li><li>starts main container</li><li>executes the Job command</li><li>monitors the Pod’s exit code</li></ul><p>A Pod is considered <strong>Succeeded</strong> only if:</p><ul><li>the main container exits with status 0</li></ul><p>A Pod is considered <strong>Failed</strong> if:</p><ul><li>container exits non-zero</li><li>it exceeds activeDeadlineSeconds</li><li>it is OOMKilled</li><li>node becomes unreachable (depending on TTL)</li><li>the job controller marks it failed after retries</li></ul><h3>Job Retry Logic: Backoff and Failure Handling</h3><p>Jobs have explicit retry behavior.</p><p>The controller tracks <strong>failed Pods</strong> and compares them to:</p><pre>backoffLimit (default: 6)</pre><p>If failures &gt; backoffLimit → Job is marked <strong>Failed</strong></p><p>Otherwise → new Pod is created to retry the work.</p><p>Retry behavior is exponential:</p><ul><li>10s</li><li>20s</li><li>40s</li></ul><p>This prevents clusters from being flooded with retries during outages.</p><h3>Tracking Completions</h3><p>The controller continuously updates:</p><pre>status.active<br>status.succeeded<br>status.failed<br>status.conditions</pre><p>This allows you to monitor Job progress:</p><pre>kubectl describe job &lt;job&gt;<br>kubectl get jobs</pre><h3>Cleanup Behavior (TTL Controller)</h3><p>If configured:</p><pre>ttlSecondsAfterFinished: 3600</pre><p>A separate TTL controller deletes:</p><ul><li>Completed Jobs</li><li>Their Pods</li><li>Their ephemeral resources</li></ul><p>If TTL is not set, Jobs remain forever until deleted manually.</p><h3>Node Failures and Job Resilience</h3><p>If a node dies while running a Job Pod:</p><p><strong>With </strong>restartPolicy: Never</p><ul><li>Pod is marked Failed</li><li>controller retries (if allowed)</li></ul><p><strong>With </strong>restartPolicy: OnFailure</p><ul><li>kubelet retries locally</li><li>if node is lost, new Pod is created on another node</li></ul><p>Jobs are designed for resilience across node churn.</p><h3>Job Controller Internals: How It Reconciles</h3><p>Every reconcile loop checks:</p><ul><li>active Pod count</li><li>successful Pod count</li><li>failed Pods</li><li>backoff state</li><li>parallelism limit</li><li>completions achieved</li></ul><p>If a Pod completes:</p><ul><li>count increases</li><li>new Pods may be created</li><li>status conditions updated</li></ul><p>If all completions achieved:</p><pre>Job marked: Succeeded</pre><p>If failures exceed backoffLimit:</p><pre>Job marked: Failed</pre><h3>Indexed Mode Deep Insight</h3><p>Indexed Jobs enable deterministic processing.<br> Each Pod:</p><ul><li>gets a unique index</li><li>may process a specific data partition</li><li>must succeed for Job to finish</li></ul><p>If Pod-7 fails →<br>Job re-creates a Pod with the same index until it succeeds or backoffLimit reached.</p><p>This is extremely valuable for parallel workloads like:</p><ul><li>distributed ETL</li><li>ML training shards</li><li>video transcoding</li><li>Big Data partitioned workloads</li></ul><h3>Completions Mode: Non-Indexed</h3><p>Non-indexed Jobs treat completions as identical work units.</p><p>Each Pod success increments “succeeded” count — Pod identity does not matter.</p><p>This is ideal for:</p><ul><li>independent computations</li><li>embarrassingly parallel tasks</li><li>generic batch systems</li></ul><h3>Flow Diagram</h3><pre>kubectl apply<br>     |<br>     v<br>API Server<br>(Auth → RBAC → Admission → Validation)<br>     |<br>     v<br>etcd (job stored)<br>     |<br>     v<br>Job Controller<br>     |<br>     +-- create Pods<br>             |<br>             v<br>         Scheduler<br>             |<br>             v<br>         kubelet runs Pods<br>             |<br>             v<br>         Pod completes?<br>          /          \<br>         Yes          No<br>         |             |<br>   increment count   retry logic<br>         |<br>         v<br>   all completions met?<br>          |<br>          v<br>      Job Succeeded</pre><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ATJ2inunN_-ToIhubCRRQ.png" /><figcaption>Kubernetes Jobs Overview</figcaption></figure><h3>When Should You Use a Job?</h3><p><strong>Perfect for:</strong></p><ul><li>data processing</li><li>ETL pipelines</li><li>ML inference</li><li>backups / exports</li><li>install scripts</li><li>one-off migrations</li><li>report generation</li></ul><p><strong>Not for:</strong></p><ul><li>long-running apps</li><li>services needing stable endpoints</li><li>scheduled tasks (CronJob)</li><li>clusters needing replica scaling (Deployment)</li><li>workloads needing identity (StatefulSet)</li></ul><h3>Kubernetes Workload Comparison Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UFFfC1umHMsxVJ2xuvFfdA.png" /><figcaption>Kubernetes Workload Comparison Table</figcaption></figure><h3>Real-Life Example: When You Would Create a Job</h3><p>Jobs are designed for workloads that <strong>must run to completion</strong> — tasks that start, do work, finish, and exit. Unlike Deployments or Pods, Jobs ensure the task actually completes, even if Pods fail, restart, or nodes crash.</p><p>Here’s a real, practical example of when you would create a Job in production.</p><h4>Example: Running a Database Migration Script During a Release</h4><p>Imagine your engineering team is deploying a new version of an application that requires database schema changes:</p><ul><li>adding new tables</li><li>altering columns</li><li>migrating data</li><li>creating indexes</li></ul><p>These operations must run <strong>exactly once</strong>, must <strong>complete successfully</strong>, and should <strong>not run again</strong> unless triggered manually.</p><p>A Deployment or Pod is not suitable here — you need guaranteed completion with retries.</p><p>A Job is the correct choice:</p><pre>apiVersion: batch/v1<br>kind: Job<br>metadata:<br>  name: db-migration<br>spec:<br>  backoffLimit: 4        # retry up to 4 times if it fails<br>  template:<br>    spec:<br>      restartPolicy: OnFailure<br>      containers:<br>      - name: migrate<br>        image: myorg/migrate:v1<br>        command: [&quot;sh&quot;, &quot;-c&quot;, &quot;python migrate.py&quot;]</pre><h4>Why a Job?</h4><p>Because a migration must:</p><h4>1. Run Exactly Once (Not Forever)</h4><p>Jobs run until the task finishes successfully, then stop permanently.</p><h4>2. Retry Automatically if Something Fails</h4><p>If the network hiccups or DB connection fails, Kubernetes will retry until the backoffLimit is hit.</p><h4>3. Not Restart After Success</h4><p>Once complete, the Job will <em>never</em> run again unless re-created.</p><h4>4. Recover From Node Failures</h4><p>If the node running the migration dies, Kubernetes recreates the Pod on another node and continues the task.</p><h4>5. Provide a Clear Success/Fail State</h4><p>Teams can verify:</p><pre>kubectl get jobs<br>kubectl logs job/db-migration</pre><p>Deployments and Pods cannot guarantee any of this.</p><h3>Conclusion</h3><p>Creating a Job initiates a sophisticated lifecycle:</p><ul><li>kubectl sends the manifest</li><li>API Server authenticates, validates, and stores it</li><li>Job controller activates</li><li>Pods are created according to parallelism</li><li>scheduler places Pods</li><li>kubelet runs the Pods</li><li>controller tracks completions</li><li>retries occur on failure</li><li>Job succeeds or fails based on limits</li><li>cleanup happens via TTL (optional)</li></ul><p>Jobs are Kubernete’s answer to <strong>batch processing, run-to-completion workloads</strong>, and distributed parallel execution. They provide reliability, retries, ordering logic, and failure tolerance built directly into the control plane.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2257fa53381d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Create a Deployment in Kubernetes — A Deep, Internal-Level Breakdown]]></title>
            <link>https://tanmaybatham.medium.com/what-happens-when-you-create-a-deployment-in-kubernetes-a-deep-internal-level-breakdown-f6bf37bdcdd0?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6bf37bdcdd0</guid>
            <category><![CDATA[etcd]]></category>
            <category><![CDATA[kubernetes-deployment]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[k8s]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 11:21:02 GMT</pubDate>
            <atom:updated>2025-12-03T06:07:34.695Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happens When You Create a Deployment in Kubernetes — A Deep, Internal-Level Breakdown</h3><p>Kubernetes Series — K002</p><p>Kubernetes Deployments are among the most commonly used objects in modern cloud-native environments, but very few engineers truly understand the internal mechanics behind the scenes. You apply a YAML, Kubernetes magically launches Pods, and your application comes online — but what exactly happened underneath the hood?</p><p>This article breaks down every single subsystem involved when you create a Deployment, from the moment the request leaves your terminal to the moment Pods are running on nodes. We’ll go layer by layer — API Server, etcd, Controllers, Scheduler, Kubelet, CNI — and reveal the full orchestration machinery that makes Kubernetes so powerful.</p><h3>1. When You Create a Deployment (kubectl apply)</h3><p>Everything starts with:</p><pre>kubectl apply -f deployment.yaml</pre><p>But kubectl does a <em>lot</em> more than people realize:</p><h4>kubectl internal flow</h4><pre>+-------------------------------+<br>| Load kubeconfig               |<br>| Select context                |<br>| Resolve API endpoint          |<br>| Load TLS certificates         |<br>| Prepare credentials           |<br>+-------------------------------+<br>              |<br>              v<br>+-------------------------------+<br>| Convert YAML → JSON           |<br>| Construct REST request        |<br>+-------------------------------+<br>              |<br>              v<br>           API Server</pre><p>kubectl isn’t just a CLI — it’s a Kubernetes API client with full logic for:</p><ul><li>Authentication plugins</li><li>Client-side diff</li><li>Strategic merging</li><li>Conflict detection</li><li>SSL negotiation</li><li>Resource discovery</li></ul><h3>2. API Server: The Security Gatehouse</h3><p>Once the request arrives, the API server processes it through three strict stages:</p><pre>kubectl → [Auth] → [AuthZ] → [Admission] → etcd</pre><h4>2.1 Authentication</h4><p>API Server validates identity via:</p><ul><li>Client certs</li><li>OIDC tokens</li><li>Exec credential providers</li><li>ServiceAccount tokens</li><li>TokenReview webhooks</li></ul><p>Fail here → <strong>401 Unauthorized</strong></p><h4>2.2 Authorization (RBAC/ABAC/Node)</h4><p>The server checks:</p><pre>Can this identity CREATE deployments?</pre><p>Fail → <strong>403 Forbidden</strong></p><h4>2.3 Admission Controllers</h4><p>This is where YAML gets transformed and validated.</p><p><strong>Mutating Admission Webhooks<br></strong>Inject defaults:</p><ul><li>resource limits</li><li>security context</li><li>sidecars (Istio, Linkerd)</li><li>PSa changes</li></ul><p><strong>Validating Admission Webhooks</strong><br>Reject if unsafe:</p><ul><li>OPA Gatekeeper constraints</li><li>Kyverno rules</li><li>Image signing requirements</li></ul><p>Then, schema validation happens.</p><p>If successful → Deployment object is accepted into the cluster.</p><h3>3. etcd: The Source of Truth</h3><p>Kubernetes stores the <em>desired state</em> in etcd:</p><pre>/registry/deployments/&lt;namespace&gt;/&lt;name&gt;</pre><p>At this moment:</p><p>Deployment exists<br>No ReplicaSets<br>No Pods</p><p>This is the Kubernetes model:</p><blockquote>“Store desired state → constantly try to make reality match it.”</blockquote><h3>4. Deployment Controller: The Brain of Deployment Logic</h3><p>The <strong>Deployment Controller</strong> (running inside the kube-controller-manager) notices the new Deployment:</p><pre>Deployment created → Controller sees event → Begins reconciliation</pre><h4>4.1 What the Deployment Controller Checks</h4><ul><li>Does a ReplicaSet exist for this spec?</li><li>Does a PodTemplateHash exist?</li><li>How many replicas are desired?</li></ul><h4>4.2 The ReplicaSet Is Created</h4><p>The controller generates:</p><pre>ReplicaSet name = &lt;deployment-name&gt;-&lt;hash&gt;</pre><p>Example:</p><pre>web-frontend-68755c6bb5</pre><p>Why the hash?<br>It represents the <strong>Pod template version</strong>, allowing rolling updates.</p><p>ASCII depiction:</p><pre>Deployment<br>  |<br>  +--&gt; ReplicaSet (v1 hash)<br>         |<br>         +--&gt; Pods</pre><h3>5. ReplicaSet Controller: The Pod Factory</h3><p>The ReplicaSet controller now takes over:</p><pre>desiredReplicas = 3<br>currentReplicas = 0</pre><p>It begins creating Pods one at a time.</p><h4>ReplicaSet → Pods flow</h4><pre>ReplicaSet<br>   |<br>   +---&gt; Pod 1<br>   +---&gt; Pod 2<br>   +---&gt; Pod 3</pre><p>Each Pod gets:</p><ul><li>Metadata</li><li>Labels</li><li>OwnerReferences (so garbage collection works)</li><li>Template fields from Deployment</li></ul><h3>6. Pods Enter the Scheduling Queue</h3><p>Initially, Pods have:</p><pre>spec.nodeName: &quot;&quot;</pre><p>Meaning they are unscheduled.</p><p>They exist in etcd but are not running anywhere.</p><h3>7. Scheduler: Choosing the Right Node</h3><p>The scheduler continuously watches for Pods with no assigned node.</p><h4>7.1 Filtering Stage</h4><p>Remove nodes that cannot host the Pod:</p><ul><li>Insufficient resources</li><li>Taints not tolerated</li><li>Node affinity mismatch</li><li>Pod anti-affinity violation</li><li>Storage topology constraints</li></ul><h4>7.2 Scoring Stage</h4><p>Score each eligible node:</p><ul><li>Least allocated resources</li><li>Image locality</li><li>Spread constraints</li><li>Custom scheduler plugins</li></ul><h4>7.3 Binding</h4><p>Scheduler updates the Pod:</p><pre>spec.nodeName = &quot;worker-node-3&quot;</pre><p>Stored back into etcd.</p><p>Now kubelet takes over.</p><h3>8. Kubelet: The Actual Executor</h3><p>Each node runs a kubelet which watches:</p><pre>Pods where spec.nodeName == &lt;this-node&gt;</pre><p>When kubelet sees the Pod assigned to it, it begins execution.</p><h4>Kubelet responsibilities</h4><ul><li>Prepare volumes</li><li>Pull container images</li><li>Apply secrets &amp; configmaps</li><li>Create Pod sandbox (via CRI)</li><li>Apply security settings</li><li>Start containers</li><li>Run probes</li><li>Report Pod status back to API</li></ul><h3>9. Pod Sandbox + CNI Networking</h3><p>Before any container starts, kubelet asks the runtime to create a <strong>Pod sandbox</strong>:</p><pre>pause container → namespaces → cgroups → network</pre><p>Then:</p><h4>CNI plugin runs (Calico, Cilium, Weave, Flannel)</h4><ul><li>Allocate IP</li><li>Create veth pairs</li><li>Attach Pod to node network</li><li>Apply network policies</li><li>Configure routing</li></ul><p>ASCII depiction:</p><pre>[Pod Sandbox]<br>     |<br>     +-- veth0 --- CNI Bridge --- Node Interface --- Cluster network</pre><p>If CNI fails, Pod becomes stuck in:</p><pre>ContainerCreating</pre><h3>10. CSI Storage Setup</h3><p>If Deployment uses PVCs:</p><ul><li>CSI driver provisions volume</li><li>Attaches to node</li><li>Mounts file system</li><li>Binds into sandbox</li></ul><h3>11. Containers Start</h3><p>Kubelet now instructs CRI to start containers:</p><ol><li>Pull images</li><li>Create root FS</li><li>Apply resource limits</li><li>Apply security context</li><li>Execute entrypoint</li></ol><p>Container state transitions:</p><pre>Created → Starting → Running</pre><p>Once all containers run successfully, kubelet updates:</p><pre>status.phase = Running</pre><h3>12. Deployment Reaches Steady State</h3><p>The Deployment controller monitors progress:</p><pre>updatedReplicas: 3  <br>readyReplicas: 3  <br>availableReplicas: 3</pre><p>When actual state == desired state:</p><blockquote>The rollout is complete.</blockquote><h3>13. Scaling &amp; Autoscaling Behavior</h3><p>Scaling a Deployment changes:</p><pre>spec.replicas: 3 → 10</pre><p>Deployment controller updates RS<br> ↓<br> RS controller creates additional Pods<br> ↓<br> Scheduler assigns them<br> ↓<br> Kubelet runs containers</p><p>HPA works by modifying Deployment’s .spec.replicas.</p><h3>14. Rolling Updates Internals</h3><p>Rolling update = creating a new ReplicaSet.</p><p>Flow:</p><pre>Old RS (v1)        New RS (v2)<br>   |                   |<br>3 replicas        0 replicas</pre><p>Deployment controller performs:</p><pre>Step 1: Scale v2 RS up (1,2,3…)<br>Step 2: Scale v1 RS down (3,2,1…)<br>Step 3: Continue until:<br>        v1 = 0<br>        v2 = desired replicas</pre><p>During rolling updates you see:</p><pre>web-deploy<br> ├─ RS v1 → 3 → 2 → 1 → 0<br> └─ RS v2 → 0 → 1 → 2 → 3</pre><h3>15. Rollbacks: How Kubernetes Restores Previous Versions</h3><p>Every ReplicaSet created carries <strong>annotations</strong> with:</p><ul><li>rollout revision</li><li>Pod template hash</li><li>deployment.kubernetes.io/revision</li></ul><p>Rollback flow:</p><pre>kubectl rollout undo deployment/web</pre><p>Deployment controller identifies previous RS<br> ↓<br> Scales previous RS up<br> ↓<br> Scales current RS down</p><p>Rollback completes.</p><h3>16. Flowcharts &amp; Illustrations</h3><h4>16.1 High-Level Deployment Lifecycle</h4><pre>kubectl apply<br>     |<br>     v<br> API Server<br>     |<br>     v<br>   etcd  &lt;--- watches ---- Deployment Controller<br>     |                        |<br>     |                        v<br>     |                    ReplicaSet<br>     |                        |<br>     |                        v<br>     |                      Pods  ---&gt; Scheduler ---&gt; Nodes<br>     |                                            (kubelet → runtime)</pre><h4>16.2 Pod Scheduling Detailed Flow</h4><pre>Unscheduled Pod<br>       |<br>       v<br>+--------------------------+<br>|       Scheduler          |<br>+--------------------------+<br> Filter nodes<br> Score nodes<br> Pick best node<br> Bind Pod to node<br>       |<br>       v<br> Node Kubelet<br>       |<br>       v<br> Pod Sandbox → CNI → CSI → Containers</pre><h4>16.3 Rolling Update Flow</h4><pre>Deployment<br>   |<br>   +-- RS (old) -- scaling down<br>   |<br>   +-- RS (new) -- scaling up</pre><h4>16.4 Detailed Flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I6AV6w2jsrBR1D5MkQLQgw.png" /><figcaption>Kubernetes Deployment Scheduling</figcaption></figure><h4>16.5 Kubelet Flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rnKkTr2w-fPu041EFCOdA.png" /><figcaption>Kubelet Flow</figcaption></figure><h4>16.5 Rolling Update Flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWJos5H-s_YedFNP1ODe0w.png" /><figcaption>Deployment Controller</figcaption></figure><h3>Kubernetes Workload Comparison Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UFFfC1umHMsxVJ2xuvFfdA.png" /><figcaption>Kubernetes Workload Comparison Table</figcaption></figure><h3>Real-Life Example: When You Would Create a Deployment</h3><p>Deployments are the backbone of almost every production application in Kubernetes.<br>Whenever you need an application to stay online, scale horizontally, survive failures, and support safe version rollouts, a Deployment is the controller you choose.</p><p>Here’s a <strong>real, practical, production-grade example</strong> of when you <em>must</em> use a Deployment.</p><h4>Example: Running a Customer-Facing Web/API Service That Must Never Go Down</h4><p>Imagine you’re running a backend API or frontend web application used by real customers. This service must:</p><ul><li>be running <strong>24/7</strong>,</li><li>recover instantly when a Pod crashes,</li><li>handle traffic spikes by <strong>scaling replicas</strong>,</li><li>update safely without downtime, and</li><li>roll back instantly if a release goes wrong.</li></ul><p>A standalone Pod cannot provide any of these guarantees — but a Deployment can.</p><p>Here’s a typical Deployment you’d use for such an application:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: auth-service<br>spec:<br>  replicas: 5<br>  selector:<br>    matchLabels:<br>      app: auth-service<br>  template:<br>    metadata:<br>      labels:<br>        app: auth-service<br>    spec:<br>      containers:<br>      - name: auth<br>        image: myorg/auth-service:v2<br>        ports:<br>        - containerPort: 8080<br>        readinessProbe:<br>          httpGet:<br>            path: /healthz<br>            port: 8080<br>        livenessProbe:<br>          httpGet:<br>            path: /live<br>            port: 8080</pre><h4>Why a Deployment?</h4><p>Because this is a <strong>mission-critical service</strong>, and it needs everything a Deployment provides:</p><h4>1. Automatic Self-Healing</h4><p>If one replica dies at 2 AM, the Deployment instantly replaces it.<br>A standalone Pod would stay dead — and your customers would see failures.</p><h4>2. Horizontal Scaling</h4><p>Traffic spikes?<br>Scale to 10, 20, or 100 replicas without redesigning anything.</p><pre>kubectl scale deployment auth-service --replicas=10</pre><h4>3. Zero-Downtime Rolling Updates</h4><p>Push a new version without ever taking the service offline.</p><pre>kubectl set image deployment auth-service auth=myorg/auth-service:v3</pre><p>Kubernetes gradually replaces Pods only when newer ones are “Ready.”</p><h4>4. Instant Rollbacks</h4><p>If a release goes wrong:</p><pre>kubectl rollout undo deployment auth-service</pre><p>The app instantly returns to a stable version.</p><h4>5. Integration With Autoscaling</h4><p>HPA (HorizontalPodAutoscaler) works only with controllers like Deployments.</p><p>Scaling based on CPU, memory, or custom metrics:</p><pre>minReplicas: 3<br>maxReplicas: 15</pre><h4>6. Load-Balanced Traffic With a Service</h4><p>Deployments work seamlessly with ClusterIP / NodePort / LB Services for smooth traffic distribution.</p><h3>Conclusion</h3><p>A Deployment triggers a cascade of 10+ subsystems working together:</p><ol><li>kubectl sends request</li><li>API Server authenticates &amp; validates</li><li>Deployment saved in etcd</li><li>Deployment controller creates ReplicaSet</li><li>ReplicaSet creates Pods</li><li>Scheduler assigns nodes</li><li>Kubelet prepares environment</li><li>CNI sets up networking</li><li>CSI mounts storage</li><li>Containers start</li><li>Probes run</li><li>Deployment reaches steady state</li><li>Rollouts &amp; rollbacks happen automatically</li></ol><p>Kubernetes is not a black box — it’s a series of predictable, observable, reconciling loops that enforce desired state with mathematical precision.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6bf37bdcdd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Happens When You Create a Pod in Kubernetes — A Deep, Internal-Level Breakdown]]></title>
            <link>https://tanmaybatham.medium.com/what-happens-when-you-create-a-pod-in-kubernetes-a-deep-internal-level-breakdown-08ad256ee673?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/08ad256ee673</guid>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[kubernetes-control-plane]]></category>
            <category><![CDATA[kubernetes-pods]]></category>
            <category><![CDATA[kubernetes-scheduling]]></category>
            <category><![CDATA[etcd]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 09:38:53 GMT</pubDate>
            <atom:updated>2025-12-03T06:00:49.827Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Happens When You Create a Pod in Kubernetes — A Deep, Internal-Level Breakdown</h3><p>Kubernetes Series — K001</p><p>Most blogs explain Pod creation at a surface level:<br>kubectl → API Server → Scheduler → Kubelet → container runtime.</p><p>But Kubernetes is far more complex, layered, and elegant than that.</p><p>A Pod creation event triggers <strong>over 20+ internal subsystems</strong>, hundreds of micro-interactions, API calls, watchers, informers, cache updates, checkpoint writes, CNI operations, volume provisioning, runtime sandboxing, and continuous reconciliation.</p><p>This is the version that goes deeper than the docs — the internals that matter when:</p><ul><li>Pods refuse to schedule</li><li>Pods hang in ContainerCreating</li><li>A node keeps flapping</li><li>Services don’t forward traffic</li><li>Volumes remain stuck in “Attached” state</li><li>DNS fails</li><li>Pods resurrect after deletion</li><li>Or your entire cluster behaves strangely</li></ul><p>If you’re a DevOps/SRE working with real production clusters, you want to understand this ecosystem at a <strong>micro-behavior</strong> level.</p><p>Let’s dive in.</p><h3>1. kubectl: The Very Beginning (Client-Side Internals)</h3><p>When you run:</p><pre>kubectl apply -f pod.yaml</pre><p>kubectl performs <strong>8 steps</strong>, not just one.</p><h4>1.1. kubeconfig Parsing</h4><p>kubectl loads:</p><ul><li>client certs</li><li>cluster CA</li><li>default namespace</li><li>context</li><li>exec plugins (AWS/GCP auth)</li><li>custom auth providers</li></ul><p>Under the hood, kubectl uses:</p><ul><li>client-go</li><li>rest.Config</li><li>Transport with caching of TLS sessions</li></ul><h4>1.2. Discovery API</h4><p>kubectl checks the API Server’s available API versions via:</p><pre>/apis<br>/api<br>/openapi/v2<br>/openapi/v3</pre><p>It caches these for 10 minutes.</p><p>This is why a new CRD sometimes causes kubectl to say:</p><blockquote>“no matches for kind X in version Y”</blockquote><h4>1.3. OpenAPI schema lookup</h4><p>kubectl validates your YAML locally using OpenAPI schema.</p><h4>1.4. Three-Way Strategic Merge Patch creation</h4><p>For apply/patch operations, kubectl creates:</p><ul><li>last-applied state</li><li>live state</li><li>new desired state</li></ul><p>And performs a strategic merge.</p><h4>1.5. Request construction</h4><p>The YAML is marshaled to JSON.</p><p>kubectl adds:</p><ul><li>content-type headers</li><li>certificate-based authentication</li><li>impersonation headers (if used)</li><li>audit annotations</li></ul><h4>1.6. Client-side rate limiting</h4><p>kubectl uses a token bucket limiter to avoid hammering the API Server.</p><h4>1.7. HTTPS connection pooling</h4><p>It reuses TCP/TLS sessions (for multi-object apply).</p><h4>1.8. Sending Request</h4><p>The final HTTP request lands at the Kubernetes API Server.</p><p>The <strong>real show begins here</strong>.</p><h3>2. Kubernetes API Server — The Control Plane Entry Point</h3><p>The API Server is not a single program — it is a <em>collection of sub-components wrapped in a binary</em>.</p><p>When your request arrives:</p><h4>2.1. Request Handling Pipeline</h4><p>The request flows through these layers:</p><ol><li><strong>Authentication Filter</strong></li><li><strong>Authorization Filter</strong></li><li><strong>Mutating Admission Chain</strong></li><li><strong>Validation (Schema &amp; Custom)</strong></li><li><strong>Validating Admission Chain</strong></li><li><strong>Storage Serializer</strong></li><li><strong>etcd Write Path</strong></li></ol><p>Each stage is pluggable.</p><h4>2.2. Authentication Details</h4><p>Supported auth mechanisms:</p><ul><li>TLS client cert</li><li>ServiceAccount tokens (JWT)</li><li>OIDC tokens</li><li>Static tokens</li><li>Webhook authenticators</li></ul><p>API Server extracts user identity → assigns a <strong>UserInfo object</strong>.</p><p>If anything fails, request ends here.</p><h4>2.3. Authorization (RBAC/ABAC/Webhook)</h4><p>API Server checks:</p><ul><li>verbs (create/update/list)</li><li>API groups</li><li>resource names</li><li>namespace permissions</li></ul><p>The RBAC engine evaluates thousands of rules using a fast LRU-optimized rule lookup.</p><h4>2.4. Mutating Admission Webhooks</h4><p>Here, the Pod may be modified by:</p><ul><li>Sidecar injector (Istio, Linkerd)</li><li>Resource defaults injector</li><li>Image policy mutators</li><li>Security context injectors</li><li>Custom organizational policies</li></ul><p>Mutating webhooks can:</p><ul><li>Add containers</li><li>Add init containers</li><li>Change environment variables</li><li>Add pod labels</li><li>Modify security context</li></ul><p>Your submitted Pod is rarely the final Pod.</p><h4>2.5. OpenAPI and Structural Schema Validation</h4><p>Kubernetes uses:</p><ul><li>JSON schema</li><li>CRD structural schemas</li><li>API field validation logic</li></ul><p>Validation errors → request fails.</p><h4>2.6. Validating Admission Webhooks</h4><p>Enforces:</p><ul><li>Pod Security Standards</li><li>OPA Gatekeeper</li><li>Kyverno</li><li>Custom governance rules</li></ul><p>If any admission fails → request rejected.</p><h3>3. etcd — The Heart of Kubernetes State</h3><p>API Server serializes the <em>final</em> Pod object into Protobuf and writes to etcd.</p><h4>Why Protobuf?</h4><p>80% smaller than JSON, much faster serialization.</p><h4>3.1. etcd Write Path Internals</h4><p>The write path includes:</p><ul><li>revision increment</li><li>MVCC logic</li><li>WAL journal write</li><li>Snapshot delta</li><li>Storage compaction tracking</li></ul><p>Every change to any resource increments the global etcd revision.</p><p>This is what powers the entire watch API.</p><h4>3.2. At this point: The Pod “exists”</h4><p>But nothing is running.</p><p>It’s just an object in etcd.</p><h3>4. Watchers, Informers &amp; Controllers — The Kubernetes Nervous System</h3><p>From this moment onward, dozens of controllers react.</p><h4>Components watching for Pod changes:</h4><ul><li>Scheduler</li><li>Kube-Controller-Manager</li><li>Node controllers</li><li>ServiceAccount controllers</li><li>EndpointSlice controllers</li><li>PV/PVC controllers</li><li>Cluster autoscaler</li><li>Any custom controllers</li></ul><p>Kubernetes loosely couples everything through the <strong>Watcher pattern + sharedInformerFactory caches</strong>.</p><p>This makes the system eventually consistent but highly resilient.</p><h3>5. Scheduler — How Kubernetes Actually Picks a Node</h3><p>When the Scheduler sees a Pod with:</p><pre>spec.nodeName: &quot;&quot;</pre><p>it begins scheduling.</p><p>This is where the real “intelligence” lives.</p><h4>5.1. Scheduler Internal Architecture</h4><p>The scheduler consists of:</p><ul><li><strong>Cache</strong> (node resources, Pod requests, volume info)</li><li><strong>Scheduling Queue</strong></li><li><strong>Scheduling Framework Plugins</strong></li><li><strong>PreFilter plugins</strong></li><li><strong>Filter plugins</strong></li><li><strong>Score plugins</strong></li><li><strong>Reserve plugin</strong></li><li><strong>Bind plugin</strong></li><li><strong>PostBind hooks</strong></li></ul><p>Yes, the scheduler is plugin-driven — almost everything is modular.</p><h4>5.2. Scheduling Cycle</h4><h4>Step 1: Pre-Filter</h4><p>Checks:</p><ul><li>Pod resource requests</li><li>Pod topology constraints</li><li>Volume claims</li><li>Node affinity rules</li></ul><h4>Step 2: Filter Phase</h4><p>Eliminates nodes that fail:</p><ul><li>memory/cpu checks</li><li>taints/tolerations</li><li>node selectors</li><li>Pod affinity/anti-affinity</li><li>custom policy plugins</li><li>resource quotas</li></ul><p>Filtering often eliminates 90–95% of nodes.</p><h4>5.3. Scoring Phase</h4><p>Remaining nodes are scored using a weighted plugin system:</p><ul><li><strong>LeastAllocated</strong> (spread load)</li><li><strong>BalancedAllocation</strong></li><li><strong>PodTopologySpread</strong></li><li><strong>ImageLocality</strong></li><li><strong>NodeResourceFit</strong></li><li><strong>InterPodAffinity</strong></li></ul><p>Each plugin returns a score from 0–100.</p><p>Scores are aggregated and the highest score wins.</p><h4>5.4. Reserve &amp; PreBind</h4><p>Scheduler performs pre-bind checks:</p><ul><li>volume topology compatibility</li><li>scheduling gates</li><li>Pod disruption budgets</li></ul><h4>5.5. Binding</h4><p>Finally, the scheduler sends:</p><pre>PATCH /api/v1/namespaces/default/pods/&lt;pod&gt;/binding</pre><p>to API Server.</p><p>Result:</p><pre>spec:<br>  nodeName: &lt;chosenNode&gt;</pre><p>Stored in etcd.</p><p><strong>The Pod is officially assigned but not running.</strong></p><h3>6. Kubelet — The Node Agent Takes Over</h3><p>Every node runs kubelet which syncs desired → actual state.</p><p>Kubelet sees:</p><blockquote>“A new Pod assigned to me.”</blockquote><p>Then it enters the <strong>Pod lifecycle state machine</strong>.</p><h4>6.1. Kubelet Pod Admission Checks</h4><p>Before even creating containers, kubelet validates:</p><ul><li>node memory pressure</li><li>disk pressure</li><li>PID cgroup allocations</li><li>eviction thresholds</li><li>Pod security context</li><li>AppArmor profiles</li><li>Seccomp profiles</li><li>SELinux context</li><li>CPU manager policies</li><li>Topology manager constraints</li></ul><p>If any admission fails → Pod rejected on that node.</p><h3>7. Pod Sandbox — One of the Least Understood Parts</h3><p>Before containers start, kubelet requests CRI to create a <strong>PodSandbox</strong>.</p><p>This sandbox sets up:</p><ul><li>Pod network namespace</li><li>Pod IP</li><li>Loopback interface</li><li>Cgroup hierarchy</li><li>Init process (pause container)</li><li>Shared namespaces (IPC, UTS)</li></ul><p>The pause container (“infra container”) becomes PID 1 inside the Pod.</p><p>Your containers share:</p><ul><li>network namespace</li><li>PID namespace (optional)</li><li>IPC namespace</li></ul><h3>8. CNI Networking — Deep Internals</h3><p>When the Pod sandbox is created, the container runtime calls:</p><pre>/opt/cni/bin/&lt;plugin&gt; ADD</pre><p>with a JSON payload describing:</p><ul><li>interface</li><li>sandbox PID</li><li>namespace path</li><li>desired network config</li></ul><p>CNI plugin does:</p><ul><li>generate Pod IP</li><li>create veth pair</li><li>attach veth to CNI bridge</li><li>update iptables or eBPF maps</li><li>enforce network policies</li><li>add routes</li></ul><p>If <em>any</em> network component is unhealthy:</p><ul><li>Pod stuck in <em>ContainerCreating</em></li><li>DNS resolution fails</li><li>Cross-node traffic breaks</li><li>Services break</li></ul><h3>9. CSI — Storage Attachment &amp; Mounting</h3><p>If the Pod has volumes:</p><ul><li>CSI controller provisions/attaches volume</li><li>CSI node driver mounts to node</li><li>kubelet bind-mounts into Pod sandbox</li><li>filesystem permissions applied</li></ul><p>Volume mount failures cause:</p><ul><li>Init container hangs</li><li>Long mount timeouts</li><li>Pod stuck in <em>Pending</em></li></ul><h3>10. Container Runtime — The Actual Container Creation</h3><p>Runtime (containerd, CRI-O) pulls images using:</p><ul><li>registries</li><li>secrets</li><li>retry/backoff logic</li><li>caching</li><li>layer deduplication</li></ul><p>Then:</p><ul><li>Creates rootfs</li><li>Applies Linux namespaces</li><li>Applies cgroups</li><li>Sets capabilities</li><li>Injects environment variables</li><li>Starts entrypoint</li></ul><p>If runtime fails → Pod enters CrashLoopBackOff or ImagePullBackOff.</p><h3>11. Pod Status Updates &amp; API Server Sync</h3><p>kubelet continuously sends Pod status:</p><ul><li>container running</li><li>container terminated</li><li>readiness probe results</li><li>restart counts</li><li>IP addresses</li></ul><p>This status is written to etcd.</p><p><strong>The Pod’s “Status” object is always live-updated.</strong></p><h3>12. Probes — Kubernetes Health Management in Depth</h3><p>Kubelet runs:</p><ul><li>readiness probes</li><li>liveness probes</li><li>startup probes</li></ul><p>Each probe:</p><ul><li>runs in its own goroutine</li><li>has timeout/period semantics</li><li>affects service endpoints</li><li>triggers restarts</li></ul><h3>13. kube-proxy &amp; EndpointSlice Propagation</h3><p>Once a Pod is Ready:</p><ul><li>EndpointSlice updated</li><li>kube-proxy updates iptables/eBPF rules</li><li>Service routing updated</li></ul><p>This is why a Pod isn’t immediately reachable after starting — propagation takes a few hundred milliseconds.</p><h3>14. Garbage Collection, Reconciliation &amp; Constant State Correction</h3><p>Kubernetes is ALWAYS reconciling.<br> Controllers constantly try to correct divergence between:</p><p><strong>Desired state (etcd)</strong><br> vs.<br><strong>Actual state (node runtime)</strong></p><p>This includes:</p><ul><li>container GC</li><li>image GC</li><li>orphaned volume cleanup</li><li>node heartbeat checks</li><li>Pod re-sync</li><li>eviction manager actions</li></ul><p>Kubernetes is eventually consistent — not instantly consistent.</p><h3>15. What Happens When You Delete a Pod</h3><p>Deletion triggers:</p><ol><li>Finalizers checked</li><li>Grace period countdown</li><li>SIGTERM sent</li><li>If still running → SIGKILL</li><li>CNI teardown</li><li>CSI unmounts volumes</li><li>runtime removes containers</li><li>Pod object removed from etcd</li><li>Controllers reconcile freed resources</li></ol><h3>16. The Entire Chain Revisited</h3><p>From YAML → Running Pod:</p><ol><li>kubectl builds request</li><li>API Server authenticates/authorizes</li><li>Webhooks mutate/validate</li><li>etcd stores the Pod</li><li>Scheduler assigns a node</li><li>Kubelet sees assignment</li><li>Pod sandbox created</li><li>CNI assigns IP</li><li>CSI mounts volumes</li><li>Containers created + started</li><li>Probes begin</li><li>kube-proxy routes traffic</li><li>Monitoring/logging integrate</li><li>Pod reconciled continuously</li><li>Pod deleted gracefully</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4syNd3p-7lgq2X4tCp6pw.png" /><figcaption>Pod Lifecycle</figcaption></figure><h3>Kubernetes Workload Comparison Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UFFfC1umHMsxVJ2xuvFfdA.png" /><figcaption>Kubernetes Workload Comparison Table</figcaption></figure><h3>Real-Life Example: When You Would Create a Pod</h3><p>While rare, there <em>are</em> valid production scenarios where you intentionally create a <strong>permanent standalone Pod</strong> that should always stay alive — but <strong>without a controller</strong> like Deployment or StatefulSet.</p><p>Here’s a real, practical example:</p><h4>Example: Running a Critical Node-Level Agent That Must Not Restart Automatically</h4><p>Imagine you have a <strong>hardware-dependent monitoring agent</strong> or <strong>one-off device driver</strong> that must run on a specific node and must <strong>not</strong> be auto-recreated on failure because:</p><ul><li>it binds to a hardware device (e.g., TV tuner, USB dongle, GPU tester)</li><li>it interacts with a legacy appliance</li><li>it should stop permanently if the underlying process fails</li><li>you want the failure to be visible rather than silently recreated</li></ul><p>In such cases, you intentionally create a <strong>permanent, single Pod</strong> pinned to a node:</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: node-monitor<br>spec:<br>  nodeName: node-05<br>  containers:<br>  - name: monitor<br>    image: custom/node-health-agent:latest<br>    volumeMounts:<br>    - mountPath: /host/dev<br>      name: dev<br>  volumes:<br>  - name: dev<br>    hostPath:<br>      path: /dev</pre><h3>Why a standalone Pod?</h3><p>Because:</p><ul><li>Deployments would auto-restart the container if it fails (undesirable).</li><li>StatefulSets create identity and ordering overhead (not needed).</li><li>DaemonSets would run on <em>every</em> node (not desired).</li><li>Jobs/CronJobs don’t run permanently.</li></ul><p>A single, pinned Pod is the cleanest solution.</p><h3>Conclusion</h3><p>Understanding Pod creation at this depth helps you debug:</p><ul><li>Pending Pods</li><li>kubelet issues</li><li>CNI failures</li><li>volume mount issues</li><li>node pressure conditions</li><li>container runtime failures</li><li>DNS problems</li><li>scheduling anomalies</li></ul><p>This turns Kubernetes from “a mysterious orchestrator” into a <strong>predictable system</strong> you can operate with confidence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08ad256ee673" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Air-Gapped Kubernetes & AI: Building Intelligent Systems in Disconnected Environments]]></title>
            <link>https://tanmaybatham.medium.com/air-gapped-kubernetes-ai-building-intelligent-systems-in-disconnected-environments-a0ecd8e03be1?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0ecd8e03be1</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[aiops]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 14:36:01 GMT</pubDate>
            <atom:updated>2025-11-28T14:36:01.042Z</atom:updated>
            <content:encoded><![CDATA[<p>There’s a quiet revolution happening in places the internet can’t reach.</p><p>Far away from the comfort of public clouds and GitHub Actions pipelines — inside defense labs, on oil rigs, in banks with unforgiving auditors, in data centers that run only on private fiber, and sometimes deep in basements where Wi-Fi is considered a security threat — Kubernetes is powering AI systems that are never allowed to touch the outside world.</p><p>These environments are <em>air-gapped</em>.</p><ul><li>No public images.</li><li>No curl to PyPI.</li><li>No docker pull from a random registry.</li><li>No telemetry sent to some SaaS dashboard.</li></ul><p>Just isolated clusters, sealed networks, and strict controls where anything that moves in — or out — must be approved, scanned, and logged.</p><p>And yet, organizations in these settings increasingly want the same things everybody else wants:</p><ul><li>Machine learning inference at the edge</li><li>On-prem LLM workloads</li><li>GPU scheduling and sharing</li><li>Scalable pipelines for computer vision</li><li>Automated drift detection</li><li>Secure MLOps workflows</li></ul><p>Delivering AI inside an air-gapped Kubernetes environment is absolutely possible — but it is a different sport altogether.</p><h4>Why Air-Gapped AI Is Such a Big Deal</h4><p>Before diving into Kubernetes, let’s talk about why AI behind air-gaps even matters.</p><p>Most industries still run workloads on-prem, not because they dislike the cloud, but because they’re required to keep things inside:</p><ul><li><strong>Defense &amp; National Security:</strong> models trained on classified data</li><li><strong>Healthcare:</strong> data residency and strict privacy controls</li><li><strong>Banking/FinTech:</strong> regulatory boundaries and internal compliance</li><li><strong>Industrial IoT / Manufacturing:</strong> offline or partially connected sites</li><li><strong>Energy &amp; Utilities:</strong> edge inference on remote or low-bandwidth locations</li><li><strong>Telecom:</strong> sovereign networks and private 5G/6G</li></ul><p>These groups need AI — vision systems, anomaly detection, digital twins, predictive maintenance, fraud detection, and increasingly internal LLMs — but cannot depend on cloud services.</p><p>So they turn to Kubernetes clusters that live fully inside their own walls.</p><p>But simply dropping an ML model into an isolated environment is not enough. In real systems, you need:</p><ul><li>A way to move container images</li><li>A secure internal registry</li><li>GPU support without internet</li><li>An offline package repository (pip, conda, npm, apt, yum…)</li><li>CI/CD that works offline</li><li>A model store</li><li>Monitoring without cloud services</li><li>A way to update models</li><li>Drift detection without external telemetry</li><li>RBAC and zero-trust boundaries</li><li>Backup strategies for clusters that can’t use cloud snapshots</li></ul><p>This is where things start to get tricky.</p><h3>Architecture Overview</h3><p>The system is usually split into three logical layers:</p><h4>1. Outer Layer: Offline CI/CD &amp; Artifact Gateway</h4><p>This is the staging zone before anything enters the air-gapped environment.</p><p>It normally includes:</p><ul><li>A connected CI/CD runner (GitLab/Jenkins/Cloud Build/GitHub Enterprise)</li><li>Build machines with internet access</li><li>Container image hardening and scanning</li><li>Signed artifacts creation</li><li>A “transfer station” (usually an isolated VM or bastion)</li><li>Secure USB or private fiber link</li></ul><p>Think of it like airport customs for AI models and container images.</p><p>Everything must be:</p><ul><li>Scanned</li><li>Signed</li><li>Approved</li><li>Logged</li><li>Checksum-verified</li></ul><p>Before crossing the boundary.</p><h4>2. Air-Gapped Zone: The Kubernetes Cluster</h4><p>Once inside, the core components typically look like this:</p><p><strong>Core Infrastructure</strong></p><ul><li>Kubernetes (often with hardened distributions such as RKE2, OpenShift, or K3s on edge sites)</li><li>Internal private registries (Harbor is the most common)</li><li>Private Helm chart repositories</li><li>Local CA for signing</li><li>Internal DNS</li><li>MetalLB / In-cluster load balancers for private networks</li></ul><p><strong>GPU/Accelerator Layer</strong></p><ul><li>NVIDIA GPU Operator (mirrored images)</li><li>Preloaded CUDA toolkits</li><li>Triton Inference Server or TorchServe</li><li>GPU-aware schedulers</li></ul><p><strong>AI/MLOps Layer</strong></p><ul><li>Internal MLflow installation</li><li>Local object storage (MinIO instead of S3)</li><li>Offline pipelines using Kubeflow or Argo</li><li>Feature store options (Feast with local Redis/Postgres)</li><li>Offline model registry and versioning</li><li>Drift monitoring with Prometheus</li><li>Grafana dashboards without cloud backends</li></ul><p><strong>Data Layer</strong></p><ul><li>Encrypted NFS or Ceph volumes</li><li>Immutable storage policies</li><li>Automatic rotation and pruning</li><li>Backup workflows using Velero with local storage targets</li></ul><h4>3. Model Serving Layer</h4><p>Once the training and registry layers are inside, the actual AI workloads include:</p><ul><li>Vision models running at the edge</li><li>LLM inference for chatbots, internal fuzzing, or summarization</li><li>Speech recognition models for call centres</li><li>Predictive maintenance for machines</li><li>Fraud detection models</li><li>Autonomous robotics inference pipelines</li></ul><p>Everything is versioned, signed, and controlled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dBIlxPB0vJJNOVb3TJhcsw.png" /><figcaption>Architecture Overview</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zBc2XPhq47WhxZ9i-C0Urw.png" /><figcaption>Architecture Overview</figcaption></figure><h3>Core Challenges</h3><h4>Getting Container Images Inside Is Painful</h4><p>In a connected world, everything is easy:</p><pre>docker pull pytorch/pytorch:2.1.0</pre><p>In air-gapped land?<br>You pull manually, export, checksum, scan, sign, and transfer.</p><p><strong>Typical workflow</strong></p><pre>docker pull pytorch/pytorch:2.1.0<br>docker save -o pytorch.tar pytorch/pytorch:2.1.0<br>sha256sum pytorch.tar &gt; pytorch.tar.sha256</pre><p>Move it through the gateway.</p><p>Then inside the cluster:</p><pre>docker load -i pytorch.tar<br>docker tag pytorch:2.1.0 registry.internal/pytorch:2.1.0<br>docker push registry.internal/pytorch:2.1.0</pre><p>Multiply this by:</p><ul><li>NVIDIA drivers</li><li>GPU runtime</li><li>CUDA base images</li><li>Torch/TensorFlow images</li><li>Inference servers</li><li>Your application stack</li></ul><p>You end up managing dozens of large, slow images.</p><h4>Python Dependencies Issues</h4><p>Pip packages want internet.<br>Conda packages want internet.<br>NPM packages <em>really</em> want internet.</p><p>In air-gapped setups you create:</p><ul><li>A private pip mirror (like pypi.org → local devpi/Artifactory)</li><li>A local conda mirror</li><li>A private npm registry</li></ul><p>Then you pre-sync everything you need.</p><p>The problem?<br>ML frameworks have dependency trees longer than family WhatsApp chats.</p><p>You end up mirroring:</p><ul><li>numpy</li><li>scipy</li><li>pandas</li><li>tokenizers</li><li>torch</li><li>torchtext</li><li>transformers</li><li>sentencepiece</li><li>triton</li></ul><p>…and hundreds more.</p><p>This is why teams often freeze environments with a single blessed dependency set.</p><h4>GPUs Don’t Play Nice Offline</h4><p>NVIDIA GPU Operator is excellent — but it downloads dozens of images.</p><p>In an air-gap:</p><ul><li>You must preload all driver images</li><li>Pre-mirror the entire GPU operator catalog</li><li>Build compatible CUDA toolkits</li><li>Store them in your private registry</li></ul><p>If anything mismatches — driver versions, host kernel versions, locked-down OS packages — GPUs simply refuse to cooperate.</p><p>This is why many teams choose:</p><ul><li>Red Hat OpenShift (because it’s predictable), or</li><li>Ubuntu LTS with fixed kernel versions, or</li><li>SUSE for mission-critical setups</li></ul><p>Predictability is oxygen in an air-gap.</p><h4>Monitoring Without Sending Data Out</h4><p>Prometheus works offline.</p><p>Grafana works offline.</p><p>But you have no cloud:</p><ul><li>No Datadog</li><li>No CloudWatch</li><li>No New Relic</li><li>No Sentry</li></ul><p>You must build your own stack:</p><ul><li>Prometheus → metrics</li><li>Loki → logs</li><li>Tempo → traces</li><li>Grafana → dashboards</li></ul><p>You also have to manage:</p><ul><li>Long-term retention</li><li>Storage growth</li><li>Log volume spikes</li><li>Cluster bloat</li></ul><p>Nothing can “ship logs to the cloud”, so everything becomes your problem.</p><h4>Updating Models Without Internet</h4><p>This is the most interesting and engineering-heavy part.</p><p>Most teams build a workflow like this:</p><p><strong>Model Training (Connected Zone)</strong></p><p>Train → Evaluate → Sign → Version → Export<br> Artifacts stored in MLflow.</p><p><strong>Transfer Layer</strong></p><p>Model packaged as:</p><pre>model.tar.gz<br>model.signature<br>model.metadata</pre><p>This bundle is carried through the air-gap gateway.</p><h4>Air-Gapped Zone</h4><p>Bundle is verified, scanned, and imported into the internal model registry.</p><p>Then deployments happen via:</p><ul><li>Argo CD (with offline Git repos)</li><li>Helm charts</li><li>Kustomize manifests</li><li>Triton model repository sync</li></ul><p>The end result:<br>A deterministic, versioned, auditable model update pipeline.</p><h3>Security Considerations Unique to Air-Gaps</h3><p>Security is not just “tighter” — it is different.</p><p>Below are the patterns you see only in these environments.</p><h4>1. Everything Must Be Signed</h4><p>Clusters often enforce:</p><ul><li>Container signing</li><li>Model artifact signing</li><li>Policy-as-code enforcement</li><li>Admission controller checks</li></ul><p>Without signatures?<br>Deployments are rejected.</p><h4>2. Zero Trust Inside the Cluster</h4><p>Even though the network is isolated from outside, internal movement must still be controlled.</p><p>Key approaches:</p><ul><li>NetworkPolicies blocking all east-west traffic</li><li>mTLS for all services</li><li>Strict RBAC roles</li><li>Secret rotation policies</li><li>Gatekeeper/OPA policies</li></ul><p>The assumption is simple:</p><blockquote>“The threat is not the internet. The threat is misconfiguration and insiders.”</blockquote><h4>3. USB Transfers Are Audited</h4><p>In many environments, moving files via USB requires:</p><ul><li>Formal ticket approval</li><li>Hardware-level encryption</li><li>Dual-person integrity checking</li><li>Automatic scanning systems</li><li>Tamper logs</li></ul><p>The physical world becomes part of the deployment process.</p><h3>Offline MLOps: The Framework That Makes All This Work</h3><p>Modern MLOps tooling assumes internet connectivity.</p><p>In air-gapped Kubernetes you typically build an internal stack like this:</p><h4>1. MLflow for Model Tracking</h4><p>Works beautifully offline.</p><ul><li>Tracks experiments</li><li>Stores artifacts</li><li>Provides model registry</li><li>Offers reproducibility</li></ul><h4>2. MinIO for Storage</h4><p>S3-compatible, perfect for air-gaps.</p><p>Stores:</p><ul><li>Features</li><li>Model artifacts</li><li>Large datasets</li><li>Logs</li></ul><h4>3. Kubeflow Pipelines / Prefect / Airflow</h4><p>Depending on complexity, teams choose:</p><ul><li><strong>Kubeflow</strong> when they need full-fledged pipelines with GPU orchestration</li><li><strong>Prefect</strong> when they want lightweight offline orchestration</li><li><strong>Airflow</strong> for traditional ETL-style workflows</li></ul><p>All run inside Kubernetes, fully offline.</p><h4>4. Triton Inference Server / TorchServe</h4><p>These are the backbone of inference.</p><p>Triton allows:</p><ul><li>Multi-framework support</li><li>Dynamic batching</li><li>GPU sharing</li><li>High throughput</li></ul><p>TorchServe is simpler but great for PyTorch-only teams.</p><h4>5. Argo CD with Offline Git</h4><p>Teams maintain:</p><ul><li>A Git repository <em>inside</em> the air-gapped network</li><li>Argo CD syncing against this repo</li></ul><p>This brings GitOps to disconnected clusters.</p><h3>Key Lessons</h3><p>These are patterns you start recognizing only after real deployments.</p><h4>1. You Need a “Golden Image Catalog”</h4><p>Teams quickly learn to freeze:</p><ul><li>Base container images</li><li>CUDA versions</li><li>Python versions</li><li>Torch/TensorFlow versions</li><li>OS patches</li><li>Kernel versions</li></ul><p>Consistency reduces debugging by 90%.</p><h4>2. Air-Gaps Are Not Actually Fully Isolated</h4><p>There’s always some controlled transfer mechanism.</p><p>But the rule is:</p><blockquote>“Everything entering must be known, scanned, and signed.”</blockquote><p>That’s the real boundary.</p><h4>3. Observability Becomes the Heart of Reliability</h4><p>Because you can’t Google errors or send logs to an external system, you need:</p><ul><li>Comprehensive metrics</li><li>Detailed logs</li><li>Traces</li><li>Node-level insight</li><li>GPU-level metrics</li></ul><p>The cluster must essentially explain itself.</p><h4>4. Documentation Is a Survival Tool</h4><p>Engineers maintain:</p><ul><li>Version maps</li><li>Architecture docs</li><li>“What’s inside the cluster” catalogs</li><li>“How to reproduce” guides</li></ul><p>Air-gapped Kubernetes clusters age quickly if documentation is neglected.</p><h3>A Look at Emerging Trends</h3><p>Air-gapped environments are starting to adopt several interesting patterns.</p><h4>1. On-Prem LLMs Are Becoming Normal</h4><p>Teams run:</p><ul><li>LLaMA</li><li>Mistral</li><li>Gemma</li><li>Falcon</li><li>QLoRA fine-tuned models</li></ul><p>These are compact, capable, and perfect for offline inference.</p><p>LLMs are being used for:</p><ul><li>Code analysis inside secure networks</li><li>Log summarization</li><li>Incident response</li><li>Knowledge base Q&amp;A</li><li>Internal chatbots</li></ul><h4>2. Confidential AI</h4><p>Hardware-backed protection like:</p><ul><li>Intel SGX</li><li>AMD SEV</li><li>NVIDIA Hopper Confidential Compute</li></ul><p>…is becoming integrated into clusters.</p><h4>3. Edge Kubernetes + AI</h4><p>Lightweight clusters such as:</p><ul><li>K3s</li><li>MicroK8s</li><li>KubeEdge</li></ul><p>…enable inference at remote sites with periodic synchronization back to the central system.</p><h4>4. Hybrid Multi-Site Air-Gaps</h4><p>Many orgs now run:</p><ul><li>Multiple disconnected Kubernetes clusters</li><li>Occasional offline synchronization windows</li><li>Multi-site model version propagation</li></ul><p>This requires:</p><ul><li>Deterministic updates</li><li>Version locking</li><li>Cross-site attestation</li></ul><h3>If You’re Starting Your First Air-Gapped AI Project</h3><p>Here’s a quick guide from real-world experience.</p><h4>Start with These Tools</h4><ul><li><strong>Harbor</strong> → for internal registry</li><li><strong>MinIO</strong> → for artifact storage</li><li><strong>MLflow</strong> → for model lifecycle</li><li><strong>Argo CD</strong> → for offline GitOps</li><li><strong>Prometheus + Grafana + Loki</strong> → for monitoring logs/metrics</li></ul><h4>Freeze Your Toolchain Early</h4><p>Lock versions for:</p><ul><li>Kubernetes</li><li>CUDA</li><li>Python</li><li>Framework versions</li><li>OS versions</li></ul><p>This eliminates debug chaos.</p><h4>Automate the Transfer Workflow</h4><p>Build a tool or a script that:</p><ul><li>Packages artifacts</li><li>Generates checksums</li><li>Signs them</li><li>Generates metadata</li><li>Validates integrity on the receiving side</li></ul><h4>Prioritize Documentation</h4><ul><li>Well-written documentation shortens on boarding time and helps new engineers ramp up faster.</li><li>It preserves key architectural decisions and prevents knowledge from being lost over time.</li><li>Strong documentation reduces repeated mistakes and keeps engineering velocity high as the team grows.</li></ul><h4>Test Disaster Recovery</h4><p>You cannot rely on cloud backups.</p><p>Use:</p><ul><li>Velero with local storage</li><li>Offline snapshot systems</li><li>Immutable backups</li></ul><p>Test restore procedures regularly.</p><h3>Air-Gapped AI Use Cases</h3><h4>Scenario 1: Air-Gapped AI in a National Defense Research Lab</h4><h4><strong>Background</strong></h4><p>A national defense research center was tasked with building an AI system to identify unusual patterns in telemetry collected from radar systems deployed across remote borders.<br>The radar data was extremely sensitive — classified at a level where even metadata couldn’t leave the secure facility. Internet connectivity was explicitly forbidden.</p><p>Yet the project required:</p><ul><li>GPU-heavy model training</li><li>Continuous model updates</li><li>Reliable inference pipelines</li><li>Strict compliance and traceability</li><li>Deterministic deployments that auditors could verify</li></ul><h4>How They Built the System</h4><h4><strong>1. Connected Development Zone (Outer Layer)</strong></h4><p>Outside the air-gapped facility, engineers performed:</p><ul><li>Data simulation</li><li>Model prototyping</li><li>Experiment tracking using MLflow</li><li>Code reviews via GitLab</li><li>Container builds for PyTorch/TensorFlow</li><li>Security scanning and signing of artifacts</li></ul><p>Once a model version was approved, it was exported into a deployment capsule:</p><pre>model_v9/<br>  model.pt<br>  metadata.yaml<br>  signature.json<br>  dependencies.lock<br>  performance_report.pdf</pre><p>This capsule was encrypted, digitally signed, and moved via secure portable storage devices following a 4-step approval workflow.</p><h4><strong>2. Air-Gapped Kubernetes Cluster (Inner Layer)</strong></h4><p>Inside the isolated network, a hardened Kubernetes cluster ran:</p><ul><li>RKE2 with CIS Level 2 hardening</li><li>Harbor registry</li><li>NVIDIA GPU Operator with mirrored images</li><li>Internal MLflow instance</li><li>Triton Inference Server</li><li>Loki + Prometheus + Grafana</li></ul><p>When new models arrived, they were:</p><ul><li>Checksum-verified</li><li>Virus-scanned</li><li>Signature-verified</li><li>Imported into internal MLflow</li><li>Pushed into the inference pipeline</li></ul><h4><strong>Outcome</strong></h4><ul><li>Real-time radar streams were processed on GPU nodes</li><li>Unusual patterns were detected in milliseconds</li><li>Operators received alerts with confidence scores</li><li>Models were updated without breaking air-gap compliance</li></ul><h4><strong>An Underlying Insight</strong></h4><p>The biggest challenge wasn’t GPUs or Kubernetes — it was creating a robust, safe workflow for moving AI across the air-gap. Once that was solved, the cluster ran like a reliable internal cloud.</p><h4>Scenario 2: Predictive Maintenance AI in a Large Manufacturing Plant</h4><h4><strong>Background</strong></h4><p>A global manufacturing company ran a 24×7 plant producing specialized automotive components. Any unplanned machine downtime could cost millions per hour.</p><p>They wanted on-site AI capable of:</p><ul><li>Detecting anomalies in vibration and temperature</li><li>Predicting failures hours in advance</li><li>Triggering maintenance alerts</li><li>Scaling to hundreds of sensors</li></ul><p>The site was strictly offline due to intellectual property regulations, and software updates required rigorous validation.</p><h4>How They Built the System</h4><h4><strong>1. Edge Kubernetes Cluster</strong></h4><ul><li>3 worker nodes with NVIDIA GPUs</li><li>K3s distribution hardened for industrial environments</li><li>Local MinIO storage</li><li>Internal Harbor registry</li><li>Argo CD connected to a private Git server</li><li>Node-level failover for hardware resilience</li></ul><h4><strong>2. Offline Data Processing &amp; AI</strong></h4><p>Machines continuously produced:</p><ul><li>Vibration signatures (accelerometers)</li><li>Heat maps (thermal sensors)</li><li>Acoustic patterns (microphones)</li></ul><p>A lightweight collector pushed this into the internal MinIO bucket. Models ran on Triton Inference Server:</p><ul><li>Converting sensor inputs into embeddings</li><li>Running anomaly detection</li><li>Pushing scores into Prometheus</li></ul><h4><strong>3. Model Updates via “Maintenance Window Sync”</strong></h4><p>Every two months:</p><ul><li>Data scientists trained new models in a connected environment</li><li>Offline pipeline packaged them into versioned bundles</li><li>A technician hand-carried the bundle into the plant</li><li>Argo CD detected changes in the internal Git repo</li><li>Inference pods were updated with zero downtime</li></ul><h4><strong>Impact</strong></h4><ul><li>Anomaly detection moved from reactive to predictive</li><li>Maintenance teams received alerts 3–4 hours before failures</li><li>Downtime dropped by 40%</li><li>One major gearbox failure was prevented</li><li>Engineers trusted the fully offline system</li></ul><h4><strong>An Underlying Insight</strong></h4><p>Industrial sites require extremely stable versioning and deployment processes. A single untested package, driver, or kernel update could halt the entire plant. Success came from a frozen, controlled environment where Kubernetes versions, model runtimes, CUDA versions, and Python dependencies were locked.</p><h4>Scenario 3: Computer Vision Model for a Manufacturing Plant</h4><h4><strong>Background</strong></h4><p>A plant needed to detect small defects on a conveyor system in real-time. The site had no internet connectivity. The system required:</p><ul><li>4 GPUs per node</li><li>Handling 5 video streams</li><li>Strict audit controls</li><li>High availability</li></ul><h4><strong>How They Built the System</strong></h4><h4><strong>1. Training Happens Outside (Connected Development Zone)</strong></h4><p>Data engineers had access to:</p><ul><li>CV libraries</li><li>Pretrained models</li><li>GPUs for training</li><li>Experiment tracking tools via MLflow</li></ul><p>The best model was registered as model_v13, frozen, exported, and digitally signed.</p><h4><strong>2. Package and Move the Model</strong></h4><p>Deployment bundle:</p><pre>model_v13/<br>  weights.pt<br>  config.json<br>  labels.txt<br>  signature.json<br>  requirements.lock</pre><p>It was scanned for vulnerabilities, signed, and transferred via the offline gateway.</p><h4><strong>3. Sync Inside the Air-Gapped Cluster</strong></h4><p>Operators ran:</p><pre>mlflow models import -m ./model_v13 -r internal-mlflow</pre><p>model_v13 appeared in the air-gapped MLflow registry.</p><h4><strong>4. Deploying the Model</strong></h4><p>An offline Argo CD pipeline watched the internal Git repository. A commit like:</p><pre>Update inference-service to model_v13</pre><p>triggered deployment of:</p><ul><li>Triton inference server pod</li><li>CV processing application</li><li>Custom scaling configuration</li></ul><p>All images were pulled from the internal Harbor registry.</p><h4><strong>5. Monitoring &amp; Drift Insight</strong></h4><ul><li><strong>Prometheus:</strong> FPS per camera, GPU utilization, model latency, failure rates</li><li><strong>Loki:</strong> log collection</li><li><strong>Grafana:</strong> visualization</li></ul><p>When defect patterns shifted over time, drift alerts were raised offline.</p><h4><strong>Outcome</strong></h4><ul><li>Real-time defect detection was reliable and auditable</li><li>All video streams processed simultaneously</li><li>Operators could confidently roll out new models without downtime</li></ul><h4><strong>An Underlying Insight</strong></h4><p>Success required a <strong>frozen, controlled environment</strong>: fixed Kubernetes versions, locked container runtimes, and stable Python/CUDA dependencies, ensuring deterministic deployments and full auditability.</p><h4>Scenario 4: AI-Driven License Management in a Software Enterprise</h4><h4><strong>Background</strong></h4><p>A software company wanted to deploy an AI system to monitor and optimize license usage across its enterprise software products. The system needed to:</p><ul><li>Detect underused or overused licenses</li><li>Predict license demand for upcoming periods</li><li>Automate compliance reporting</li><li>Operate fully offline due to strict IP and corporate security policies</li></ul><p>The environment had strict constraints:</p><ul><li>No internet connectivity for cloud access</li><li>Multiple license servers with GPU nodes for model inference</li><li>High availability required to avoid disrupting user access</li><li>Full audit trails for compliance</li></ul><h4><strong>How They Built the System</strong></h4><h4><strong>1. Connected Development Zone (Outer Layer)</strong></h4><p>Data scientists and engineers trained models on a connected cluster using:</p><ul><li>Historical license usage data</li><li>ML frameworks like PyTorch and XGBoost</li><li>MLflow for experiment tracking</li><li>Simulated future usage scenarios</li></ul><p>Once a model passed validation, it was frozen, signed, and exported as a deployment bundle:</p><pre>license_ai_model_v2/<br>  weights.pt<br>  config.json<br>  metadata.yaml<br>  signature.json<br>  requirements.lock<br>  performance_report.pdf</pre><h4><strong>2. Secure Transfer to Air-Gapped Cluster</strong></h4><ul><li>The deployment bundle was encrypted, scanned for vulnerabilities, and physically transported via a secure workflow with multi-step approvals.</li></ul><h4><strong>3. Air-Gapped Kubernetes Cluster (Inner Layer)</strong></h4><p>The isolated cluster included:</p><ul><li>RKE2 with CIS Level 2 hardening</li><li>Internal Harbor registry</li><li>NVIDIA GPU Operator for inference acceleration</li><li>Internal MLflow for model versioning</li><li>Triton Inference Server for license prediction workloads</li><li>Prometheus, Loki, Grafana for monitoring</li></ul><p>Models were:</p><ul><li>Checksum verified</li><li>Signature verified</li><li>Imported into internal MLflow</li><li>Deployed to inference pods</li></ul><h4><strong>4. Deployment &amp; Monitoring</strong></h4><ul><li>Argo CD monitored an internal Git repository for model updates</li><li>Triton pods processed license server logs continuously</li><li>Prometheus tracked GPU usage, inference latency, and license prediction accuracy</li><li>Grafana visualized usage patterns</li><li>Drift alerts notified administrators if license usage patterns changed</li></ul><h4><strong>Outcome</strong></h4><ul><li>License under utilization and over utilization were detected in real-time</li><li>Compliance reports were generated automatically</li><li>AI predictions helped optimize license allocations, saving significant costs</li><li>Fully auditable workflows ensured enterprise security and IP compliance</li></ul><h4><strong>An Underlying Insight</strong></h4><p>The key success factor was <strong>creating a deterministic, fully controlled deployment environment</strong>. Even in a complex enterprise setting, frozen environments, secure transfer protocols, and auditable pipelines ensured AI models could run reliably without external connectivity.</p><h3>Conclusion</h3><p>Running AI in air-gapped Kubernetes environments isn’t glamorous. It’s gritty. It’s slow. It’s full of edge cases and manual steps and version mismatches and debugging sessions where you sometimes question your life choices.</p><p>But it’s also some of the most rewarding engineering work you can do.</p><p>These environments power:</p><ul><li>National security systems</li><li>Critical manufacturing lines</li><li>Financial systems dealing with billions</li><li>Healthcare systems protecting people’s lives</li><li>Remote infrastructure that keeps countries running</li></ul><p>When you finally see an AI workload running flawlessly — entirely offline, entirely self-contained, scaling across isolated nodes with GPUs humming in perfect synchronization — it’s a thing of beauty.</p><p>It feels like building a spaceship with no access to Earth.</p><p>and somehow, it works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0ecd8e03be1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI + Fully Homomorphic Encryption (FHE): Building a Privacy-First Intelligence Era]]></title>
            <link>https://tanmaybatham.medium.com/ai-fully-homomorphic-encryption-fhe-building-a-privacy-first-intelligence-era-361e40b61896?source=rss-8fdae21a7b45------2</link>
            <guid isPermaLink="false">https://medium.com/p/361e40b61896</guid>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[homomorphic-encryption]]></category>
            <dc:creator><![CDATA[Tanmay Batham]]></dc:creator>
            <pubDate>Tue, 25 Nov 2025 10:04:45 GMT</pubDate>
            <atom:updated>2025-11-25T10:04:45.944Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence has transformed healthcare, banking, telecom, retail, and public sector operations. But as AI systems consume more sensitive data, one question dominates every boardroom and regulatory meeting:</p><blockquote>How can we allow AI to process sensitive information without exposing that information?</blockquote><p>Fully Homomorphic Encryption (FHE) is emerging as the most powerful answer — enabling AI computations <em>directly on encrypted data</em>.</p><p>This blog explains:</p><ul><li>What FHE is</li><li>Why AI needs it</li><li>Code examples</li><li>Real-world industry case studies</li><li>Architectural patterns</li><li>Future directions</li></ul><h3>Understanding Fully Homomorphic Encryption</h3><p>Fully Homomorphic Encryption allows computations on encrypted data <strong>without decrypting it</strong>. This means:</p><ul><li>You encrypt the data</li><li>Cloud/AI performs computation on encrypted values</li><li>You decrypt the result</li><li>At no point is plaintext revealed</li></ul><p>Mathematically, FHE preserves operations like:</p><pre>Enc(a) + Enc(b) → Enc(a+b)<br>Enc(a) × Enc(b) → Enc(a×b)</pre><p>Since AI models rely heavily on addition, multiplication, and matrix operations, this enables <strong>privacy-preserving machine learning</strong>.</p><h3>Why AI Needs FHE</h3><p>Traditional AI requires plaintext data. But industries have strict concerns:</p><ul><li>Healthcare: Patient privacy laws (HIPAA, DPDP, GDPR)</li><li>Banking: Sensitive transactions, risk models (RBI, PCI-DSS)</li><li>Government: Confidential population or identity data</li><li>Telecom: Subscriber privacy</li><li>Enterprises: Confidential business data</li></ul><p>FHE ensures:</p><ul><li>Cloud providers cannot see the data</li><li>External vendors cannot misuse data</li><li>Analysts cannot access sensitive inputs</li><li>Even if the cloud is compromised, the attacker sees only ciphertext</li></ul><p>This makes FHE ideal for AI workloads involving sensitive information.</p><h3>Code Examples</h3><h4>Example 1: Encrypted Computation Using Microsoft SEAL (Python)</h4><pre>import seal<br>from seal import EncryptionParameters, scheme_type, SEALContext, KeyGenerator<br>from seal import Encryptor, Decryptor, Evaluator, CKKSEncoder<br><br>parms = EncryptionParameters(scheme_type.CKKS)<br>parms.set_poly_modulus_degree(8192)<br>parms.set_coeff_modulus(seal.CoeffModulus.Create(8192, [60, 40, 40, 60]))<br><br>context = SEALContext(parms)<br><br>keygen = KeyGenerator(context)<br>public_key = keygen.public_key()<br>secret_key = keygen.secret_key()<br><br>encryptor = Encryptor(context, public_key)<br>decryptor = Decryptor(context, secret_key)<br>encoder = CKKSEncoder(context)<br>evaluator = Evaluator(context)<br><br>scale = pow(2.0, 40)<br><br>x = encoder.encode(25.0, scale)<br>y = encoder.encode(17.0, scale)<br><br>enc_x = encryptor.encrypt(x)<br>enc_y = encryptor.encrypt(y)<br><br>enc_sum = evaluator.add(enc_x, enc_y)<br>enc_prod = evaluator.multiply(enc_x, enc_y)<br><br>print(&quot;Sum:&quot;, encoder.decode(decryptor.decrypt(enc_sum))[0])<br>print(&quot;Product:&quot;, encoder.decode(decryptor.decrypt(enc_prod))[0])import seal<br>from seal import EncryptionParameters, scheme_type, SEALContext, KeyGenerator<br>from seal import Encryptor, Decryptor, Evaluator, CKKSEncoder</pre><h4>Example 2: Encrypted AI Inference (Linear Model)</h4><pre># encrypted_x1, encrypted_x2 are ciphertexts<br><br>w1 = encoder.encode(0.72, scale)<br>w2 = encoder.encode(1.34, scale)<br>b  = encoder.encode(2.10, scale)<br><br>enc_result = evaluator.add(<br>    evaluator.add(<br>        evaluator.multiply_plain(encrypted_x1, w1),<br>        evaluator.multiply_plain(encrypted_x2, w2)<br>    ),<br>    b<br>)<br><br>print(&quot;Prediction:&quot;, encoder.decode(decryptor.decrypt(enc_result))[0])</pre><h4>Example 3: Encrypted Neural Network with Zama Concrete</h4><pre>import numpy as np<br>from concrete.numpy import compiler<br><br>def approx_relu(x):<br>    return 0.125*x*x + 0.5*x<br><br>@compiler.jit<br>def fhe_layer(x, W, b):<br>    return approx_relu(np.dot(W, x) + b)<br><br>model = fhe_layer.compile(<br>    inputset=[np.random.randn(4) for _ in range(100)],<br>)<br><br>encrypted_input = model.encrypt(np.array([1.2, 2.1, 0.9, -0.5]))<br>encrypted_output = model.run(encrypted_input)<br><br>print(model.decrypt(encrypted_output))</pre><h3>Case Studies: How Industries Are Using AI + FHE</h3><h4>Case Study 1: Privacy-Preserving Cancer Diagnosis in Cloud</h4><p><strong>Problem:</strong><br> A hospital wanted to use an AI model trained on MRI scans to detect early-stage tumors.<br> Due to privacy regulations, MRI images could not be sent to cloud providers in plaintext.</p><p><strong>Solution:</strong></p><ul><li>Each MRI scan was encrypted using CKKS FHE</li><li>The encrypted image was sent to a cloud inference model</li><li>Cloud computed the prediction over ciphertext</li><li>Only the hospital could decrypt the result</li></ul><p><strong>Outcome:</strong></p><ul><li>Cloud provider never saw medical images</li><li>AI models offered real-time diagnosis</li><li>Fully compliant with HIPAA and country-local privacy laws</li><li>Enabled multi-hospital collaboration without sharing raw data</li></ul><h4>Case Study 2: Encrypted Fraud Detection Across Banks</h4><p><strong>Problem:</strong><br> Multiple banks wanted to detect fraudulent patterns across customer transactions but were restricted by secrecy rules and competitive concerns.</p><p><strong>Solution:</strong></p><ul><li>Each bank encrypted their transaction histories</li><li>A joint AI fraud detection model computed on encrypted data</li><li>Banks received encrypted risk scores and decrypted them locally</li></ul><p><strong>Outcome:</strong></p><ul><li>Banks shared intelligence without exposing customers</li><li>Detected fraud rings operating across institutions</li><li>Enhanced compliance with RBI and global regulatory requirements</li></ul><h4>Case Study 3: Encrypted Identity Matching in Government Services</h4><p><strong>Problem:</strong><br> A government department wanted to match citizen identity records across multiple databases (tax, passport, driving license) without exposing data between departments.</p><p><strong>Solution:</strong></p><ul><li>Each department encrypted their datasets</li><li>Matching algorithms using FHE performed comparisons</li><li>Results returned encrypted and decrypted only by authorized personnel</li></ul><p><strong>Outcome:</strong></p><ul><li>High accuracy identity matching</li><li>No department saw another’s raw data</li><li>Reduced data leak risk</li><li>Fully compliant with national data privacy laws</li></ul><h4>Case Study 4: Telecom Customer Analytics Without Data Exposure</h4><p><strong>Problem:</strong><br> A telecom provider wanted to use AI to analyze 4G/5G subscriber behavior (churn prediction, usage patterns), but customer data was too sensitive for cloud analytics.</p><p><strong>Solution:</strong></p><ul><li>Subscriber logs encrypted on-prem</li><li>Cloud AI ran homomorphic inference</li><li>Provider decrypted the predictions locally</li></ul><p><strong>Outcome:</strong></p><ul><li>Zero customer data leak exposure</li><li>Accurate churn forecasting</li><li>Improved subscriber retention using privacy-safe intelligence</li></ul><h3>Architecture Diagram — AI + Fully Homomorphic Encryption System</h3><h4>1. High-Level FHE Architecture (AI Inference on Encrypted Data)</h4><pre>                 ┌──────────────────────────────────────────────┐<br>                 │                  Client/User                 │<br>                 │                                              │<br>                 │  • Owns Secret Key                           │<br>                 │  • Encrypts input data                       │<br>                 └───────────────┬──────────────────────────────┘<br>                                 │ Encrypted Data (Ciphertext)<br>                                 ▼<br>         ┌────────────────────────────────────────────────────────────────┐<br>         │                        Cloud / AI Server                       │<br>         │                                                                │<br>         │  (Only sees encrypted values)                                  │<br>         │                                                                │<br>         │  ┌──────────────────────────────────────────────────────────┐  │<br>         │  │                 Homomorphic AI Model                     │  │<br>         │  │   • Linear layers (FHE-friendly)                         │  │<br>         │  │   • Polynomial activation functions                      │  │<br>         │  │   • Matrix multiplications on ciphertext                 │  │<br>         │  └──────────────────────────────────────────────────────────┘  │<br>         │                 │                                 │            │<br>         │                 ▼ Encrypted Intermediate Values   │            │<br>         │                                                                │<br>         │  Performs:                                                     │<br>         │   • add(enc_a, enc_b)                                          │<br>         │   • mul(enc_x, enc_y)                                          │<br>         │   • dot_product(enc_vec, plain_weights)                        │<br>         │                                                                │<br>         │  Results stay encrypted at all times                           │<br>         └───────────────┬────────────────────────────────────────────────┘<br>                         │ Encrypted Output (Ciphertext)<br>                         ▼<br>                 ┌──────────────────────────────────────────────┐<br>                 │                Client/User                   │<br>                 │                                              │<br>                 │  • Decrypts AI output using Secret Key       │<br>                 │  • Gets final prediction                     │<br>                 └──────────────────────────────────────────────┘</pre><h4>2. Detailed Multi-Layer AI + FHE Architecture</h4><pre>┌──────────────────────────────────────────────────────────────────────────┐<br>│                           Client / Data Owner                            │<br>│                                                                          │<br>│  • Raw data (image, EMR, transaction, identity info)                     │<br>│  • FHE Key Generation (Public + Secret Keys)                             │<br>│  • Encrypt input using Public Key                                        │<br>└───────────────┬──────────────────────────────────────────────────────────┘<br>                │ Encrypted Input (Ciphertext)<br>                ▼<br>┌─────────────────────────────────────────┐<br>│      Secure Transport Layer (TLS)       │<br>│   (Encrypted data over encrypted pipe)  │<br>└────────────────────┬────────────────────┘<br>                     ▼<br>┌──────────────────────────────────────────────────────────────────────────┐<br>│                           Cloud AI / Compute Layer                       │<br>│                                                                          │<br>│  (Has NO access to plaintext at any point)                               │<br>│                                                                          │<br>│    ┌────────────────────────────────────────────────────────────────┐    │<br>│    │            Privacy-Preserving AI Engine (Homomorphic)          │    │<br>│    │                                                                │    │<br>│    │   • Encrypted matrix multiplication (W · X)                    │    │<br>│    │   • Encrypted polynomial activation functions (ReLU approx)    │    │<br>│    │   • Encrypted convolution operations                           │    │<br>│    │   • Ciphertext addition / multiplication                       │    │<br>│    └────────────────────────────────────────────────────────────────┘    │<br>│                                                                          │<br>│  Outputs encrypted inference results                                     │<br>└───────────────┬──────────────────────────────────────────────────────────┘<br>                │ Encrypted Output (Ciphertext)<br>                ▼<br>┌─────────────────────────────────────────┐<br>│        Client / Data Owner              │<br>│                                         │<br>│  • Decrypt output using Secret Key      │<br>│  • Interpret AI result                  │<br>└─────────────────────────────────────────┘</pre><h4>3. End-to-End Flow Diagram (Compact)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*yDoNWGKcnC7hWlf82ukOlg.png" /><figcaption>End-to-End Flow Diagram (Compact)</figcaption></figure><h3>Challenges in FHE + AI</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_Q3ASyzR1p2ERPxx8UtBA.png" /><figcaption>Challenges in FHE + AI</figcaption></figure><h3>Future Directions</h3><h4>1. FHE-accelerated AI hardware</h4><p>NVIDIA, Intel, AMD are building specialized FHE compute units.</p><h4>2. Federated Learning + FHE</h4><p>Training multi-organization models on encrypted data.</p><h4>3. Consumer-grade secure AI</h4><p>Smartphones performing encrypted inference for:</p><ul><li>Personal health analytics</li><li>Private AI assistants</li><li>Financial guidance apps</li></ul><h4>4. Government adoption</h4><p>National digital identity and social services will rely heavily on privacy-preserving AI.</p><h3>Conclusion</h3><p>AI and data privacy no longer need to conflict. Fully Homomorphic Encryption enables AI models to operate on data they can never see. This unlocks secure applications in:</p><ul><li>Healthcare diagnostics</li><li>Banking fraud analytics</li><li>Telecom subscriber intelligence</li><li>Government digital services</li><li>Enterprise collaborations</li></ul><p>With FHE, the future of AI is not only powerful — it is trustworthy, compliant, and privacy-first.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=361e40b61896" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>