<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MeteorOps</title>
    <description>The latest articles on DEV Community by MeteorOps (meteorops).</description>
    <link>https://dev.to/meteorops</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F7873%2Fad0d7cdb-d642-474a-9592-c8d08685ca13.png</url>
      <title>DEV Community: MeteorOps</title>
      <link>https://dev.to/meteorops</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meteorops"/>
    <language>en</language>
    <item>
      <title>Kubernetes Persistent Volumes: PV, PVC and StorageClass</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Sat, 05 Dec 2026 15:31:08 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-persistent-volumes-pv-pvc-and-storageclass-2l59</link>
      <guid>https://dev.to/meteorops/kubernetes-persistent-volumes-pv-pvc-and-storageclass-2l59</guid>
      <description>&lt;p&gt;A Kubernetes persistent volume is storage that outlives the Pod that uses it. You get one through 3 objects: a PersistentVolumeClaim (PVC) asks for storage, a PersistentVolume (PV) is the storage, and a StorageClass creates the PV when the claim shows up. 5 things to know before you put data on one:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;PVC = the request. PV = the record of a real disk.&lt;/strong&gt; App teams write claims. The cluster creates the volume&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The StorageClass decides what you get.&lt;/strong&gt; Disk type, when the disk is created, whether it can grow, and what happens to the data when the claim is deleted&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The default is to delete your data.&lt;/strong&gt; Dynamically created volumes have the reclaim policy Delete. Delete the claim and the disk goes with it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ReadWriteOnce does NOT mean 1 Pod.&lt;/strong&gt; It means 1 node. Only ReadWriteOncePod limits a volume to 1 Pod&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A disk usually lives in 1 zone.&lt;/strong&gt; Use a StorageClass with WaitForFirstConsumer, so the disk is created where the Pod runs&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A claim and a Pod that uses it, on Kubernetes v1.37:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PersistentVolumeClaim&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ReadWriteOnce"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10Gi&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.29&lt;/span&gt;
    &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data&lt;/span&gt;
      &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/usr/share/nginx/html&lt;/span&gt;
  &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data&lt;/span&gt;
    &lt;span class="na"&gt;persistentVolumeClaim&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;claimName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The claim has no &lt;code&gt;storageClassName&lt;/code&gt;, so it uses the default StorageClass of the cluster. Check that one exists with &lt;code&gt;kubectl get storageclass&lt;/code&gt;. With no default, the claim and the Pod stay Pending.&lt;/p&gt;

&lt;p&gt;The 5 commands you will use most:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pvc
kubectl describe pvc data
kubectl get pv
kubectl get storageclass
kubectl describe pod web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Disks nobody remembers creating, and a storage bill that only goes up?&lt;/strong&gt; Get a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt;: a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You mix up the 2 objects: &lt;a href="https://meteorops.com/blog/kubernetes-persistent-volume#pv-vs-pvc-the-request-and-the-record" rel="noopener noreferrer"&gt;PV vs PVC&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are picking an access mode: &lt;a href="https://meteorops.com/blog/kubernetes-persistent-volume#access-modes-count-nodes-with-1-exception" rel="noopener noreferrer"&gt;access modes count nodes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are writing a StorageClass: &lt;a href="https://meteorops.com/blog/kubernetes-persistent-volume#the-storageclass-decides-what-disk-you-get" rel="noopener noreferrer"&gt;the StorageClass decides what disk you get&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are afraid of losing data: &lt;a href="https://meteorops.com/blog/kubernetes-persistent-volume#the-reclaim-policy-decides-what-happens-to-your-data" rel="noopener noreferrer"&gt;the reclaim policy&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are on a managed cluster: &lt;a href="https://meteorops.com/blog/kubernetes-persistent-volume#storage-classes-on-eks-gke-and-aks" rel="noopener noreferrer"&gt;EKS, GKE and AKS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A claim or a Pod is stuck right now: &lt;a href="https://meteorops.com/blog/kubernetes-persistent-volume#debug-a-pvc-11-symptoms-and-the-first-command" rel="noopener noreferrer"&gt;11 symptoms and the first command&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  PV vs PVC: the request and the record
&lt;/h2&gt;

&lt;p&gt;Storage in Kubernetes takes 3 objects and 1 field in the Pod. Each one answers 1 question:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Object&lt;/th&gt;
&lt;th&gt;Question it answers&lt;/th&gt;
&lt;th&gt;Scope&lt;/th&gt;
&lt;th&gt;Who writes it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Volume in the Pod spec&lt;/td&gt;
&lt;td&gt;Where does the container see the files?&lt;/td&gt;
&lt;td&gt;The Pod&lt;/td&gt;
&lt;td&gt;The app team&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PersistentVolumeClaim (PVC)&lt;/td&gt;
&lt;td&gt;How much storage, and which kind?&lt;/td&gt;
&lt;td&gt;A namespace&lt;/td&gt;
&lt;td&gt;The app team&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PersistentVolume (PV)&lt;/td&gt;
&lt;td&gt;Which real disk is it?&lt;/td&gt;
&lt;td&gt;The cluster&lt;/td&gt;
&lt;td&gt;The StorageClass, or an admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;StorageClass&lt;/td&gt;
&lt;td&gt;How are disks created?&lt;/td&gt;
&lt;td&gt;The cluster&lt;/td&gt;
&lt;td&gt;The platform team&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Pod names a claim. The claim is bound to a volume. The volume points at a disk that lives outside the cluster: an EBS volume, a Persistent Disk, an Azure Disk, an NFS share.&lt;/p&gt;

&lt;p&gt;The claim is the request. The volume is the record of a real disk.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft8d24r63bs6wgml94et2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft8d24r63bs6wgml94et2.jpg" alt="Kubernetes PV vs PVC: a Pod uses a PersistentVolumeClaim, the claim is bound to a PersistentVolume created by a StorageClass, and the PersistentVolume points to a disk outside the cluster" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Pod, claim, volume, disk. The StorageClass creates the volume.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The split exists so that the app team never has to know how storage is provided. A claim says "10Gi, ReadWriteOnce". It does not say which cloud, which disk ID or which zone. The same manifest works on every cluster that has a default StorageClass.&lt;/p&gt;

&lt;p&gt;3 rules follow from the scopes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Pod can only use a claim from its own namespace&lt;/li&gt;
&lt;li&gt;A PV has no namespace. An admin sees all of them with &lt;code&gt;kubectl get pv&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A dynamically created PV is named after the claim's UID, like &lt;code&gt;pvc-b6efd8da-b7b5-11e6-9d58-0ed433a7dd94&lt;/code&gt;. You almost never type that name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My rule: app teams write claims, the platform team writes StorageClasses, and nobody writes PVs by hand.&lt;/p&gt;
&lt;h2&gt;
  
  
  What survives a restart, a deleted Pod and a dead node
&lt;/h2&gt;

&lt;p&gt;Before you add a claim, check that you need one. Kubernetes has 3 places to put files, and a claim comes in 2 kinds. They differ in what they survive:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Where the files are&lt;/th&gt;
&lt;th&gt;Container restart&lt;/th&gt;
&lt;th&gt;Pod deleted&lt;/th&gt;
&lt;th&gt;Node lost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The container filesystem&lt;/td&gt;
&lt;td&gt;Lost&lt;/td&gt;
&lt;td&gt;Lost&lt;/td&gt;
&lt;td&gt;Lost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An &lt;code&gt;emptyDir&lt;/code&gt; volume&lt;/td&gt;
&lt;td&gt;Kept&lt;/td&gt;
&lt;td&gt;Lost&lt;/td&gt;
&lt;td&gt;Lost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A claim on a network disk&lt;/td&gt;
&lt;td&gt;Kept&lt;/td&gt;
&lt;td&gt;Kept&lt;/td&gt;
&lt;td&gt;Kept&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A claim on a local volume&lt;/td&gt;
&lt;td&gt;Kept&lt;/td&gt;
&lt;td&gt;Kept&lt;/td&gt;
&lt;td&gt;Lost, or out of reach until the node is back&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;An &lt;code&gt;emptyDir&lt;/code&gt; is created when the Pod lands on a node and is deleted for good when the Pod leaves that node. A container crash does not remove the Pod, so the data is safe across crashes.&lt;/p&gt;

&lt;p&gt;That makes &lt;code&gt;emptyDir&lt;/code&gt; the right place for caches, scratch space and files shared between containers of 1 Pod. A claim is for data you want back after the Pod is gone.&lt;/p&gt;

&lt;p&gt;2 volume types look like shortcuts and cost you later:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;hostPath&lt;/strong&gt; mounts a directory of the node. The Kubernetes docs warn that it carries many security risks, and a hostPath PV only works on a single node cluster. Keep it for local testing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;local&lt;/strong&gt; volumes are real PVs on a node's own disk. They are fast, they need a &lt;code&gt;nodeAffinity&lt;/code&gt;, they cannot be created dynamically, and when the node is unhealthy the data is out of reach&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How a claim finds a volume
&lt;/h2&gt;

&lt;p&gt;There are 2 ways for a volume to exist:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Static:&lt;/strong&gt; an admin creates PVs ahead of time, and claims pick from them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic:&lt;/strong&gt; nobody creates anything ahead of time. A claim arrives, and the StorageClass creates a disk and a PV for it&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Dynamic is the normal way on any cloud. Static is for storage that already exists: an NFS export, a disk restored from a backup, a local SSD.&lt;/p&gt;

&lt;p&gt;Either way, a control loop binds the claim to a volume. The binding rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1 to 1.&lt;/strong&gt; A volume is bound to 1 claim, and no other claim can have it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;At least what you asked for.&lt;/strong&gt; A 3Gi claim can bind a 10Gi volume, and &lt;code&gt;kubectl get pvc&lt;/code&gt; then shows 10Gi&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The class must match.&lt;/strong&gt; A volume of class &lt;code&gt;fast&lt;/code&gt; only binds a claim of class &lt;code&gt;fast&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The access mode must be offered.&lt;/strong&gt; A ReadWriteMany claim does not bind a volume that only offers ReadWriteOnce&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The volume mode must match.&lt;/strong&gt; &lt;code&gt;Filesystem&lt;/code&gt; (the default) gives you a directory. &lt;code&gt;Block&lt;/code&gt; gives you a raw device&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No match, no binding.&lt;/strong&gt; The claim stays Pending until a matching volume appears&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A bound claim looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pvc data

NAME   STATUS   &lt;span class="k"&gt;VOLUME&lt;/span&gt;                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
data   Bound    pvc-b6efd8da-b7b5-11e6-9d58-0ed433a7dd94   10Gi       RWO            fast           30s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  storageClassName: empty and missing are 2 different things
&lt;/h3&gt;

&lt;p&gt;This 1 field has 3 behaviors, and the difference matters:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;In the claim&lt;/th&gt;
&lt;th&gt;What happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;storageClassName: fast&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The class &lt;code&gt;fast&lt;/code&gt; creates the volume&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The field is missing&lt;/td&gt;
&lt;td&gt;The default StorageClass is used. With no default, the claim waits, and it gets the class once a default appears&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;storageClassName: ""&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No dynamic provisioning. The claim only binds a pre-created PV that has no class&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So &lt;code&gt;""&lt;/code&gt; is the way to say "I want that existing volume with no class, do not create a new one". Pair it with &lt;code&gt;volumeName&lt;/code&gt; to pick the exact PV:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PersistentVolumeClaim&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;restored-data&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;storageClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
  &lt;span class="na"&gt;volumeName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;restored-pv&lt;/span&gt;
  &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ReadWriteOnce"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;100Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without the &lt;code&gt;""&lt;/code&gt;, the default class is filled in, the classes no longer match, and the claim stays Pending.&lt;/p&gt;

&lt;h2&gt;
  
  
  Access modes count nodes, with 1 exception
&lt;/h2&gt;

&lt;p&gt;There are 4 access modes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Short&lt;/th&gt;
&lt;th&gt;What it allows&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ReadWriteOnce&lt;/td&gt;
&lt;td&gt;RWO&lt;/td&gt;
&lt;td&gt;Read and write from 1 node. Several Pods on that node can all use it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ReadOnlyMany&lt;/td&gt;
&lt;td&gt;ROX&lt;/td&gt;
&lt;td&gt;Read only from many nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ReadWriteMany&lt;/td&gt;
&lt;td&gt;RWX&lt;/td&gt;
&lt;td&gt;Read and write from many nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ReadWriteOncePod&lt;/td&gt;
&lt;td&gt;RWOP&lt;/td&gt;
&lt;td&gt;Read and write from 1 Pod in the whole cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Only ReadWriteOncePod limits the volume to 1 Pod.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fogu0xbsrlfoa9i1ohx7m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fogu0xbsrlfoa9i1ohx7m.jpg" alt="Kubernetes access modes: ReadWriteOnce (RWO) is 1 node, ReadOnlyMany (ROX) is many nodes read only, ReadWriteMany (RWX) is many nodes read and write, ReadWriteOncePod (RWOP) is 1 Pod in the whole cluster" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;3 modes count nodes. 1 counts Pods.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;3 things about access modes that surprise people:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;RWO is about nodes.&lt;/strong&gt; 2 Pods on the same node can both write to a ReadWriteOnce volume. If your database assumes it is alone, RWO does not protect it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The modes do not enforce write protection.&lt;/strong&gt; Kubernetes uses them to match claims with volumes. Once a volume is mounted, a ReadOnlyMany volume is not guaranteed to be read only&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The disk decides what is possible.&lt;/strong&gt; A normal block disk (EBS, Azure Disk) attaches to 1 node. For ReadWriteMany you need a file service: EFS on AWS, Filestore on Google Cloud, Azure Files on Azure, or NFS&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;ReadWriteOncePod is stable since Kubernetes v1.29 and only works with CSI drivers. The Kubernetes tutorial on persistent volumes recommends it over ReadWriteOnce for production.&lt;/p&gt;

&lt;p&gt;I treat ReadWriteOnce as a scheduling hint and ReadWriteOncePod as a lock. For a database, I want the lock.&lt;/p&gt;

&lt;p&gt;ReadWriteMany looks like the easy answer for "3 replicas, 1 folder". It works, and you pay for it with a network filesystem: slower small writes and file locking that your app has to tolerate. If the app can use object storage (S3, GCS) for shared files, that is usually simpler.&lt;/p&gt;
&lt;h2&gt;
  
  
  The StorageClass decides what disk you get
&lt;/h2&gt;

&lt;p&gt;A StorageClass is a template for disks. A claim names a class, and the class creates the volume.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;storage.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StorageClass&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;fast&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;storageclass.kubernetes.io/is-default-class&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"true"&lt;/span&gt;
&lt;span class="na"&gt;provisioner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ebs.csi.aws.com&lt;/span&gt;
&lt;span class="na"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gp3&lt;/span&gt;
&lt;span class="na"&gt;reclaimPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Delete&lt;/span&gt;
&lt;span class="na"&gt;allowVolumeExpansion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;volumeBindingMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;WaitForFirstConsumer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The annotation makes this class the default. Leave it out if the cluster already has a default you want to keep.&lt;/p&gt;

&lt;p&gt;The fields, with the defaults:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;provisioner&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The driver that creates the disk. Required&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;parameters&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Passed to the driver: disk type, IOPS, encryption. Each driver has its own list&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;reclaimPolicy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What happens to the disk when the claim is deleted&lt;/td&gt;
&lt;td&gt;Delete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;allowVolumeExpansion&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Whether a claim of this class can grow&lt;/td&gt;
&lt;td&gt;Off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;volumeBindingMode&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;When the disk is created&lt;/td&gt;
&lt;td&gt;Immediate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;allowedTopologies&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Limits the zones. Rarely needed with WaitForFirstConsumer&lt;/td&gt;
&lt;td&gt;All zones&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;3 of these defaults are wrong for production data: Delete, no expansion and Immediate. Set all 3 on purpose when you write the class.&lt;/p&gt;

&lt;p&gt;You cannot fix them later. The API rejects a change to &lt;code&gt;reclaimPolicy&lt;/code&gt;, &lt;code&gt;volumeBindingMode&lt;/code&gt;, &lt;code&gt;provisioner&lt;/code&gt; or &lt;code&gt;parameters&lt;/code&gt; on an existing class. Only &lt;code&gt;allowVolumeExpansion&lt;/code&gt; can be switched on afterwards. To change the rest, create a new class and move the default annotation to it.&lt;/p&gt;

&lt;p&gt;The driver names you will see: &lt;code&gt;ebs.csi.aws.com&lt;/code&gt; for Amazon EBS, &lt;code&gt;pd.csi.storage.gke.io&lt;/code&gt; for Google Persistent Disk and &lt;code&gt;disk.csi.azure.com&lt;/code&gt; for Azure Disk. The old drivers that were built into Kubernetes are gone: EBS and Azure Disk were removed in v1.27, and GCE PD in v1.28.&lt;/p&gt;

&lt;h3&gt;
  
  
  The default StorageClass
&lt;/h3&gt;

&lt;p&gt;A claim with no &lt;code&gt;storageClassName&lt;/code&gt; gets the default class. A class is the default when it carries the annotation &lt;code&gt;storageclass.kubernetes.io/is-default-class: "true"&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get storageclass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The default has &lt;code&gt;(default)&lt;/code&gt; next to its name. 3 cases to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;0 defaults:&lt;/strong&gt; a claim without a class waits. Since v1.28 it gets the class when a default appears, without you touching it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1 default:&lt;/strong&gt; what you want&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2 or more defaults:&lt;/strong&gt; the most recently created one is used. Keep it that way only while you migrate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To move the default from one class to another:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl patch storageclass standard -p &lt;span class="s1"&gt;'{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'&lt;/span&gt;
kubectl patch storageclass fast -p &lt;span class="s1"&gt;'{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This affects new claims, and claims that are still waiting with no class. Bound claims and existing volumes keep the class they were created with.&lt;/p&gt;

&lt;h2&gt;
  
  
  WaitForFirstConsumer: the disk follows the Pod
&lt;/h2&gt;

&lt;p&gt;A cloud disk usually lives in 1 zone. A Pod can only use it from a node in that zone. The binding mode decides who picks the zone:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Immediate:&lt;/strong&gt; the disk is created as soon as the claim exists, before anybody knows where the Pod will run&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WaitForFirstConsumer:&lt;/strong&gt; the claim waits until a Pod uses it. The scheduler picks a node first, using the Pod's requests, node selectors, affinity rules and taints. Then the disk is created&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With WaitForFirstConsumer, the disk is created in the zone of the Pod.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8xmiqzjlqp6ise1hrk50.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8xmiqzjlqp6ise1hrk50.jpg" alt="Kubernetes volumeBindingMode: with Immediate the disk is created in zone a as soon as the claim exists and a Pod that cannot run there stays Pending, with WaitForFirstConsumer the disk is created in the zone of the Pod" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Schedule the Pod first, then create the disk.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With Immediate, the Pod has to fit in whatever zone the disk landed in. When that zone has no room, or an anti-affinity rule sends the Pod elsewhere, the Pod stays Pending with a scheduler message about the volume's node affinity.&lt;/p&gt;

&lt;p&gt;3 things to expect with WaitForFirstConsumer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A new claim sits in Pending with the event &lt;code&gt;waiting for first consumer to be created before binding&lt;/code&gt;. That is normal. Create the Pod&lt;/li&gt;
&lt;li&gt;Do not set &lt;code&gt;nodeName&lt;/code&gt; on the Pod. It skips the scheduler, and the claim stays Pending. Use a &lt;code&gt;nodeSelector&lt;/code&gt; on &lt;code&gt;kubernetes.io/hostname&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The zone is picked once. After a zonal disk exists, the Pod is tied to that zone for as long as it uses that volume. Zone-redundant disks (the built-in AKS classes in a multi-zone cluster, regional disks on GKE) are the exception&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Number 3 is the part people forget. A stateful Pod cannot move to another zone when its own zone runs out of nodes. Plan capacity per zone for anything with a disk.&lt;/p&gt;
&lt;h2&gt;
  
  
  The reclaim policy decides what happens to your data
&lt;/h2&gt;

&lt;p&gt;Every PV has a reclaim policy. It answers 1 question: the claim was deleted, now what?&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Policy&lt;/th&gt;
&lt;th&gt;When the claim is deleted&lt;/th&gt;
&lt;th&gt;Default for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Delete&lt;/td&gt;
&lt;td&gt;The PV is removed, and so is the disk in the cloud&lt;/td&gt;
&lt;td&gt;Dynamically created volumes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retain&lt;/td&gt;
&lt;td&gt;The PV stays, in the phase Released. The disk and the data stay&lt;/td&gt;
&lt;td&gt;PVs created by hand&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recycle&lt;/td&gt;
&lt;td&gt;Deprecated. Do not use it&lt;/td&gt;
&lt;td&gt;Nothing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So on a default cloud setup, &lt;code&gt;kubectl delete pvc data&lt;/code&gt; deletes the data. So does &lt;code&gt;kubectl delete namespace&lt;/code&gt;, because the claims go with the namespace.&lt;/p&gt;

&lt;p&gt;(A wrong kubectl context is the usual way this happens.)&lt;/p&gt;

&lt;p&gt;You can change the policy of a volume that already exists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl patch pv pvc-b6efd8da-b7b5-11e6-9d58-0ed433a7dd94 -p &lt;span class="s1"&gt;'{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For new volumes, use a StorageClass with &lt;code&gt;reclaimPolicy: Retain&lt;/code&gt;. The field cannot be changed on an existing class, so this means a new class. Volumes that already exist keep their policy: patch each of them with the command above.&lt;/p&gt;

&lt;p&gt;Retain keeps the disk and the bill until you delete both by hand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0sjcvgbg61bfja8h01dr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0sjcvgbg61bfja8h01dr.jpg" alt="Kubernetes reclaim policies when a PersistentVolumeClaim is deleted: with Delete the volume and the disk are deleted, with Retain the volume is Released and the disk keeps the data and is still billed" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Delete removes the disk. Retain keeps it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A Released volume is not available to a new claim, because the old data is still on it. You have 2 options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Throw it away:&lt;/strong&gt; delete the PV, then delete the disk in the cloud console. Deleting the PV alone leaves the disk&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use it again:&lt;/strong&gt; remove the &lt;code&gt;claimRef&lt;/code&gt; from the PV, and it becomes Available. Then bind it with a claim that sets &lt;code&gt;volumeName&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl patch pv pvc-b6efd8da-b7b5-11e6-9d58-0ed433a7dd94 -p &lt;span class="s1"&gt;'{"spec":{"claimRef":null}}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;2 things to get right when you reuse a volume:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;storageClassName&lt;/code&gt; of the new claim has to equal the class on the PV. For a volume that a class created, that is the class name. Use &lt;code&gt;""&lt;/code&gt; only when the PV has no class&lt;/li&gt;
&lt;li&gt;An Available volume can be taken by any claim that matches it. Create your claim right after the patch, or set the &lt;code&gt;claimRef&lt;/code&gt; of the PV to the namespace and name of your new claim to reserve it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My rule: Retain for anything I would be sad to lose, Delete for everything else, and backups for both. Retain protects you from a deleted claim. It does nothing for a dropped table.&lt;/p&gt;
&lt;h3&gt;
  
  
  A claim in use is not deleted right away
&lt;/h3&gt;

&lt;p&gt;Kubernetes will not pull a disk from under a running Pod. If you delete a claim that a Pod still uses, the claim shows &lt;code&gt;Terminating&lt;/code&gt; and stays there until the Pod is gone. The same goes for a PV that is bound to a claim.&lt;/p&gt;

&lt;p&gt;The delete is only postponed. When the Pod goes away (a restart, a rollout, a node drain), the claim is removed, and with the Delete policy the disk too. If the delete was a mistake, patch the PV to Retain before anything restarts the Pod.&lt;/p&gt;

&lt;p&gt;The mechanism is a finalizer: &lt;code&gt;kubernetes.io/pvc-protection&lt;/code&gt; on the claim and &lt;code&gt;kubernetes.io/pv-protection&lt;/code&gt; on the volume.&lt;/p&gt;

&lt;p&gt;2 more finalizers guard the Delete policy. On older clusters, deleting the PV before the claim could leave the disk behind in the cloud, with nothing in the cluster pointing at it. The fix is stable since v1.33: the disk is removed whatever the order.&lt;/p&gt;
&lt;h3&gt;
  
  
  The phases you will see
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Object&lt;/th&gt;
&lt;th&gt;Phase&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PV&lt;/td&gt;
&lt;td&gt;Available&lt;/td&gt;
&lt;td&gt;Free, no claim yet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PV&lt;/td&gt;
&lt;td&gt;Bound&lt;/td&gt;
&lt;td&gt;Bound to a claim&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PV&lt;/td&gt;
&lt;td&gt;Released&lt;/td&gt;
&lt;td&gt;The claim was deleted, the data is still there&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PV&lt;/td&gt;
&lt;td&gt;Failed&lt;/td&gt;
&lt;td&gt;The automatic reclaim failed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PVC&lt;/td&gt;
&lt;td&gt;Pending&lt;/td&gt;
&lt;td&gt;No volume yet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PVC&lt;/td&gt;
&lt;td&gt;Bound&lt;/td&gt;
&lt;td&gt;Ready to use&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PVC&lt;/td&gt;
&lt;td&gt;Lost&lt;/td&gt;
&lt;td&gt;The volume it was bound to no longer exists&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Grow a volume by editing the claim
&lt;/h2&gt;

&lt;p&gt;When a disk fills up, you edit the claim and ask for more:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl patch pvc data -p &lt;span class="s1"&gt;'{"spec":{"resources":{"requests":{"storage":"20Gi"}}}}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The StorageClass needs &lt;code&gt;allowVolumeExpansion: true&lt;/code&gt;, and the driver has to support it&lt;/li&gt;
&lt;li&gt;The same disk is resized. No new PV is created&lt;/li&gt;
&lt;li&gt;A claim that a Pod is using grows online, with no restart, when the driver supports online expansion. Most cloud disk drivers do. A claim that no Pod uses finishes growing when a Pod mounts it&lt;/li&gt;
&lt;li&gt;The filesystem has to be XFS, Ext3 or Ext4&lt;/li&gt;
&lt;li&gt;You cannot shrink a volume. Ever&lt;/li&gt;
&lt;li&gt;Never edit the size on the PV. Kubernetes then assumes the resize was done by hand and skips it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the cloud refuses the new size (a quota, a size the disk type does not allow), the resize is retried forever. You can then lower the request to a smaller value, as long as it is still above the current size, and the resize is tried again. This recovery is stable since v1.34.&lt;/p&gt;

&lt;p&gt;The full procedure, with the checks before and after, is in our guide on &lt;a href="https://meteorops.com/blog/how-to-resize-kubernetes-persistent-volumes-without-downtime" rel="noopener noreferrer"&gt;resizing persistent volumes without downtime&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One more detail on size: &lt;code&gt;10Gi&lt;/code&gt; is 10 times 1024 cubed bytes, and &lt;code&gt;10G&lt;/code&gt; is 10 times 1000 cubed. And the request is the size of the disk. The space you can write to is a little lower, because the filesystem takes its share.&lt;/p&gt;

&lt;h2&gt;
  
  
  Snapshots and clones copy a volume
&lt;/h2&gt;

&lt;p&gt;A VolumeSnapshot is a point in time copy of a volume. It works like claims and volumes do: a VolumeSnapshot is the request, a VolumeSnapshotContent is the real snapshot, and a VolumeSnapshotClass says how to make it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;snapshot.storage.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;VolumeSnapshot&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data-snap&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;volumeSnapshotClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;csi-snapclass&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;persistentVolumeClaimName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To restore, you create a new claim that names the snapshot as its source:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PersistentVolumeClaim&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data-restored&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;storageClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;fast&lt;/span&gt;
  &lt;span class="na"&gt;dataSource&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;data-snap&lt;/span&gt;
    &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;VolumeSnapshot&lt;/span&gt;
    &lt;span class="na"&gt;apiGroup&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;snapshot.storage.k8s.io&lt;/span&gt;
  &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ReadWriteOnce"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A restore never overwrites the old volume. You get a new claim, and you point the app at it.&lt;/p&gt;

&lt;p&gt;3 things to check before you count on snapshots:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Snapshots are not part of core Kubernetes. They are custom resources, and they need a snapshot controller in the cluster and a CSI driver that supports them. Run &lt;code&gt;kubectl get volumesnapshotclass&lt;/code&gt; to see if your cluster has them&lt;/li&gt;
&lt;li&gt;A snapshot covers a deleted claim. It does not cover a deleted namespace: the VolumeSnapshot lives in the namespace, and with &lt;code&gt;deletionPolicy: Delete&lt;/code&gt; on the VolumeSnapshotClass the snapshot in the cloud is deleted with it. Use &lt;code&gt;deletionPolicy: Retain&lt;/code&gt; for snapshots you count on. And a snapshot usually lives in the same cloud account as the disk, so it does not cover a deleted account&lt;/li&gt;
&lt;li&gt;A snapshot of a running database is only as consistent as a power cut. Test a restore&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A clone skips the snapshot. The new claim names another claim as its &lt;code&gt;dataSource&lt;/code&gt;, with &lt;code&gt;kind: PersistentVolumeClaim&lt;/code&gt;. The source has to be in the same namespace, and the clone has to be at least as large as the source. It is handy for a copy of production data in a test Pod.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Pod with a disk: Deployment or StatefulSet
&lt;/h2&gt;

&lt;p&gt;All replicas of a Deployment share 1 claim. That gives you 2 cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Several replicas on 1 claim:&lt;/strong&gt; works only with ReadWriteMany storage. With a ReadWriteOnce disk, the replicas on other nodes cannot attach it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1 replica on 1 claim:&lt;/strong&gt; works, with a catch on every rollout&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The catch: a rolling update starts the new Pod before it stops the old one. If the new Pod lands on another node, it waits for a disk that the old Pod still holds, and the old Pod is not stopped until the new one is ready. The rollout hangs.&lt;/p&gt;

&lt;p&gt;With ReadWriteOncePod it happens on every rollout. The scheduler refuses the new Pod on every node, the old node included, and the new Pod stays Pending with &lt;code&gt;node(s) unavailable due to PersistentVolumeClaim with ReadWriteOncePod access mode already in-use by another pod&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2 ways out:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set &lt;code&gt;strategy.type: Recreate&lt;/code&gt; on the Deployment. The old Pod stops first, at the price of a short downtime on each release&lt;/li&gt;
&lt;li&gt;Use a StatefulSet. Its &lt;code&gt;volumeClaimTemplates&lt;/code&gt; give every replica its own claim, and it replaces Pods 1 at a time&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For anything with more than 1 replica and a disk per replica, the StatefulSet is the only option. The details are in our &lt;a href="https://meteorops.com/blog/kubernetes-statefulset" rel="noopener noreferrer"&gt;Kubernetes StatefulSet guide&lt;/a&gt;, and the rollout mechanics are in the &lt;a href="https://meteorops.com/blog/kubernetes-deployment" rel="noopener noreferrer"&gt;Kubernetes Deployment guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  fsGroup can make a big volume mount slowly
&lt;/h2&gt;

&lt;p&gt;A fresh disk is owned by root. A container that runs as another user cannot write to it. The usual fix is &lt;code&gt;fsGroup&lt;/code&gt; in the Pod's security context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;securityContext&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runAsUser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;
    &lt;span class="na"&gt;fsGroup&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;
    &lt;span class="na"&gt;fsGroupChangePolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;OnRootMismatch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;fsGroup&lt;/code&gt;, Kubernetes changes the group of the files on the volume when it mounts it. By default it walks every file, on every mount. On a volume with millions of files, the Pod sits in ContainerCreating for minutes, and the events show a mount that timed out.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fsGroupChangePolicy: OnRootMismatch&lt;/code&gt; only walks the files when the top directory has the wrong owner. In practice that means once. It is stable since v1.23, and I add it every time I set &lt;code&gt;fsGroup&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2 related mount options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;readOnly: true&lt;/code&gt; on a volume mount makes it read only for that container. Other containers can still write&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;subPath&lt;/code&gt; mounts 1 folder of the volume, which lets 2 containers share a disk without seeing each other's files&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Storage classes on EKS, GKE and AKS
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cloud&lt;/th&gt;
&lt;th&gt;Classes you get&lt;/th&gt;
&lt;th&gt;Binding mode&lt;/th&gt;
&lt;th&gt;Shared files (ReadWriteMany)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;EKS&lt;/td&gt;
&lt;td&gt;EKS Auto Mode creates no StorageClass. You write one, with the provisioner &lt;code&gt;ebs.csi.eks.amazonaws.com&lt;/code&gt;. Without Auto Mode, you install the EBS CSI driver (&lt;code&gt;ebs.csi.aws.com&lt;/code&gt;) and write a gp3 class for it. Older clusters may still carry a gp2 class&lt;/td&gt;
&lt;td&gt;Yours to set. The AWS sample uses WaitForFirstConsumer and gp3&lt;/td&gt;
&lt;td&gt;The EFS CSI driver&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GKE&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;standard-rwo&lt;/code&gt; (balanced disk) and &lt;code&gt;premium-rwo&lt;/code&gt; (SSD). ReadWriteOnce claims default to &lt;code&gt;standard-rwo&lt;/code&gt;. Google's driver page still describes an older default class on Standard clusters, so check yours&lt;/td&gt;
&lt;td&gt;WaitForFirstConsumer on &lt;code&gt;standard-rwo&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Filestore. From GKE 1.37.1, ReadWriteMany claims default to &lt;code&gt;regional-rwx&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AKS&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;default&lt;/code&gt; and &lt;code&gt;managed-csi&lt;/code&gt; (Standard SSD), &lt;code&gt;managed-csi-premium&lt;/code&gt; (Premium SSD)&lt;/td&gt;
&lt;td&gt;WaitForFirstConsumer, with reclaim policy Delete and expansion on&lt;/td&gt;
&lt;td&gt;Azure Files&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Do not trust a table for your own cluster, this one included. Run this and read 4 columns: the provisioner, the reclaim policy, the binding mode and the expansion flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get storageclass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 notes for AWS. The Auto Mode provisioner and the standard EBS CSI driver manage their volumes separately, and moving volumes from one to the other goes through snapshots. And EBS volumes do not work on Fargate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits, quotas and the bill
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A node takes a limited number of disks
&lt;/h3&gt;

&lt;p&gt;Every node has a maximum number of volumes it can attach. The CSI driver reports the number, and the scheduler respects it. Some numbers from the docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS:&lt;/strong&gt; most Nitro instance types support 28 attachments, shared between EBS volumes, network interfaces and NVMe instance store volumes. An m5.xlarge with 1 network interface takes 27 EBS volumes, the root volume included. Each extra network interface takes 1 away, and EKS nodes usually have several&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Cloud:&lt;/strong&gt; up to 127 volumes per node, depending on the node type&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Azure:&lt;/strong&gt; up to 64 disks per node, depending on the node type&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Many small Pods with 1 disk each on a few large nodes will hit this before they hit CPU. The Pod then stays Pending with &lt;code&gt;node(s) exceed max volume count&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quotas stop a namespace from eating the storage
&lt;/h3&gt;

&lt;p&gt;A ResourceQuota can cap storage per namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ResourceQuota&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;storage&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;hard&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;persistentvolumeclaims&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"10"&lt;/span&gt;
    &lt;span class="na"&gt;requests.storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;200Gi&lt;/span&gt;
    &lt;span class="na"&gt;fast.storageclass.storage.k8s.io/requests.storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;50Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That allows 10 claims and 200Gi in total, of which at most 50Gi on the class &lt;code&gt;fast&lt;/code&gt;. A LimitRange of type PersistentVolumeClaim adds a minimum and a maximum size per claim.&lt;/p&gt;

&lt;h3&gt;
  
  
  Volumes without a Pod still cost money
&lt;/h3&gt;

&lt;p&gt;A claim lives longer than the workload that created it. Delete a Deployment, scale down a StatefulSet, and the claims stay. So do the disks, and AWS and Azure both state it plainly: a disk that is no longer attached is still charged until you delete it.&lt;/p&gt;

&lt;p&gt;Kubernetes v1.37 makes these easier to find. Claims now carry an &lt;code&gt;Unused&lt;/code&gt; condition (beta, on by default) with the time since no Pod has used them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pvc -A -o custom-columns=&lt;span class="s1"&gt;'NS:.metadata.namespace,NAME:.metadata.name,UNUSED:.status.conditions[?(@.type=="Unused")].status,SINCE:.status.conditions[?(@.type=="Unused")].lastTransitionTime'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And list the volumes whose claim is already gone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pv &lt;span class="o"&gt;|&lt;/span&gt; grep Released
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I run both once a month. There is always something.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed for volumes from v1.33 to v1.37
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;th&gt;Why you care&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;v1.33&lt;/td&gt;
&lt;td&gt;The fix for PVs deleted before their claim is stable&lt;/td&gt;
&lt;td&gt;A Delete policy volume no longer leaves an orphan disk in the cloud&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.33&lt;/td&gt;
&lt;td&gt;The scheduler message for a zone mismatch changed to &lt;code&gt;node(s) didn't match PersistentVolume's node affinity&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Older guides and alerts search for &lt;code&gt;volume node affinity conflict&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.34&lt;/td&gt;
&lt;td&gt;Recovery from a failed volume expansion is stable&lt;/td&gt;
&lt;td&gt;You can lower a resize request that the cloud refused&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.34&lt;/td&gt;
&lt;td&gt;VolumeAttributesClass is stable&lt;/td&gt;
&lt;td&gt;Change the IOPS or throughput of a live volume by editing the claim, when the driver supports it (the EBS CSI driver does)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.36&lt;/td&gt;
&lt;td&gt;Volume group snapshots are stable&lt;/td&gt;
&lt;td&gt;Snapshot several volumes at the same point in time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.37&lt;/td&gt;
&lt;td&gt;The &lt;code&gt;Unused&lt;/code&gt; condition on claims is beta and on by default&lt;/td&gt;
&lt;td&gt;Find claims that no Pod uses, and since when&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.37&lt;/td&gt;
&lt;td&gt;SELinux mount labeling is on by default, for CSI drivers that opt in&lt;/td&gt;
&lt;td&gt;On SELinux nodes, 2 Pods with different labels sharing a volume can fail to start&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Debug a PVC: 11 symptoms and the first command
&lt;/h2&gt;

&lt;p&gt;Start with &lt;code&gt;kubectl describe pvc&lt;/code&gt; for a claim and &lt;code&gt;kubectl describe pod&lt;/code&gt; for a Pod. The events at the bottom name the cause.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Likely cause&lt;/th&gt;
&lt;th&gt;First command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Claim Pending: &lt;code&gt;no persistent volumes available for this claim and no storage class is set&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;No default StorageClass, and no pre-created PV that matches&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get storageclass&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claim Pending: &lt;code&gt;waiting for first consumer to be created before binding&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Normal with WaitForFirstConsumer. No Pod uses the claim yet&lt;/td&gt;
&lt;td&gt;Create the Pod&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claim Pending with a &lt;code&gt;ProvisioningFailed&lt;/code&gt; event&lt;/td&gt;
&lt;td&gt;The driver could not create the disk: missing cloud permissions, a quota, a wrong parameter&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pvc data&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod Pending: &lt;code&gt;pod has unbound immediate PersistentVolumeClaims&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The claim is not bound. The problem is on the claim&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pvc data&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod Pending: &lt;code&gt;node(s) didn't match PersistentVolume's node affinity&lt;/code&gt; (before v1.33: &lt;code&gt;node(s) had volume node affinity conflict&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;The disk is in a zone where the Pod cannot run&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe pv&lt;/code&gt;, and compare with the zones of your nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod Pending: &lt;code&gt;node(s) exceed max volume count&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The nodes are at their attach limit&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pod web&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod Pending during a rollout: &lt;code&gt;PersistentVolumeClaim with ReadWriteOncePod access mode already in-use by another pod&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A Deployment with a rolling update and a ReadWriteOncePod claim&lt;/td&gt;
&lt;td&gt;Set &lt;code&gt;strategy.type: Recreate&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod in ContainerCreating: &lt;code&gt;Multi-Attach error for volume&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The disk is still attached to another node: an old Pod is still running, or a node died without detaching. After a node failure, expect about 6 minutes before the disk is force detached&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -o wide&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod in ContainerCreating: a mount that timed out&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;fsGroup&lt;/code&gt; on a volume with a huge number of files&lt;/td&gt;
&lt;td&gt;Set &lt;code&gt;fsGroupChangePolicy: OnRootMismatch&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claim stuck in Terminating&lt;/td&gt;
&lt;td&gt;A Pod still uses it&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe pvc data&lt;/code&gt;, and read the "Used By" line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claim Lost&lt;/td&gt;
&lt;td&gt;The PV object is gone: somebody removed its finalizer to force a delete, or the cluster was restored without it&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pv&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For the Pod-level statuses (CrashLoopBackOff, ImagePullBackOff, OOMKilled), use the table in our &lt;a href="https://meteorops.com/blog/kubernetes-pod" rel="noopener noreferrer"&gt;Kubernetes Pod guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist before a volume takes real data
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The claim names its StorageClass, or you checked which class is the default&lt;/li&gt;
&lt;li&gt;The class uses WaitForFirstConsumer&lt;/li&gt;
&lt;li&gt;The class has &lt;code&gt;allowVolumeExpansion: true&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The reclaim policy is a decision: Retain for data you cannot recreate&lt;/li&gt;
&lt;li&gt;The access mode is ReadWriteOncePod where 1 writer is the assumption&lt;/li&gt;
&lt;li&gt;A Deployment with a ReadWriteOnce or ReadWriteOncePod claim uses the Recreate strategy, or it is a StatefulSet&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fsGroupChangePolicy: OnRootMismatch&lt;/code&gt; is set next to &lt;code&gt;fsGroup&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Each zone has enough node capacity for the Pods whose disks live there&lt;/li&gt;
&lt;li&gt;The nodes have room under their volume attach limit&lt;/li&gt;
&lt;li&gt;A ResourceQuota caps storage per namespace&lt;/li&gt;
&lt;li&gt;Backups run outside the volume, and a restore was tested&lt;/li&gt;
&lt;li&gt;An alert fires before the disk is full&lt;/li&gt;
&lt;li&gt;Somebody looks for unused claims and Released volumes every month&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a persistent volume in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;A PersistentVolume (PV) is a piece of storage in the cluster whose life does not depend on any Pod. It points at a real disk or file share, and a Pod uses it through a PersistentVolumeClaim.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a PV and a PVC?
&lt;/h3&gt;

&lt;p&gt;A PVC is a request for storage, written by the app team inside a namespace: a size, an access mode and a class. A PV is the cluster-wide object that represents the real disk. A claim is bound to exactly 1 volume.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does PVC stand for in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;PersistentVolumeClaim. It is the object a Pod refers to when it needs storage that survives the Pod.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a volume and a persistent volume?
&lt;/h3&gt;

&lt;p&gt;A volume is a directory mounted into a Pod. Some volume types, like &lt;code&gt;emptyDir&lt;/code&gt;, are deleted with the Pod. A persistent volume is a separate object that stays when the Pod is deleted.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I create a persistent volume in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;On a cluster with a StorageClass, you create a PersistentVolumeClaim and the volume is created for you. Creating a PV by hand is only needed for storage that already exists, like an NFS share.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is my PVC stuck in Pending?
&lt;/h3&gt;

&lt;p&gt;The 3 common causes: the cluster has no default StorageClass, the class uses WaitForFirstConsumer and no Pod uses the claim yet, or the driver failed to create the disk. &lt;code&gt;kubectl describe pvc&lt;/code&gt; shows which one in its events.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to the data when I delete a PVC?
&lt;/h3&gt;

&lt;p&gt;It depends on the reclaim policy of the volume. With Delete, the default for dynamically created volumes, the disk and the data are deleted. With Retain, the volume moves to Released and the data stays.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can 2 Pods use the same PVC?
&lt;/h3&gt;

&lt;p&gt;Yes, when they are in the same namespace and the access mode allows it. With ReadWriteOnce they have to run on the same node. With ReadWriteMany they can run on different nodes. With ReadWriteOncePod only 1 Pod can use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  A recap
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing, let it be this: the claim is yours, the disk is the cloud's, and the StorageClass is the contract between them.&lt;/p&gt;

&lt;p&gt;Everything in this guide follows from that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A claim asks, a volume records, a class creates&lt;/li&gt;
&lt;li&gt;The access mode counts nodes, except ReadWriteOncePod&lt;/li&gt;
&lt;li&gt;The binding mode picks the zone&lt;/li&gt;
&lt;li&gt;The reclaim policy decides if a deleted claim is a deleted database&lt;/li&gt;
&lt;li&gt;Claims outlive workloads, and so does the bill&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can set all of this up yourself with the YAML and the checklist above.&lt;/p&gt;

&lt;p&gt;If you would like a second pair of eyes on your storage setup, get a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt;. Next reads: &lt;a href="https://meteorops.com/blog/kubernetes-statefulset" rel="noopener noreferrer"&gt;Kubernetes StatefulSet&lt;/a&gt;, &lt;a href="https://meteorops.com/blog/kubernetes-pod" rel="noopener noreferrer"&gt;Kubernetes Pod&lt;/a&gt; and &lt;a href="https://meteorops.com/blog/kubernetes-deployment" rel="noopener noreferrer"&gt;Kubernetes Deployment&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes StatefulSet: What It Guarantees, When to Use It</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Fri, 04 Dec 2026 15:30:10 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-statefulset-what-it-guarantees-when-to-use-it-1eaj</link>
      <guid>https://dev.to/meteorops/kubernetes-statefulset-what-it-guarantees-when-to-use-it-1eaj</guid>
      <description>&lt;p&gt;A Kubernetes StatefulSet runs a group of Pods where each Pod keeps its own name and its own volume. It is what you use for databases, queues and anything else where Pod number 2 cannot stand in for Pod number 0. 5 things to know before you run one:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;StatefulSet = Pods with a fixed name and their own volume.&lt;/strong&gt; web-0 stays web-0 after every restart, and it gets the same disk back&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The order is fixed.&lt;/strong&gt; Pods are created from 0 up, removed from the top down, and updated from the top down, 1 at a time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The volumes outlive the Pods.&lt;/strong&gt; Scale down or delete the StatefulSet and the PersistentVolumeClaims stay, and so does the bill, until you delete them or set a retention policy&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A StatefulSet does NOT replicate your data.&lt;/strong&gt; It gives each Pod an identity and a disk. Replication, failover and backups are the job of the app or of an Operator&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If the Pods are interchangeable, use a Deployment.&lt;/strong&gt; A StatefulSet is slower to roll and harder to repair, so use it only when you need what it gives&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A small StatefulSet to start from, on Kubernetes v1.37:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;clusterIP&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;None&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StatefulSet&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;serviceName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.29&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
        &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;www&lt;/span&gt;
          &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/usr/share/nginx/html&lt;/span&gt;
  &lt;span class="na"&gt;volumeClaimTemplates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;www&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ReadWriteOnce"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 5 commands you will use most:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply -f web.yaml
kubectl get sts web
kubectl get pods -l &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nginx
kubectl get pvc
kubectl rollout status sts/web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A database on Kubernetes that nobody wants to touch on release day?&lt;/strong&gt; Get a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt;: a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are choosing between the 2: &lt;a href="https://meteorops.com/blog/kubernetes-statefulset#statefulset-vs-deployment" rel="noopener noreferrer"&gt;StatefulSet vs Deployment&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are writing a manifest: &lt;a href="https://meteorops.com/blog/kubernetes-statefulset#a-statefulset-yaml-for-production" rel="noopener noreferrer"&gt;a StatefulSet YAML for production&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You scaled down and the disks are still there: &lt;a href="https://meteorops.com/blog/kubernetes-statefulset#the-volumes-outlive-the-pods" rel="noopener noreferrer"&gt;the volumes outlive the Pods&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A rollout is stuck on 1 Pod: &lt;a href="https://meteorops.com/blog/kubernetes-statefulset#rolling-updates-go-from-the-last-pod-to-the-first" rel="noopener noreferrer"&gt;a stuck rollout needs 2 fixes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A node died and the Pod did not come back: &lt;a href="https://meteorops.com/blog/kubernetes-statefulset#when-a-node-dies-the-pod-is-not-replaced" rel="noopener noreferrer"&gt;when a node dies&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Something is broken right now: &lt;a href="https://meteorops.com/blog/kubernetes-statefulset#debug-a-statefulset-7-symptoms-and-the-first-command" rel="noopener noreferrer"&gt;7 symptoms and the first command&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A StatefulSet gives each Pod a name it keeps
&lt;/h2&gt;

&lt;p&gt;A Deployment treats its Pods as copies. A StatefulSet treats them as individuals.&lt;/p&gt;

&lt;p&gt;Every Pod in a StatefulSet gets an identity made of 3 things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;An ordinal:&lt;/strong&gt; a number from 0 to replicas minus 1&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A stable name:&lt;/strong&gt; the StatefulSet name plus the ordinal, so &lt;code&gt;web-0&lt;/code&gt;, &lt;code&gt;web-1&lt;/code&gt;, &lt;code&gt;web-2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stable storage:&lt;/strong&gt; its own PersistentVolumeClaim, created from a template&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Identity = ordinal + name + volume. It sticks to the Pod, whichever node the Pod lands on.&lt;/p&gt;

&lt;p&gt;Delete web-1 and the new Pod is web-1 again, with the same volume.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3iaae409ox9bdpzoow9m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3iaae409ox9bdpzoow9m.jpg" alt="A Kubernetes StatefulSet gives each Pod a fixed name and its own volume: a headless Service named nginx in front of Pods web-0, web-1 and web-2, each bound to its own claim www-web-0, www-web-1 and www-web-2" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A fixed name and 1 volume per Pod.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The name is also a DNS name. This is what the headless Service is for.&lt;/p&gt;

&lt;p&gt;A headless Service is a Service with &lt;code&gt;clusterIP: None&lt;/code&gt;. It has no virtual IP and does no load balancing. It only publishes DNS records for the Pods behind it.&lt;/p&gt;

&lt;p&gt;With a headless Service called &lt;code&gt;nginx&lt;/code&gt; in the &lt;code&gt;default&lt;/code&gt; namespace, each Pod gets its own address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;web-0.nginx.default.svc.cluster.local
web-1.nginx.default.svc.cluster.local
web-2.nginx.default.svc.cluster.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pattern is &lt;code&gt;$(pod name).$(service name).$(namespace).svc.cluster.local&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So a replica can always reach web-0 at &lt;code&gt;web-0.nginx&lt;/code&gt;, and a client can pick the exact Pod it wants to write to.&lt;/p&gt;

&lt;p&gt;4 details that save time later:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You create the headless Service yourself. The StatefulSet points at it with &lt;code&gt;serviceName&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The Pod IP can change after a restart. The name does not. Connect by name&lt;/li&gt;
&lt;li&gt;Clients that are happy with any healthy Pod can use a second, normal ClusterIP Service over the same Pods&lt;/li&gt;
&lt;li&gt;A new Pod's DNS name may not resolve right away. A lookup made before the Pod exists gets cached as a miss (CoreDNS caches for 30 seconds)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each Pod also gets 2 labels you can select on:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Use it for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;statefulset.kubernetes.io/pod-name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;web-0&lt;/td&gt;
&lt;td&gt;A Service that targets 1 Pod&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;apps.kubernetes.io/pod-index&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Routing or filtering logs and metrics by ordinal (stable since v1.32)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The numbering starts at 0. You can change that with &lt;code&gt;spec.ordinals.start&lt;/code&gt; (stable since v1.31), which helps when you move replicas from one StatefulSet to another.&lt;/p&gt;

&lt;h2&gt;
  
  
  StatefulSet vs Deployment
&lt;/h2&gt;

&lt;p&gt;The 2 use the same Pod template. The difference is what happens around the Pods.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Deployment&lt;/th&gt;
&lt;th&gt;StatefulSet&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod names&lt;/td&gt;
&lt;td&gt;Random suffix, new on every replacement&lt;/td&gt;
&lt;td&gt;Fixed: web-0, web-1, web-2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods are&lt;/td&gt;
&lt;td&gt;Interchangeable&lt;/td&gt;
&lt;td&gt;Individuals&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Storage&lt;/td&gt;
&lt;td&gt;All replicas share the same claim&lt;/td&gt;
&lt;td&gt;1 claim per Pod, from a template&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS&lt;/td&gt;
&lt;td&gt;1 name for the Service&lt;/td&gt;
&lt;td&gt;1 name per Pod, through a headless Service&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create and scale&lt;/td&gt;
&lt;td&gt;Any order, in parallel&lt;/td&gt;
&lt;td&gt;0 first, 1 at a time (by default)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rolling update&lt;/td&gt;
&lt;td&gt;New Pods alongside old ones: 25% surge and 25% unavailable by default&lt;/td&gt;
&lt;td&gt;Highest ordinal first, the old Pod stops before the new one starts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;In between&lt;/td&gt;
&lt;td&gt;A ReplicaSet per revision&lt;/td&gt;
&lt;td&gt;Nothing. The StatefulSet manages the Pods directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rollback&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout undo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl rollout undo&lt;/code&gt;, plus manual work if a Pod is stuck&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Good for&lt;/td&gt;
&lt;td&gt;APIs, web apps, workers&lt;/td&gt;
&lt;td&gt;Databases, queues, search clusters, anything with a quorum&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Kubernetes docs list 4 reasons to pick a StatefulSet:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stable, unique network identifiers&lt;/li&gt;
&lt;li&gt;Stable, persistent storage&lt;/li&gt;
&lt;li&gt;Ordered, graceful deployment and scaling&lt;/li&gt;
&lt;li&gt;Ordered, automated rolling updates&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My rule: if you need 0 of the 4, use a Deployment.&lt;/p&gt;

&lt;p&gt;(A StatefulSet for a stateless API is a Deployment with extra waiting.)&lt;/p&gt;

&lt;p&gt;The same docs say it directly: if an app does not need stable identifiers or ordered deployment, deletion or scaling, deploy it with a Deployment or a ReplicaSet.&lt;/p&gt;

&lt;h3&gt;
  
  
  1 database Pod with 1 disk can be a Deployment
&lt;/h3&gt;

&lt;p&gt;A single-instance database does not need ordinals.&lt;/p&gt;

&lt;p&gt;A Deployment with 1 replica and 1 PersistentVolumeClaim works, with 2 conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Do not scale it.&lt;/strong&gt; Every replica of a Deployment mounts the same claim&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set &lt;code&gt;strategy.type: Recreate&lt;/code&gt;.&lt;/strong&gt; With 1 replica, the default rolling update starts the new Pod before it stops the old one. With a ReadWriteOnce volume the new Pod can wait for the disk forever while the old Pod waits for the new one&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I still use a StatefulSet with 1 replica for this. The old Pod always stops before the new one starts, and adding a replica later does not mean a migration.&lt;/p&gt;

&lt;p&gt;And a DaemonSet is a different thing: 1 Pod per node, for node-level agents such as log collectors.&lt;/p&gt;

&lt;h2&gt;
  
  
  A StatefulSet YAML for production
&lt;/h2&gt;

&lt;p&gt;The small manifest at the top is enough for a first try. This one adds what I set before real data goes in.&lt;/p&gt;

&lt;p&gt;If you applied the first one, delete that StatefulSet and its claims before you apply this one: the volume template cannot be changed in place.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StatefulSet&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;serviceName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;minReadySeconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
  &lt;span class="na"&gt;podManagementPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;OrderedReady&lt;/span&gt;
  &lt;span class="na"&gt;updateStrategy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;RollingUpdate&lt;/span&gt;
    &lt;span class="na"&gt;rollingUpdate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;partition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="na"&gt;persistentVolumeClaimRetentionPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;whenDeleted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Retain&lt;/span&gt;
    &lt;span class="na"&gt;whenScaled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Retain&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;terminationGracePeriodSeconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
      &lt;span class="na"&gt;affinity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;podAntiAffinity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;requiredDuringSchedulingIgnoredDuringExecution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;labelSelector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
            &lt;span class="na"&gt;topologyKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kubernetes.io/hostname&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.29&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
        &lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;tcpSocket&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
        &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;100m&lt;/span&gt;
            &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;128Mi&lt;/span&gt;
          &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;128Mi&lt;/span&gt;
        &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;www&lt;/span&gt;
          &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/usr/share/nginx/html&lt;/span&gt;
  &lt;span class="na"&gt;volumeClaimTemplates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;www&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ReadWriteOncePod"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;storageClassName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-storage-class&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;my-storage-class&lt;/code&gt; with a class from &lt;code&gt;kubectl get storageclass&lt;/code&gt;. With a name that does not exist, the claims and the Pods stay Pending.&lt;/p&gt;

&lt;p&gt;The probe here only checks that nginx listens on port 80. For a real database, use a probe that checks that the member has joined and caught up.&lt;/p&gt;

&lt;p&gt;What each part does:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;serviceName&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;The headless Service that gives the Pods their DNS names&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;replicas&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;How many Pods. Leave it out when a HorizontalPodAutoscaler owns the number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;selector&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;required&lt;/td&gt;
&lt;td&gt;Must match the labels in the Pod template, or the API rejects the object&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;minReadySeconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;How long a Pod must stay Ready before it counts as available and the rollout moves on&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;podManagementPolicy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;OrderedReady&lt;/td&gt;
&lt;td&gt;OrderedReady or Parallel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;updateStrategy.type&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;RollingUpdate&lt;/td&gt;
&lt;td&gt;RollingUpdate, OnDelete, or Recreate (alpha in v1.37)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rollingUpdate.partition&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Only Pods with this ordinal or higher get updated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rollingUpdate.maxUnavailable&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;How many Pods may be down during an update&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;revisionHistoryLimit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;How many old revisions to keep for rollback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;persistentVolumeClaimRetentionPolicy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Retain, Retain&lt;/td&gt;
&lt;td&gt;What happens to the claims on delete and on scale down&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;volumeClaimTemplates&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;The template for each Pod's claim&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;3 choices in this manifest are worth explaining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ReadWriteOncePod:&lt;/strong&gt; ReadWriteOnce allows 1 node, and several Pods on that node can still mount the volume. ReadWriteOncePod allows 1 Pod in the whole cluster. The Kubernetes project recommends it for production. It needs a CSI driver&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pod anti-affinity on the hostname:&lt;/strong&gt; by default 2 replicas can land on the same node, and then 1 node failure takes both. With the required rule and too few nodes, the extra Pods stay Pending&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A termination grace period above 0:&lt;/strong&gt; the docs call a value of 0 "unsafe and strongly discouraged" for StatefulSet Pods. Give the app time to flush and close&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Pod template has 1 hard rule: &lt;code&gt;restartPolicy&lt;/code&gt; must be Always.&lt;/p&gt;

&lt;h2&gt;
  
  
  The volumes outlive the Pods
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;volumeClaimTemplates&lt;/code&gt; is the part a Deployment does not have.&lt;/p&gt;

&lt;p&gt;For every Pod, the StatefulSet creates 1 PersistentVolumeClaim per template. The names follow the template name, the StatefulSet name and the ordinal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;www-web-0
www-web-1
www-web-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What happens to a claim:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Pod restarts or moves to another node:&lt;/strong&gt; same claim, same data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You delete the Pod:&lt;/strong&gt; the new Pod with the same name gets the same claim&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You scale down:&lt;/strong&gt; the Pod goes, the claim stays&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You delete the StatefulSet:&lt;/strong&gt; the Pods go, the claims stay&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scale from 3 to 1 and you still have 3 claims and 3 volumes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpuoqltnczp5bwrm35zrl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpuoqltnczp5bwrm35zrl.jpg" alt="Scaling a Kubernetes StatefulSet down from 3 to 1: Pods web-1 and web-2 are deleted, and their volumes www-web-1 and www-web-2 are still there and still billed" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The Pods go. The volumes and the bill stay.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is on purpose. The docs put it under "Limitations" and give the reason: data safety is worth more than an automatic purge.&lt;/p&gt;

&lt;p&gt;It has 2 consequences:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;You pay for disks that no Pod uses.&lt;/strong&gt; List them with &lt;code&gt;kubectl get pvc&lt;/code&gt; after every scale down&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Old data comes back.&lt;/strong&gt; Scale up again and web-1 gets www-web-1, with whatever was on it. A replica that rejoins with stale data is a surprise for some databases&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Let Kubernetes delete the claims for you
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;persistentVolumeClaimRetentionPolicy&lt;/code&gt; is stable since v1.32. It has 2 settings:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;When it applies&lt;/th&gt;
&lt;th&gt;Retain (default)&lt;/th&gt;
&lt;th&gt;Delete&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;whenDeleted&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The StatefulSet is deleted&lt;/td&gt;
&lt;td&gt;Claims stay&lt;/td&gt;
&lt;td&gt;All claims from the template are deleted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;whenScaled&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Replicas go down&lt;/td&gt;
&lt;td&gt;Claims stay&lt;/td&gt;
&lt;td&gt;Only the claims of the removed Pods are deleted&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The policy never fires when a Pod is replaced after a node failure. The new Pod keeps the claim.&lt;/p&gt;

&lt;p&gt;When / Use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A database you care about:&lt;/strong&gt; Retain and Retain. Clean up by hand&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A cache or a test environment:&lt;/strong&gt; Delete and Delete&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A cluster that rebuilds replicas from peers:&lt;/strong&gt; &lt;code&gt;whenDeleted: Retain&lt;/code&gt;, &lt;code&gt;whenScaled: Delete&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1 more layer sits below this. When a claim is deleted, the reclaim policy of its volume decides what happens to the disk. The volume gets that policy from the StorageClass when it is created. Dynamically provisioned volumes default to Delete, which removes the cloud disk too.&lt;/p&gt;

&lt;p&gt;Deleted claim + reclaim policy Delete = the data is gone.&lt;/p&gt;
&lt;h3&gt;
  
  
  You cannot edit volumeClaimTemplates
&lt;/h3&gt;

&lt;p&gt;4 fields of a StatefulSet are immutable in v1.37: &lt;code&gt;selector&lt;/code&gt;, &lt;code&gt;volumeClaimTemplates&lt;/code&gt;, &lt;code&gt;serviceName&lt;/code&gt; and &lt;code&gt;podManagementPolicy&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So you cannot grow the disks by changing the template.&lt;/p&gt;

&lt;p&gt;To resize, edit each PersistentVolumeClaim to a larger size. This works when the StorageClass has &lt;code&gt;allowVolumeExpansion: true&lt;/code&gt; and the driver supports it. A claim in use is resized without recreating the Pod.&lt;/p&gt;

&lt;p&gt;The template keeps the old size, so Pods you add later start with the old size. We wrote the full procedure in &lt;a href="https://meteorops.com/blog/how-to-resize-kubernetes-persistent-volumes-without-downtime" rel="noopener noreferrer"&gt;how to resize Kubernetes persistent volumes without downtime&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;(A proposal to make the template editable exists as KEP-4650. As of v1.37 it has not shipped.)&lt;/p&gt;
&lt;h2&gt;
  
  
  The order: up from 0, down from the top
&lt;/h2&gt;

&lt;p&gt;With the default policy, OrderedReady, a StatefulSet does 1 thing at a time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Create and scale up:&lt;/strong&gt; web-0, then web-1, then web-2&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scale down:&lt;/strong&gt; web-2, then web-1, then web-0&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rolling update:&lt;/strong&gt; web-2, then web-1, then web-0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each Pod must be Running and Ready before the next one starts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg1yhg618j9omp60wfovv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg1yhg618j9omp60wfovv.jpg" alt="Kubernetes StatefulSet order: Pods are created and scaled up from web-0 to web-2, scaled down and deleted from web-2 to web-0, and rolling updates also go from web-2 to web-0" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Up from 0, down from the top, 1 at a time.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Before a Pod is removed, every Pod above it must be fully shut down.&lt;/p&gt;

&lt;p&gt;This is useful for a database: the primary starts first, and a replica starts only when it has something to copy from.&lt;/p&gt;

&lt;p&gt;It also means 1 broken Pod blocks everything behind it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;web-0 fails while web-1 is up: web-2 is not created until web-0 is Running and Ready again&lt;/li&gt;
&lt;li&gt;Any Pod is unhealthy: you cannot scale down&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why block the scale down? Kubernetes cannot tell a permanent fault from a short one, and removing healthy members on top of a sick one can drop a cluster below its minimum.&lt;/p&gt;
&lt;h3&gt;
  
  
  Parallel: identity without the waiting
&lt;/h3&gt;

&lt;p&gt;Some systems need the names and the disks, and do not care about the order.&lt;/p&gt;

&lt;p&gt;For those, set &lt;code&gt;podManagementPolicy: Parallel&lt;/code&gt;. The StatefulSet then starts and stops all Pods at once and does not wait for 1 to be Ready before the next.&lt;/p&gt;

&lt;p&gt;2 things to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The field is immutable. Choose before you create the StatefulSet&lt;/li&gt;
&lt;li&gt;In v1.37 it also changes rolling updates: with &lt;code&gt;maxUnavailable&lt;/code&gt; above 1, up to that many Pods are replaced at the same time&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Rolling updates go from the last Pod to the first
&lt;/h2&gt;

&lt;p&gt;Change the Pod template and the StatefulSet starts a rolling update.&lt;/p&gt;

&lt;p&gt;It deletes the Pod with the highest ordinal, creates it again from the new template, waits until it is Running and Ready (plus &lt;code&gt;minReadySeconds&lt;/code&gt;), then moves to the next one down.&lt;/p&gt;

&lt;p&gt;A Deployment adds new Pods first. A StatefulSet cannot: only 1 web-2 may exist at a time. So every update takes each Pod down for a moment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;set&lt;/span&gt; image sts/web &lt;span class="nv"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nginx:1.29.1
kubectl rollout status sts/web
kubectl rollout &lt;span class="nb"&gt;history&lt;/span&gt; sts/web
kubectl rollout undo sts/web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 3 strategies:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;Use it when&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RollingUpdate (default)&lt;/td&gt;
&lt;td&gt;Replaces Pods from the highest ordinal down&lt;/td&gt;
&lt;td&gt;Almost always&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OnDelete&lt;/td&gt;
&lt;td&gt;Does nothing until you delete a Pod yourself&lt;/td&gt;
&lt;td&gt;You or an Operator must control the exact order&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recreate (alpha in v1.37, off by default)&lt;/td&gt;
&lt;td&gt;Deletes all Pods, then creates the new ones&lt;/td&gt;
&lt;td&gt;Versions cannot run side by side and downtime is fine&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;maxUnavailable&lt;/code&gt; lets an update take more than 1 Pod at a time. It is beta and on by default in v1.37, and its default value is 1.&lt;/p&gt;

&lt;p&gt;It had a bumpy road: on in v1.35.0, switched off from v1.35.4 through v1.36 because of a regression, and on again in v1.37. The API reference also says it "might not be effective" with OrderedReady, so it mostly matters with Parallel.&lt;/p&gt;

&lt;h3&gt;
  
  
  A canary with partition
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;partition&lt;/code&gt; splits the Pods in 2 groups.&lt;/p&gt;

&lt;p&gt;Pods with an ordinal at or above the partition get the new template. Pods below it stay on the old one, even if they are deleted and recreated.&lt;/p&gt;

&lt;p&gt;With 4 replicas, &lt;code&gt;partition: 2&lt;/code&gt; updates only web-2 and web-3.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd8qbl5a9nlslj3rla4jc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd8qbl5a9nlslj3rla4jc.jpg" alt="A StatefulSet rolling update with partition 2 on 4 replicas: web-2 and web-3 get the new version, web-0 and web-1 stay on the old version" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Lower the partition to 0 to finish the rollout.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A canary on a 3 replica StatefulSet, step by step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Park the rollout: a partition above the last ordinal&lt;/span&gt;
kubectl patch statefulset web -p &lt;span class="s1"&gt;'{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":3}}}}'&lt;/span&gt;

&lt;span class="c"&gt;# 2. Change the template. Nothing rolls yet&lt;/span&gt;
kubectl &lt;span class="nb"&gt;set&lt;/span&gt; image sts/web &lt;span class="nv"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nginx:1.29.1

&lt;span class="c"&gt;# 3. Canary: only web-2 gets the new version&lt;/span&gt;
kubectl patch statefulset web -p &lt;span class="s1"&gt;'{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":2}}}}'&lt;/span&gt;

&lt;span class="c"&gt;# 4. Happy with it? Finish the rollout&lt;/span&gt;
kubectl patch statefulset web -p &lt;span class="s1"&gt;'{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":0}}}}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lower the partition 1 step at a time for a phased rollout.&lt;/p&gt;

&lt;p&gt;For a database, think about which Pod is the canary. In setups that keep the primary at ordinal 0, the highest ordinal is a replica, which is what you want to test first. If your database can fail over, check who is primary before you start.&lt;/p&gt;

&lt;h3&gt;
  
  
  A stuck rollout needs 2 fixes
&lt;/h3&gt;

&lt;p&gt;This is the trap that most StatefulSet guides skip.&lt;/p&gt;

&lt;p&gt;You push a template with a bad image or a config that never becomes Ready. The rollout replaces web-2, web-2 never gets Ready, and the StatefulSet stops and waits.&lt;/p&gt;

&lt;p&gt;So you revert the template. And nothing happens.&lt;/p&gt;

&lt;p&gt;Why? Because of a known issue: the StatefulSet keeps waiting for the broken Pod to become Ready before it applies the good template to it. (It never becomes Ready.) The docs describe this for the default OrderedReady policy.&lt;/p&gt;

&lt;p&gt;The fix has 2 steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Revert the template: &lt;code&gt;kubectl rollout undo sts/web&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Delete the Pods that started with the bad template: &lt;code&gt;kubectl delete pod web-2&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The StatefulSet then recreates them from the good template.&lt;/p&gt;

&lt;p&gt;Stuck rollout fix = revert + delete the broken Pod.&lt;/p&gt;

&lt;h3&gt;
  
  
  How rollback works
&lt;/h3&gt;

&lt;p&gt;Every template change is saved as a ControllerRevision object. The StatefulSet keeps 10 by default (&lt;code&gt;revisionHistoryLimit&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl rollout &lt;span class="nb"&gt;history&lt;/span&gt; statefulset/web
kubectl rollout undo statefulset/web --to-revision=3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A rollback applies the old Pod template as a new revision.&lt;/p&gt;

&lt;p&gt;It rolls back the template only. The data on the volumes stays as the new version left it, so a rollback after a schema migration is a database problem, and Kubernetes will not solve it for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scale and delete without losing data
&lt;/h2&gt;

&lt;p&gt;Scaling is 1 command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl scale sts web --replicas=5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 things to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;replicas&lt;/code&gt; is in your manifest, the next &lt;code&gt;kubectl apply&lt;/code&gt; sets it back. Change the number in Git&lt;/li&gt;
&lt;li&gt;A HorizontalPodAutoscaler can scale a StatefulSet. Remove &lt;code&gt;spec.replicas&lt;/code&gt; from the manifest when it does&lt;/li&gt;
&lt;li&gt;Scaling adds a Pod. It does not tell your database that a new member exists. That part is on the app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Deleting has more ways to go wrong.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Delete the StatefulSet and its Pods&lt;/span&gt;
kubectl delete statefulset web

&lt;span class="c"&gt;# Delete only the StatefulSet object and keep the Pods running&lt;/span&gt;
kubectl delete statefulset web --cascade=orphan

&lt;span class="c"&gt;# The claims, when you are sure&lt;/span&gt;
kubectl delete pvc -l &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What to expect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The headless Service is not deleted. Remove it separately&lt;/li&gt;
&lt;li&gt;The claims are not deleted, unless &lt;code&gt;whenDeleted&lt;/code&gt; is Delete&lt;/li&gt;
&lt;li&gt;The docs give no guarantee on how the Pods are terminated when the StatefulSet is deleted. For an ordered shutdown, scale to 0 first and delete after (with &lt;code&gt;whenScaled: Delete&lt;/code&gt; this removes the claims as well)&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;--cascade=orphan&lt;/code&gt; the Pods keep running, and a StatefulSet you create again with the same selector adopts them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Take the backup, and test that it restores&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;whenScaled&lt;/code&gt;: if it is Delete, scaling to 0 deletes every claim&lt;/li&gt;
&lt;li&gt;Scale to 0&lt;/li&gt;
&lt;li&gt;Delete the StatefulSet&lt;/li&gt;
&lt;li&gt;Delete the claims last&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When a node dies, the Pod is not replaced
&lt;/h2&gt;

&lt;p&gt;This surprises teams that are used to Deployments.&lt;/p&gt;

&lt;p&gt;A Deployment replaces the Pods of a dead node after a few minutes. A StatefulSet does not.&lt;/p&gt;

&lt;p&gt;The reason is the rule that the whole thing is built on: at most 1 Pod per identity at any time.&lt;/p&gt;

&lt;p&gt;When a node stops answering, Kubernetes cannot know if the Pod is dead or just cut off from the network. If it started a second web-0 and the first one was still writing, 2 Pods would write to the same data. That is split brain.&lt;/p&gt;

&lt;p&gt;So the Pod on the unreachable node shows Terminating or Unknown, and it stays that way until 1 of 3 things happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Node object is deleted (by you or by the cloud's node controller)&lt;/li&gt;
&lt;li&gt;The kubelet on the node comes back and stops the Pod&lt;/li&gt;
&lt;li&gt;Someone force deletes the Pod&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On a managed cloud, number 1 usually happens for you when the instance is terminated.&lt;/p&gt;

&lt;p&gt;On bare metal, or when the instance is stuck, you do it. If the node is powered off for sure, mark it out of service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl taint nodes NODE_NAME node.kubernetes.io/out-of-service=nodeshutdown:NoExecute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This force deletes the Pods on that node and detaches their volumes at once, so the StatefulSet can create them elsewhere. The feature is stable since v1.28. Remove the taint yourself when the node is back.&lt;/p&gt;

&lt;p&gt;The last resort is the force delete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl delete pods web-0 --grace-period=0 --force
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this command you promise Kubernetes that the old Pod will never talk to its peers again. If you are wrong, you get a duplicate identity and possibly data loss. The docs say that normal operation never needs it.&lt;/p&gt;

&lt;p&gt;1 more thing ties a Pod to a place: the disk. EBS volumes, GKE zonal disks and locally redundant Azure disks live in 1 zone. A Pod with such a volume can only run in that zone. If the zone has no room, the Pod stays Pending.&lt;/p&gt;

&lt;h2&gt;
  
  
  A StatefulSet does NOT run your database
&lt;/h2&gt;

&lt;p&gt;StatefulSet = identity + disk + order.&lt;/p&gt;

&lt;p&gt;It does not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy data between Pods&lt;/li&gt;
&lt;li&gt;Pick a new primary when the old one dies&lt;/li&gt;
&lt;li&gt;Add or remove members from the cluster config&lt;/li&gt;
&lt;li&gt;Back anything up&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The official tutorials show how much is left to you. The MySQL example uses an init container to turn the ordinal into a server ID, treats ordinal 0 as the primary, and clones each new replica from the Pod before it with Percona XtraBackup. The docs add that it is not a production configuration.&lt;/p&gt;

&lt;p&gt;The same goes for Cassandra (seed nodes found by the DNS name of cassandra-0) and ZooKeeper (the member list is written into the config).&lt;/p&gt;

&lt;p&gt;This gap is what Operators fill. An Operator is a controller that knows 1 application: it can run backups and restores, do upgrades and, for some applications, pick a new leader.&lt;/p&gt;

&lt;p&gt;Some Operators manage a StatefulSet for you. And some left StatefulSets behind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CloudNativePG&lt;/strong&gt; (PostgreSQL) manages Pods and claims directly, with no StatefulSet. Its reasons include that 1 template serves all Pods and that resizing claims is a known StatefulSet limitation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strimzi&lt;/strong&gt; (Kafka) replaced StatefulSets with its own StrimziPodSet and removed StatefulSet support in 0.35.0. 1 of its reasons: in a StatefulSet only the Pod with the highest ordinal can be removed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How I decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The cloud has it as a managed service and you have no reason to say no:&lt;/strong&gt; use the managed service&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A mature Operator exists:&lt;/strong&gt; use the Operator and let it decide what is underneath&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Neither:&lt;/strong&gt; a StatefulSet, and you own replication, failover and backups&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Keep the quorum during node maintenance
&lt;/h2&gt;

&lt;p&gt;A 3 member ZooKeeper needs 2 healthy members to accept writes. Most clustered databases have a rule like it.&lt;/p&gt;

&lt;p&gt;The rolling update respects this on its own: 1 Pod at a time.&lt;/p&gt;

&lt;p&gt;A node drain does not. Draining 2 nodes at once can evict 2 members. A PodDisruptionBudget stops that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;policy/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PodDisruptionBudget&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;maxUnavailable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For quorum apps the docs suggest &lt;code&gt;maxUnavailable: 1&lt;/code&gt;, or &lt;code&gt;minAvailable&lt;/code&gt; set to the quorum size. I use maxUnavailable, because it stays correct when the replica count changes.&lt;/p&gt;

&lt;p&gt;A PodDisruptionBudget guards evictions such as drains. It does not limit the StatefulSet's own rolling update.&lt;/p&gt;

&lt;p&gt;Always, for anything with a quorum:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A PodDisruptionBudget with &lt;code&gt;maxUnavailable: 1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Anti-affinity or topology spread, so 2 members do not share a node or a zone&lt;/li&gt;
&lt;li&gt;A readiness probe that passes only when the member has joined and caught up&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Storage classes on EKS, GKE and AKS
&lt;/h2&gt;

&lt;p&gt;A volumeClaimTemplate with no &lt;code&gt;storageClassName&lt;/code&gt; uses the cluster's default StorageClass. A cluster can have none, and then the claims stay Pending.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cloud&lt;/th&gt;
&lt;th&gt;What you get&lt;/th&gt;
&lt;th&gt;Watch for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;EKS&lt;/td&gt;
&lt;td&gt;The EBS CSI driver is an add-on you install. On EKS Auto Mode the storage capability is built in&lt;/td&gt;
&lt;td&gt;Auto Mode does not create a StorageClass. You create one (AWS's example uses gp3 and WaitForFirstConsumer)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GKE&lt;/td&gt;
&lt;td&gt;GKE's docs give &lt;code&gt;standard-rwo&lt;/code&gt; as the default for ReadWriteOnce claims. It uses WaitForFirstConsumer&lt;/td&gt;
&lt;td&gt;Check with &lt;code&gt;kubectl get storageclass&lt;/code&gt; on a Standard cluster. Zonal disks: the Pod is scheduled to the disk's zone&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AKS&lt;/td&gt;
&lt;td&gt;The default class matches &lt;code&gt;managed-csi&lt;/code&gt;: Standard SSD, expandable, reclaim policy Delete&lt;/td&gt;
&lt;td&gt;A locally redundant disk cannot attach to a node in another zone. From Kubernetes 1.29 the built-in classes use zone-redundant disks in multi-zone clusters&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Check 3 settings on the class before the first Pod starts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;volumeBindingMode: WaitForFirstConsumer&lt;/code&gt;:&lt;/strong&gt; the disk is created after the Pod is scheduled, in the zone where the Pod will run. With Immediate, the disk can land in a zone where the Pod cannot&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;allowVolumeExpansion: true&lt;/code&gt;:&lt;/strong&gt; or you cannot grow the disks later&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;reclaimPolicy&lt;/code&gt;:&lt;/strong&gt; Delete is the default. For data you cannot lose, Retain keeps the disk after the claim is gone&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What changed for StatefulSets from v1.34 to v1.37
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;th&gt;State&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;v1.37&lt;/td&gt;
&lt;td&gt;Recreate update strategy&lt;/td&gt;
&lt;td&gt;Alpha, off by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.37&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;maxUnavailable&lt;/code&gt; for rolling updates&lt;/td&gt;
&lt;td&gt;Beta, on by default again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.37&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe statefulset&lt;/code&gt; shows the Service name, the pod management policy and the claim retention policy&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.36&lt;/td&gt;
&lt;td&gt;Available replicas are counted without delay, so rollouts move faster&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.35.4 and v1.36&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;maxUnavailable&lt;/code&gt; switched off after a regression with Parallel&lt;/td&gt;
&lt;td&gt;Beta, off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.35&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;maxUnavailable&lt;/code&gt; moved to beta&lt;/td&gt;
&lt;td&gt;Beta, on in 1.35.0 to 1.35.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.35&lt;/td&gt;
&lt;td&gt;Fix for a rollout that started by itself during a control plane upgrade from v1.33 to v1.34&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.34&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;minReadySeconds&lt;/code&gt; fix and Pod spec validation on create&lt;/td&gt;
&lt;td&gt;Shipped&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Older, and still missing from most guides: claim retention policy (stable in v1.32), the pod index label (stable in v1.32), start ordinal (stable in v1.31), ReadWriteOncePod (stable in v1.29) and the out-of-service taint (stable in v1.28).&lt;/p&gt;

&lt;h2&gt;
  
  
  Debug a StatefulSet: 7 symptoms and the first command
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Likely cause&lt;/th&gt;
&lt;th&gt;First command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;web-0 is Pending&lt;/td&gt;
&lt;td&gt;The claim is not bound: no default StorageClass, or no matching volume&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pvc www-web-0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;web-0 is Pending and the claim is Bound&lt;/td&gt;
&lt;td&gt;The volume is in a zone with no room, or anti-affinity has no node left&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pod web-0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;web-1 is never created&lt;/td&gt;
&lt;td&gt;web-0 is not Running and Ready&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pod web-0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The rollout hangs on 1 Pod&lt;/td&gt;
&lt;td&gt;The new template never gets Ready&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl rollout status sts/web&lt;/code&gt;, then revert and delete the Pod&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The scale down does nothing&lt;/td&gt;
&lt;td&gt;A Pod in the set is unhealthy&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -l app=nginx&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A Pod is Terminating or Unknown for a long time&lt;/td&gt;
&lt;td&gt;Its node is unreachable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get nodes&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A Pod name does not resolve&lt;/td&gt;
&lt;td&gt;No headless Service, a wrong &lt;code&gt;serviceName&lt;/code&gt;, or the Pod is not Ready yet&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get svc nginx&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For the Pod-level statuses (CrashLoopBackOff, ImagePullBackOff, OOMKilled), use the table in our &lt;a href="https://meteorops.com/blog/kubernetes-pod" rel="noopener noreferrer"&gt;Kubernetes Pod guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist before a StatefulSet takes real data
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A headless Service exists and &lt;code&gt;serviceName&lt;/code&gt; points at it&lt;/li&gt;
&lt;li&gt;The StorageClass is named in the template, with WaitForFirstConsumer and volume expansion on&lt;/li&gt;
&lt;li&gt;The access mode is ReadWriteOncePod where the driver supports it&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;persistentVolumeClaimRetentionPolicy&lt;/code&gt; is a decision, written down&lt;/li&gt;
&lt;li&gt;A readiness probe that reflects the real state of the member&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;terminationGracePeriodSeconds&lt;/code&gt; is long enough for a clean shutdown, and never 0&lt;/li&gt;
&lt;li&gt;Requests and a memory limit are set&lt;/li&gt;
&lt;li&gt;Anti-affinity or topology spread across nodes and zones&lt;/li&gt;
&lt;li&gt;A PodDisruptionBudget with &lt;code&gt;maxUnavailable: 1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Backups run, and a restore was tested&lt;/li&gt;
&lt;li&gt;The team knows the 2 step fix for a stuck rollout&lt;/li&gt;
&lt;li&gt;The team knows what to do when a node dies, and that force delete is the last resort&lt;/li&gt;
&lt;li&gt;Somebody owns replication and failover: the app, an Operator, or a managed service&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a StatefulSet in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;A StatefulSet is the workload object for stateful apps. It runs a group of Pods where each Pod has a fixed name, a stable DNS name and its own PersistentVolumeClaim, and it creates, scales and updates them in a fixed order.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a StatefulSet and a Deployment?
&lt;/h3&gt;

&lt;p&gt;A Deployment runs interchangeable Pods with random names that share any storage. A StatefulSet runs Pods that each keep a name and a volume across restarts, and it changes them 1 at a time in order.&lt;/p&gt;

&lt;h3&gt;
  
  
  When should I use a StatefulSet?
&lt;/h3&gt;

&lt;p&gt;Use it when each replica needs its own disk or its own stable network name: databases, message queues, search clusters, anything with a quorum. If any replica can replace any other, use a Deployment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does a StatefulSet need a headless Service?
&lt;/h3&gt;

&lt;p&gt;For stable DNS names, yes. The headless Service gives every Pod its DNS name, and you create it yourself. The StatefulSet refers to it with &lt;code&gt;serviceName&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to the volumes when I delete a StatefulSet?
&lt;/h3&gt;

&lt;p&gt;They stay. By default the PersistentVolumeClaims and their data survive both a delete and a scale down. Set &lt;code&gt;persistentVolumeClaimRetentionPolicy&lt;/code&gt; to Delete if you want Kubernetes to remove them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I change volumeClaimTemplates after creating the StatefulSet?
&lt;/h3&gt;

&lt;p&gt;No. The field is immutable. To grow the disks, edit each PersistentVolumeClaim, which works when the StorageClass allows volume expansion.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I restart a StatefulSet?
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;kubectl rollout restart statefulset/web&lt;/code&gt;. With the default RollingUpdate strategy the Pods are replaced 1 at a time from the highest ordinal down, and each one gets its volume back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does a StatefulSet replicate data between Pods?
&lt;/h3&gt;

&lt;p&gt;No. It gives each Pod an identity and a disk. Replicating data between them is the job of the application or of an Operator.&lt;/p&gt;

&lt;h2&gt;
  
  
  A recap
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing, let it be this: a StatefulSet keeps names and disks stable, and nothing more.&lt;/p&gt;

&lt;p&gt;Everything in this guide follows from that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fixed names, so members find each other&lt;/li&gt;
&lt;li&gt;1 volume per Pod, so data survives a restart&lt;/li&gt;
&lt;li&gt;A fixed order, so a cluster forms and updates safely&lt;/li&gt;
&lt;li&gt;At most 1 Pod per name, so 2 Pods never write to the same data&lt;/li&gt;
&lt;li&gt;Volumes that stay behind, so a mistake does not delete a database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can set all of this up yourself with the YAML and the checklist above.&lt;/p&gt;

&lt;p&gt;If you would like a second pair of eyes on your stateful workloads, get a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt;. Next reads: &lt;a href="https://meteorops.com/blog/kubernetes-deployment" rel="noopener noreferrer"&gt;Kubernetes Deployment&lt;/a&gt;, &lt;a href="https://meteorops.com/blog/kubernetes-pod" rel="noopener noreferrer"&gt;Kubernetes Pod&lt;/a&gt; and &lt;a href="https://meteorops.com/blog/kubernetes-service" rel="noopener noreferrer"&gt;Kubernetes Service&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes Pod: What It Is, Lifecycle, YAML and Debugging</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Thu, 03 Dec 2026 15:31:46 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-pod-what-it-is-lifecycle-yaml-and-debugging-1g73</link>
      <guid>https://dev.to/meteorops/kubernetes-pod-what-it-is-lifecycle-yaml-and-debugging-1g73</guid>
      <description>&lt;p&gt;A Kubernetes Pod is 1 or more containers that share 1 IP address and 1 set of volumes. It is the smallest thing Kubernetes can run. 5 things to know before you run one:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pod = a wrapper around your containers.&lt;/strong&gt; Kubernetes schedules, starts and stops Pods. It manages your containers through them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Most Pods hold 1 container.&lt;/strong&gt; A second container belongs in the same Pod only when the 2 are tightly coupled, like an app and its log shipper&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You rarely create a Pod yourself.&lt;/strong&gt; A Deployment, StatefulSet, DaemonSet or Job creates Pods from a template and replaces the ones that die&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Pod is NEVER moved to another node.&lt;/strong&gt; It is deleted and a new Pod takes its place, with a new UID and usually a new IP&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The STATUS column in kubectl is a hint.&lt;/strong&gt; A Pod has 5 phases. CrashLoopBackOff, ImagePullBackOff and Terminating are display values that kubectl puts on top of them&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A small Pod that works, on Kubernetes v1.37:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.29&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 5 commands you will use most:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply -f pod.yaml
kubectl get pods -o wide
kubectl describe pod web
kubectl logs web
kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; -it web -- sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Pods that restart all night, or sit in Pending while the release waits?&lt;/strong&gt; Get a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt;: a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Pod is broken right now: &lt;a href="https://meteorops.com/blog/kubernetes-pod#debug-a-pod-8-statuses-and-the-first-command-for-each" rel="noopener noreferrer"&gt;8 statuses and the first command for each&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are writing a manifest: &lt;a href="https://meteorops.com/blog/kubernetes-pod#a-pod-yaml-you-can-copy" rel="noopener noreferrer"&gt;a Pod YAML you can copy&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A Pod keeps restarting: &lt;a href="https://meteorops.com/blog/kubernetes-pod#what-happens-when-a-container-crashes" rel="noopener noreferrer"&gt;what happens when a container crashes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A Pod got killed for memory: &lt;a href="https://meteorops.com/blog/kubernetes-pod#requests-limits-and-what-happens-when-a-pod-goes-over" rel="noopener noreferrer"&gt;requests, limits and going over&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Requests fail during every deploy: &lt;a href="https://meteorops.com/blog/kubernetes-pod#how-a-pod-shuts-down-in-30-seconds" rel="noopener noreferrer"&gt;how a Pod shuts down&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A node has free CPU and still refuses Pods: &lt;a href="https://meteorops.com/blog/kubernetes-pod#how-many-pods-fit-on-a-node" rel="noopener noreferrer"&gt;how many Pods fit on a node&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A Pod is a wrapper around your containers
&lt;/h2&gt;

&lt;p&gt;Kubernetes does not run containers directly. It runs Pods, and each Pod runs your containers.&lt;/p&gt;

&lt;p&gt;Pod = 1 or more containers + 1 IP address + shared volumes + a spec for how to run them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwz1tctc6qy1ueydd6hiv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwz1tctc6qy1ueydd6hiv.jpg" alt="What the containers in a Kubernetes Pod share: a Pod with 2 containers, an app and a log shipper, that talk over localhost, share volumes and have 1 IP address, while each container keeps its own filesystem" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;1 IP address, shared volumes, and localhost between the containers.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The containers in a Pod always land on the same node and are scheduled together.&lt;/p&gt;

&lt;p&gt;What they share:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The network:&lt;/strong&gt; 1 IP address and 1 port space. Containers in the same Pod reach each other on &lt;code&gt;localhost&lt;/code&gt;, so 2 of them cannot listen on the same port&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The volumes:&lt;/strong&gt; every volume of the Pod can be mounted by every container in it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The hostname:&lt;/strong&gt; each container sees the Pod name as its hostname, unless you set another one&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The lifetime:&lt;/strong&gt; they start on the same node and they are deleted together&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What they keep to themselves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The filesystem:&lt;/strong&gt; each container sees the root filesystem of its own image. A volume has to be mounted in each container that needs it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Requests and limits:&lt;/strong&gt; CPU and memory are set per container&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The process list:&lt;/strong&gt; a container sees only its own processes, unless you set &lt;code&gt;shareProcessNamespace: true&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The docs call a Pod a "logical host". I find that the simplest way to think about it: a Pod is a tiny machine that runs 1 app.&lt;/p&gt;

&lt;p&gt;Want more copies of the app? Run more Pods. Adding copies as extra containers inside 1 Pod is the wrong direction.&lt;/p&gt;
&lt;h2&gt;
  
  
  Pod vs container, node, cluster and Deployment
&lt;/h2&gt;

&lt;p&gt;These 5 words get mixed up in every first week with Kubernetes.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Thing&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;Relation to a Pod&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Container&lt;/td&gt;
&lt;td&gt;1 running image with your software and its dependencies&lt;/td&gt;
&lt;td&gt;Lives inside a Pod&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod&lt;/td&gt;
&lt;td&gt;1 or more containers with a shared IP and volumes&lt;/td&gt;
&lt;td&gt;The unit Kubernetes schedules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Node&lt;/td&gt;
&lt;td&gt;A worker machine, virtual or physical&lt;/td&gt;
&lt;td&gt;Runs many Pods&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cluster&lt;/td&gt;
&lt;td&gt;A set of nodes plus a control plane&lt;/td&gt;
&lt;td&gt;Decides which node gets each Pod&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deployment&lt;/td&gt;
&lt;td&gt;An object that manages a replicated app&lt;/td&gt;
&lt;td&gt;Creates the Pods and replaces them&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Container inside Pod, Pod on node, node in cluster.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why you create Deployments and let them create Pods
&lt;/h3&gt;

&lt;p&gt;A Pod you create by hand is called a bare Pod. Nothing watches it.&lt;/p&gt;

&lt;p&gt;What happens to a bare Pod when its node dies:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The node stops reporting&lt;/li&gt;
&lt;li&gt;After about 6 minutes Kubernetes marks the Pod for deletion&lt;/li&gt;
&lt;li&gt;The Pod shows Terminating until the node comes back or is removed from the cluster&lt;/li&gt;
&lt;li&gt;Nothing creates a new one&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A Deployment holds a Pod template and a replica count. When a Pod disappears for any reason, it creates a replacement from the template.&lt;/p&gt;

&lt;p&gt;My rule: a bare Pod is for a 5 minute test. Everything else gets a controller, even when you need exactly 1 copy.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Your workload&lt;/th&gt;
&lt;th&gt;What creates the Pods&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A stateless app or API&lt;/td&gt;
&lt;td&gt;&lt;a href="https://meteorops.com/blog/kubernetes-deployment" rel="noopener noreferrer"&gt;Deployment&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A database or anything that needs a stable name and disk&lt;/td&gt;
&lt;td&gt;StatefulSet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An agent that runs on every node&lt;/td&gt;
&lt;td&gt;DaemonSet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A task that runs once and exits&lt;/td&gt;
&lt;td&gt;&lt;a href="https://meteorops.com/blog/how-to-run-one-off-kubernetes-jobs-without-leaving-orphaned-pods" rel="noopener noreferrer"&gt;Job&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A task on a schedule&lt;/td&gt;
&lt;td&gt;CronJob&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One exception: static Pods. The kubelet on a node reads them from a directory on disk and runs them without the API server. kubeadm runs the control plane itself this way (kube-apiserver, etcd, kube-scheduler, kube-controller-manager).&lt;/p&gt;
&lt;h2&gt;
  
  
  A Pod YAML you can copy
&lt;/h2&gt;

&lt;p&gt;The small manifest at the top runs. This one is shaped for production.&lt;/p&gt;

&lt;p&gt;In real life the part under &lt;code&gt;spec&lt;/code&gt; goes into the &lt;code&gt;template&lt;/code&gt; of a Deployment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;automountServiceAccountToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
  &lt;span class="na"&gt;terminationGracePeriodSeconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
  &lt;span class="na"&gt;securityContext&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runAsNonRoot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;runAsUser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10001&lt;/span&gt;
    &lt;span class="na"&gt;fsGroup&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10001&lt;/span&gt;
    &lt;span class="na"&gt;seccompProfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;RuntimeDefault&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;registry.example.com/web:1.4.2&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http&lt;/span&gt;
      &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;
    &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;250m&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;256Mi&lt;/span&gt;
      &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;256Mi&lt;/span&gt;
    &lt;span class="na"&gt;startupProbe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/healthz&lt;/span&gt;
        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http&lt;/span&gt;
      &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
      &lt;span class="na"&gt;failureThreshold&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;
    &lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/ready&lt;/span&gt;
        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http&lt;/span&gt;
    &lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/healthz&lt;/span&gt;
        &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http&lt;/span&gt;
    &lt;span class="na"&gt;lifecycle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;preStop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
    &lt;span class="na"&gt;securityContext&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;allowPrivilegeEscalation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
      &lt;span class="na"&gt;readOnlyRootFilesystem&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="na"&gt;capabilities&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ALL"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;tmp&lt;/span&gt;
      &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/tmp&lt;/span&gt;
  &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;tmp&lt;/span&gt;
    &lt;span class="na"&gt;emptyDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;sizeLimit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;64Mi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What each block is for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A fixed image tag:&lt;/strong&gt; with &lt;code&gt;:latest&lt;/code&gt; or no tag, Kubernetes asks the registry on every start and downloads whatever changed. So the same manifest can run different code tomorrow. With any other tag it pulls only when the image is missing on the node. The policy is set when the Pod is created and stays&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Requests:&lt;/strong&gt; the scheduler places the Pod by its requests. Real usage plays no part in that math&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A memory limit equal to the request:&lt;/strong&gt; the container can never use more memory than the scheduler counted for it. I leave the CPU limit off, because a CPU limit throttles the app even when the node has spare CPU&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3 probes:&lt;/strong&gt; startup gives a slow boot up to 60 seconds, readiness takes the Pod out of traffic, liveness restarts a stuck container. Their defaults: every 10 seconds, 1 second timeout, 3 failures&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;preStop sleep:&lt;/strong&gt; 5 seconds for load balancers to stop sending traffic before the app gets the stop signal&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The security block:&lt;/strong&gt; &lt;code&gt;allowPrivilegeEscalation&lt;/code&gt; defaults to true, so you have to turn it off yourself. A read-only root filesystem needs an &lt;code&gt;emptyDir&lt;/code&gt; for every path the app writes to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No API token:&lt;/strong&gt; by default a Pod gets a service account token mounted. An app that never calls the Kubernetes API does not need one&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Go deeper on 2 of these: &lt;a href="https://meteorops.com/blog/how-to-configure-kubernetes-liveness-probes-without-causing-restart-loops" rel="noopener noreferrer"&gt;liveness probes without restart loops&lt;/a&gt; and &lt;a href="https://meteorops.com/blog/how-to-set-kubernetes-resource-requests-and-limits-without-throttling-apps" rel="noopener noreferrer"&gt;requests and limits without throttling&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Pod lifecycle: 5 phases and what kubectl shows
&lt;/h2&gt;

&lt;p&gt;A Pod has exactly 5 phases.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Phase&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pending&lt;/td&gt;
&lt;td&gt;Accepted by the cluster, and at least 1 container is not ready to run. Covers waiting for a node and pulling images&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Running&lt;/td&gt;
&lt;td&gt;Bound to a node, all containers created, at least 1 is running, starting or restarting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Succeeded&lt;/td&gt;
&lt;td&gt;All containers exited with success and will not restart&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Failed&lt;/td&gt;
&lt;td&gt;All containers stopped and at least 1 failed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unknown&lt;/td&gt;
&lt;td&gt;The node cannot be reached, so the state is unknown&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqu3tjodby2jzse63ddb1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqu3tjodby2jzse63ddb1.jpg" alt="The 5 Kubernetes Pod phases: Pending while waiting for a node and pulling images, Running when at least 1 container is running, then Succeeded or Failed, and Unknown when the node cannot be reached" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;5 phases. Everything else kubectl shows is a display value.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The happy path:&lt;/p&gt;

&lt;p&gt;You apply the manifest&lt;br&gt;&lt;br&gt;
→ the scheduler binds the Pod to a node (once in its lifetime)&lt;br&gt;&lt;br&gt;
→ the kubelet sets up the sandbox and the network&lt;br&gt;&lt;br&gt;
→ init containers run, 1 at a time&lt;br&gt;&lt;br&gt;
→ images are pulled and the app containers start&lt;br&gt;&lt;br&gt;
→ the readiness probe passes&lt;br&gt;&lt;br&gt;
→ the Pod is Ready and gets traffic&lt;/p&gt;

&lt;p&gt;Each container inside the Pod has its own state: Waiting, Running or Terminated.&lt;/p&gt;
&lt;h3&gt;
  
  
  STATUS in kubectl is a display column
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;kubectl get pods&lt;/code&gt; and you will see words that are missing from the table above.&lt;/p&gt;

&lt;p&gt;CrashLoopBackOff, ImagePullBackOff, ContainerCreating, Completed, Terminating: kubectl builds these from the phase, the container states and their reasons.&lt;/p&gt;

&lt;p&gt;A Pod in CrashLoopBackOff is usually in phase Running.&lt;/p&gt;

&lt;p&gt;So when a script needs the real phase, ask for it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pod web -o &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.status.phase}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Pod also carries conditions that tell you how far it got: PodScheduled → PodReadyToStartContainers → Initialized → ContainersReady → Ready.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl describe pod&lt;/code&gt; prints them. Read them in the order above: the first one that is False is where the Pod is stuck.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when a container crashes
&lt;/h2&gt;

&lt;p&gt;The kubelet restarts the container inside the same Pod, on the same node. The Pod stays.&lt;/p&gt;

&lt;p&gt;Restarts follow &lt;code&gt;restartPolicy&lt;/code&gt;: Always (the default), OnFailure or Never. A Deployment only accepts Always. Jobs use OnFailure or Never.&lt;/p&gt;

&lt;p&gt;The timing of the restarts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First crash: restarted immediately&lt;/li&gt;
&lt;li&gt;After that the wait doubles: 10 seconds, 20, 40 and so on&lt;/li&gt;
&lt;li&gt;The wait is capped at 300 seconds (5 minutes)&lt;/li&gt;
&lt;li&gt;After 10 minutes of running clean, the counter resets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CrashLoopBackOff = the container keeps failing, and Kubernetes is waiting before the next try.&lt;/p&gt;

&lt;p&gt;It tells you that the container fails. Why it fails is in the logs of the run that died:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl logs web --previous
kubectl describe pod web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The usual causes: an app error at startup, a wrong config, a missing environment variable, too little memory, or a liveness probe that kills a healthy app.&lt;/p&gt;

&lt;p&gt;Since v1.35 a node can lower the 5 minute cap out of the box (&lt;code&gt;crashLoopBackOff.maxContainerRestartPeriod&lt;/code&gt; in the kubelet configuration, between 1 and 300 seconds).&lt;/p&gt;

&lt;h2&gt;
  
  
  Init containers and sidecars: when 1 Pod needs more than 1 container
&lt;/h2&gt;

&lt;p&gt;The docs call a multi-container Pod "a relatively advanced use case". I agree.&lt;/p&gt;

&lt;p&gt;My test for a second container: does it have to share the network or the disk of the first one? If the answer is no, it gets its own Pod.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;When it runs&lt;/th&gt;
&lt;th&gt;Use it for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Init container&lt;/td&gt;
&lt;td&gt;Before the app, 1 at a time, each to completion&lt;/td&gt;
&lt;td&gt;Migrations, waiting for a dependency, fetching config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sidecar container&lt;/td&gt;
&lt;td&gt;Starts before the app and runs for the whole life of the Pod&lt;/td&gt;
&lt;td&gt;Log shippers, proxies, secret agents&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ephemeral container&lt;/td&gt;
&lt;td&gt;Added to a running Pod by &lt;code&gt;kubectl debug&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Debugging an image that has no shell&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;3 facts about init containers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;They run in the order they are written, and each one must succeed before the next one starts&lt;/li&gt;
&lt;li&gt;A failing init container is retried until it succeeds (with &lt;code&gt;restartPolicy: Never&lt;/code&gt; the whole Pod fails)&lt;/li&gt;
&lt;li&gt;They can run more than once, so the code in them has to be safe to repeat&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A sidecar is written as an init container with &lt;code&gt;restartPolicy: Always&lt;/code&gt;. This is stable since v1.33:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;initContainers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;log-shipper&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;registry.example.com/log-shipper:2.1.0&lt;/span&gt;
    &lt;span class="na"&gt;restartPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Always&lt;/span&gt;
  &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;registry.example.com/web:1.4.2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What you get from it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The sidecar starts before the app&lt;/li&gt;
&lt;li&gt;It is stopped after the app, so the last log lines still ship&lt;/li&gt;
&lt;li&gt;In a Job it no longer blocks completion when the main container finishes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you still run sidecars as regular containers with wrapper scripts to fix the start order, this replaces all of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requests, limits and what happens when a Pod goes over
&lt;/h2&gt;

&lt;p&gt;Request = what the scheduler reserves for the container. Limit = the most it is allowed to use.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;The container goes over its&lt;/th&gt;
&lt;th&gt;What happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CPU limit&lt;/td&gt;
&lt;td&gt;It is throttled. It is never killed for CPU&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory limit&lt;/td&gt;
&lt;td&gt;The kernel can kill the container. &lt;code&gt;kubectl describe pod&lt;/code&gt; shows Reason: OOMKilled and Exit Code: 137&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory request, on a node that runs short&lt;/td&gt;
&lt;td&gt;The Pod becomes a likely candidate for eviction&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two details that surprise people:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The memory kill is reactive. It happens when the kernel detects memory pressure, so a container can sit above its limit for a moment&lt;/li&gt;
&lt;li&gt;The kernel kills the processes of that container. The Pod stays, the container restarts, and its restart count goes up by 1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kubernetes also gives every Pod a quality of service class, from its requests and limits:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Guaranteed&lt;/td&gt;
&lt;td&gt;Every container has CPU and memory requests equal to its limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Burstable&lt;/td&gt;
&lt;td&gt;At least 1 request or limit is set, and the Pod misses the Guaranteed rule&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BestEffort&lt;/td&gt;
&lt;td&gt;No requests and no limits at all&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When a node runs out of memory or disk, the kubelet evicts Pods. Pods that use more than they requested go first. Among those, the lowest priority goes first, then the one furthest above its request.&lt;/p&gt;

&lt;p&gt;A BestEffort Pod requests 0, so any usage puts it above its request. It is always in the first group.&lt;/p&gt;

&lt;p&gt;An evicted Pod gets no grace period at a hard threshold, and PodDisruptionBudgets are ignored. (The Pod does not get a vote.)&lt;/p&gt;

&lt;p&gt;If you set a limit and no request, Kubernetes copies the limit into the request (unless a LimitRange in the namespace sets a default request).&lt;/p&gt;

&lt;h3&gt;
  
  
  Change CPU and memory without a restart
&lt;/h3&gt;

&lt;p&gt;Since v1.35, in-place resize is stable. You can change the CPU and memory of a running Pod:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl patch pod web --subresource resize --patch \
  &lt;span class="s1"&gt;'{"spec":{"containers":[{"name":"web","resources":{"requests":{"cpu":"500m"}}}]}}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It needs kubectl v1.32 or later. Only CPU and memory can be resized, and the quality of service class of the Pod cannot change.&lt;/p&gt;

&lt;p&gt;So this works on a Pod that already has requests, like the production manifest above. The small Pod at the top has none, and Kubernetes rejects the resize.&lt;/p&gt;

&lt;p&gt;Remember that a Deployment will not know about it. Change the template too, or the next rollout brings the old values back.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a Pod shuts down in 30 seconds
&lt;/h2&gt;

&lt;p&gt;Every deploy, scale-down and node drain deletes Pods. Most failed requests during a deploy come from this sequence.&lt;/p&gt;

&lt;p&gt;You delete the Pod (or a rollout does)&lt;br&gt;&lt;br&gt;
→ the Pod is marked as terminating&lt;br&gt;&lt;br&gt;
→ at the same time, Services start to take it out of rotation and the preStop hook runs, if there is one&lt;br&gt;&lt;br&gt;
→ the kubelet sends SIGTERM to the main process of each container&lt;br&gt;&lt;br&gt;
→ the app finishes its open requests and exits&lt;br&gt;&lt;br&gt;
→ after 30 seconds, whatever still runs gets SIGKILL&lt;/p&gt;

&lt;p&gt;30 seconds is the default of &lt;code&gt;terminationGracePeriodSeconds&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48njj69o74agjydcsvhb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F48njj69o74agjydcsvhb.jpg" alt="How a Kubernetes Pod shuts down: the Pod is deleted and stops getting new traffic, the preStop hook runs, SIGTERM is sent, the app finishes open requests, and SIGKILL follows after 30 seconds by default" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The preStop hook and the app share the same 30 seconds.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;3 things go wrong here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The app ignores SIGTERM.&lt;/strong&gt; It keeps serving for 30 seconds and is then killed in the middle of a request. Catch the signal and shut down&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The app exits too fast.&lt;/strong&gt; Removing the Pod from load balancers and sending SIGTERM happen in parallel, so some requests still arrive. A preStop sleep of a few seconds covers the gap&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The preStop hook eats the budget.&lt;/strong&gt; The time it takes counts against the 30 seconds. A 25 second sleep leaves the app 5 seconds&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Also good to know: the preStop hook does not run when a container crashes or exits by itself. It runs only when Kubernetes stops the container.&lt;/p&gt;

&lt;p&gt;And the force delete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl delete pod web --grace-period=0 --force
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This removes the Pod from the API right away, without waiting for the node to confirm. The processes can keep running on the node. Use it for a Pod on a node that is gone, and stay away from it for databases.&lt;/p&gt;

&lt;p&gt;For whole nodes, see &lt;a href="https://meteorops.com/blog/how-to-drain-kubernetes-nodes-without-evicting-critical-workloads" rel="noopener noreferrer"&gt;how to drain nodes without evicting critical workloads&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Pod is never moved, it is replaced
&lt;/h2&gt;

&lt;p&gt;A Pod is scheduled once. It stays on that node until it finishes, is deleted, is evicted, or the node fails.&lt;/p&gt;

&lt;p&gt;"The Pod moved to another node" always means: the old Pod was deleted and a controller created a new one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuy9lynahb67v7s1fos84.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuy9lynahb67v7s1fos84.jpg" alt="A Kubernetes Pod is never moved, it is replaced: the old Pod on the failed node 1 is deleted and the Deployment creates a new Pod on node 2 with a new UID and a new IP" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Same template, new Pod, new UID, new IP.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What the new Pod gets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A new UID (the name can stay, as in a StatefulSet)&lt;/li&gt;
&lt;li&gt;A new IP address, in almost every setup&lt;/li&gt;
&lt;li&gt;An empty &lt;code&gt;emptyDir&lt;/code&gt;. That volume lives exactly as long as the Pod&lt;/li&gt;
&lt;li&gt;The same PersistentVolumeClaim, when the workload uses one&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is why nothing should call a Pod by its IP. A &lt;a href="https://meteorops.com/blog/kubernetes-service" rel="noopener noreferrer"&gt;Service&lt;/a&gt; gives a changing set of Pods 1 stable address.&lt;/p&gt;

&lt;p&gt;And it is why a dead node hurts for about 6 minutes. Kubernetes waits 50 seconds before it marks the node as unreachable. Then a second timer starts: a Pod gets 2 tolerations added automatically, for nodes that are not ready or unreachable, with &lt;code&gt;tolerationSeconds: 300&lt;/code&gt; (unless you set your own). The Pods stay bound to the dead node for those 300 seconds before they are evicted and replaced.&lt;/p&gt;

&lt;p&gt;If 6 minutes is too long for a service, lower &lt;code&gt;tolerationSeconds&lt;/code&gt; in its Pod template and run more than 1 replica across nodes.&lt;/p&gt;
&lt;h2&gt;
  
  
  How many Pods fit on a node
&lt;/h2&gt;

&lt;p&gt;Kubernetes is designed for 110 Pods per node, and 110 is the default of the kubelet setting &lt;code&gt;maxPods&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The cloud providers change that number, mostly because of IP addresses:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Platform&lt;/th&gt;
&lt;th&gt;Pods per node&lt;/th&gt;
&lt;th&gt;What drives it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Upstream default&lt;/td&gt;
&lt;td&gt;110&lt;/td&gt;
&lt;td&gt;The kubelet setting &lt;code&gt;maxPods&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amazon EKS&lt;/td&gt;
&lt;td&gt;Computed per instance type, capped at 110 under 30 vCPUs and 250 above (managed node groups)&lt;/td&gt;
&lt;td&gt;Network interfaces and IPs per interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GKE Standard&lt;/td&gt;
&lt;td&gt;110 by default, up to 512&lt;/td&gt;
&lt;td&gt;The Pod IP range given to each node&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GKE Autopilot&lt;/td&gt;
&lt;td&gt;Chosen by Google, between 8 and 256&lt;/td&gt;
&lt;td&gt;Set for you and fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AKS&lt;/td&gt;
&lt;td&gt;Up to 250. Default 250 with Azure CNI Overlay, 110 with kubenet (30 when created in the portal), 30 with legacy Azure CNI&lt;/td&gt;
&lt;td&gt;The network plugin&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On EKS each Pod takes an IP address from your VPC. The formula for the default is:&lt;/p&gt;

&lt;p&gt;max Pods = network interfaces × (IPs per interface - 1) + 2&lt;/p&gt;

&lt;p&gt;So a small instance can run out of Pod IPs while half of its CPU is free. Prefix delegation raises the ceiling.&lt;/p&gt;

&lt;p&gt;On GKE Standard the number is set when the cluster or node pool is created and cannot be changed later. Decide it before you create the pool.&lt;/p&gt;
&lt;h2&gt;
  
  
  Debug a Pod: 8 statuses and the first command for each
&lt;/h2&gt;

&lt;p&gt;Start every time with the same command. It shows the container states, the restart count and the recent events:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl describe pod web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then go by what the STATUS column says.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;STATUS&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;th&gt;Do this first&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pending&lt;/td&gt;
&lt;td&gt;No node accepts the Pod. The event says FailedScheduling with a reason like "Insufficient cpu"&lt;/td&gt;
&lt;td&gt;Read the event. Lower the requests, add nodes, or fix the taint or selector that excludes them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ContainerCreating&lt;/td&gt;
&lt;td&gt;Scheduled, and the node is still preparing the network, the volumes or the image&lt;/td&gt;
&lt;td&gt;Read the events for a volume that cannot mount or a missing Secret&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ImagePullBackOff&lt;/td&gt;
&lt;td&gt;The image cannot be pulled. Kubernetes retries with a growing wait, up to 5 minutes&lt;/td&gt;
&lt;td&gt;Check the image name and tag, then the &lt;code&gt;imagePullSecrets&lt;/code&gt; for a private registry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CrashLoopBackOff&lt;/td&gt;
&lt;td&gt;The container starts and dies, again and again&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs web --previous&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Running, 0/1 ready&lt;/td&gt;
&lt;td&gt;The container runs and the readiness probe fails, so the Pod gets no traffic&lt;/td&gt;
&lt;td&gt;Read the probe failures in the events, then call the probe path yourself&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Init:0/2&lt;/td&gt;
&lt;td&gt;The Pod has 2 init containers and none has finished&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl logs web -c NAME&lt;/code&gt; with the name of the init container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Evicted&lt;/td&gt;
&lt;td&gt;The node ran short of memory or disk and the kubelet removed the Pod&lt;/td&gt;
&lt;td&gt;Set requests that match real usage. Check what else runs on that node&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Terminating (stuck)&lt;/td&gt;
&lt;td&gt;Deletion was requested and something blocks it, most often a finalizer or a node that stopped answering&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl get pod web -o yaml&lt;/code&gt; and read &lt;code&gt;metadata.finalizers&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A ninth one you will meet: &lt;a href="https://meteorops.com/glossary/createcontainerconfigerror" rel="noopener noreferrer"&gt;CreateContainerConfigError&lt;/a&gt;. The events name the ConfigMap or Secret the container asks for and cannot find.&lt;/p&gt;

&lt;p&gt;The commands that go with the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Which node, which IP, how many restarts&lt;/span&gt;
kubectl get pods -o wide

&lt;span class="c"&gt;# Events for 1 Pod only&lt;/span&gt;
kubectl events --for pod/web

&lt;span class="c"&gt;# Logs: follow, the crashed run, every container&lt;/span&gt;
kubectl logs web -f
kubectl logs web --previous
kubectl logs web --all-containers

&lt;span class="c"&gt;# Real CPU and memory use (needs metrics-server)&lt;/span&gt;
kubectl top pod web --containers

&lt;span class="c"&gt;# Call the app from your laptop (local port:container port)&lt;/span&gt;
kubectl port-forward pod/web 8080:8080

&lt;span class="c"&gt;# What does this field do&lt;/span&gt;
kubectl explain pod.spec.containers.resources
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The image has no shell? Add a debug container to the running Pod:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl debug -it web --image=busybox:1.36 --target=web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--target&lt;/code&gt; puts the debug container in the process namespace of the &lt;code&gt;web&lt;/code&gt; container, so you see its processes.&lt;/p&gt;

&lt;p&gt;The container dies too fast to look at? Copy the Pod with a shell as its command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl debug web -it --copy-to=web-debug --container=web -- sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More one-liners in the &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet" rel="noopener noreferrer"&gt;kubectl cheat sheet&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed for Pods from v1.33 to v1.37
&lt;/h2&gt;

&lt;p&gt;Most Pod guides were written before these. If your knowledge of Pods is 2 years old, this table is the update.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;v1.33&lt;/td&gt;
&lt;td&gt;Native sidecar containers are stable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.35&lt;/td&gt;
&lt;td&gt;In-place resize of CPU and memory is stable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.35&lt;/td&gt;
&lt;td&gt;cgroup v1 is retired: the kubelet refuses to start on a cgroup v1 node by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.35&lt;/td&gt;
&lt;td&gt;Restart rules per container (&lt;code&gt;restartPolicyRules&lt;/code&gt; by exit code) are beta and on by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.36&lt;/td&gt;
&lt;td&gt;User namespaces are stable. With &lt;code&gt;hostUsers: false&lt;/code&gt;, root in the container is an unprivileged user on the node&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.36&lt;/td&gt;
&lt;td&gt;Image volumes are stable: mount an OCI image as a read-only volume&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.36&lt;/td&gt;
&lt;td&gt;A Pod can restart all its containers in place and keep its UID and IP (beta, through &lt;code&gt;restartPolicyRules&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.36&lt;/td&gt;
&lt;td&gt;The &lt;code&gt;gitRepo&lt;/code&gt; volume type is disabled for good&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v1.37&lt;/td&gt;
&lt;td&gt;Static Pods can no longer reference Secrets or ConfigMaps&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Coming next: resources set for the whole Pod (&lt;code&gt;spec.resources&lt;/code&gt;) are beta since v1.34 and expected to become stable in v1.38.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist before a Pod goes to production
&lt;/h2&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A controller owns the Pod (Deployment, StatefulSet, DaemonSet or Job)&lt;/li&gt;
&lt;li&gt;The image has a fixed tag or a digest&lt;/li&gt;
&lt;li&gt;Every container has CPU and memory requests&lt;/li&gt;
&lt;li&gt;Every container has a memory limit&lt;/li&gt;
&lt;li&gt;A readiness probe exists and checks what the app needs to serve&lt;/li&gt;
&lt;li&gt;The liveness probe checks only the app itself, with no calls to dependencies&lt;/li&gt;
&lt;li&gt;The app handles SIGTERM and exits within the grace period&lt;/li&gt;
&lt;li&gt;A preStop sleep covers the load balancer delay&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;runAsNonRoot: true&lt;/code&gt; and &lt;code&gt;allowPrivilegeEscalation: false&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;All capabilities dropped, seccomp profile RuntimeDefault&lt;/li&gt;
&lt;li&gt;The service account token is off when the app does not call the API&lt;/li&gt;
&lt;li&gt;More than 1 replica, spread across nodes&lt;/li&gt;
&lt;li&gt;Nothing stores data in the container filesystem or in an &lt;code&gt;emptyDir&lt;/code&gt; that you cannot lose&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a Pod in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;A Pod is the smallest unit Kubernetes can deploy: 1 or more containers that share an IP address, volumes and a spec. Kubernetes schedules Pods onto nodes and manages containers through them.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a Pod and a container?
&lt;/h3&gt;

&lt;p&gt;A container is 1 running image. A Pod is the wrapper Kubernetes puts around 1 or more containers so they share a network and volumes and are scheduled as 1 unit.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a Pod and a node?
&lt;/h3&gt;

&lt;p&gt;A node is a machine. A Pod is a workload that runs on that machine. 1 node runs many Pods, up to 110 by default.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can a Pod have more than 1 container?
&lt;/h3&gt;

&lt;p&gt;Yes. Use it when the containers must share the network or a volume: an app with a log shipper or a proxy. Separate services go in separate Pods so they can scale on their own.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a Pod and a Deployment?
&lt;/h3&gt;

&lt;p&gt;A Pod is 1 running copy of your app. A Deployment holds the template and the replica count, creates the Pods, replaces the ones that die and rolls out new versions.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I restart a Pod?
&lt;/h3&gt;

&lt;p&gt;You do not restart a Pod, you replace it. For a Deployment run &lt;code&gt;kubectl rollout restart deployment/web&lt;/code&gt;, or delete the Pod with &lt;code&gt;kubectl delete pod NAME&lt;/code&gt; and let the controller create a new one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is my Pod stuck in Pending?
&lt;/h3&gt;

&lt;p&gt;No node can take it. &lt;code&gt;kubectl describe pod&lt;/code&gt; shows a FailedScheduling event with the reason: too little CPU or memory for the requests, a taint without a toleration, or a node selector that matches no node.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does exit code 137 mean?
&lt;/h3&gt;

&lt;p&gt;The container was killed with SIGKILL. Together with Reason: OOMKilled it means the kernel killed it for memory. Most of the time the container went over its own limit, and sometimes the whole node ran out. Look for a leak, or raise the limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  A recap
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing, let it be this: a Pod is disposable.&lt;/p&gt;

&lt;p&gt;Kubernetes assumes it can delete any Pod at any time and start a new one somewhere else. Everything in this guide follows from that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A controller, so a new Pod appears&lt;/li&gt;
&lt;li&gt;A Service, so clients find the new Pod&lt;/li&gt;
&lt;li&gt;Probes, so traffic waits until it is ready&lt;/li&gt;
&lt;li&gt;A clean shutdown, so the old Pod finishes its work&lt;/li&gt;
&lt;li&gt;Data on a PersistentVolume, so it survives the swap&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can set all of this up yourself with the YAML and the checklist above.&lt;/p&gt;

&lt;p&gt;If you would like a second pair of eyes on your cluster, get a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt;. Next reads: &lt;a href="https://meteorops.com/blog/kubernetes-deployment" rel="noopener noreferrer"&gt;Kubernetes Deployment&lt;/a&gt;, &lt;a href="https://meteorops.com/blog/kubernetes-service" rel="noopener noreferrer"&gt;Kubernetes Service&lt;/a&gt; and &lt;a href="https://meteorops.com/blog/kubernetes-namespace" rel="noopener noreferrer"&gt;Kubernetes Namespace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes Service: Types, Ports, DNS and How to Debug One</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Wed, 02 Dec 2026 15:30:19 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-service-types-ports-dns-and-how-to-debug-one-1g16</link>
      <guid>https://dev.to/meteorops/kubernetes-service-types-ports-dns-and-how-to-debug-one-1g16</guid>
      <description>&lt;p&gt;A Kubernetes Service gives a changing set of Pods 1 stable IP address and 1 DNS name. 5 things to know before you put traffic on one:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Service = a stable address for Pods that come and go.&lt;/strong&gt; Pods get new IPs every time they are replaced. The Service IP and name stay&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Service finds Pods by label.&lt;/strong&gt; The selector matches Pod labels, and the control plane keeps the list of matching Pod IPs, with their readiness, in EndpointSlices&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There are 4 types, and 3 of them stack.&lt;/strong&gt; ClusterIP is internal. NodePort adds a port on every node. LoadBalancer adds a cloud load balancer in front. ExternalName is a DNS alias&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ONLY ready Pods get traffic.&lt;/strong&gt; A Pod that fails its readiness probe stops receiving traffic from every Service that selects it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Service balances connections at layer 4.&lt;/strong&gt; It picks a Pod at random for each new connection. It knows nothing about HTTP paths, hosts or TLS certificates&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A small Service that works, on Kubernetes v1.37:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector:
    app: web
  ports:
  - name: http
    port: 80
    targetPort: 8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 4 commands you will use most:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f service.yaml
kubectl get svc web
kubectl describe svc web
kubectl get endpointslices -l kubernetes.io/service-name=web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Services that time out, or a load balancer bill that keeps growing?&lt;/strong&gt; Get a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt;: a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are writing your first manifest: &lt;a href="https://meteorops.com/blog/kubernetes-service#a-service-yaml-you-can-copy-port-targetport-and-nodeport" rel="noopener noreferrer"&gt;a Service YAML you can copy&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are choosing a type: &lt;a href="https://meteorops.com/blog/kubernetes-service#the-4-service-types-and-when-to-use-each" rel="noopener noreferrer"&gt;the 4 Service types&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A Service does not answer right now: &lt;a href="https://meteorops.com/blog/kubernetes-service#debug-a-service-in-8-checks" rel="noopener noreferrer"&gt;debug a Service in 8 checks&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You wonder why you pay for 12 load balancers: &lt;a href="https://meteorops.com/blog/kubernetes-service#a-loadbalancer-service-costs-money-per-service-on-aws" rel="noopener noreferrer"&gt;what a LoadBalancer Service costs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;gRPC traffic lands on 1 Pod: &lt;a href="https://meteorops.com/blog/kubernetes-service#how-traffic-gets-from-the-service-ip-to-a-pod" rel="noopener noreferrer"&gt;how traffic gets to a Pod&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You want the main fields with their defaults: &lt;a href="https://meteorops.com/blog/kubernetes-service#12-spec-fields-and-their-defaults" rel="noopener noreferrer"&gt;12 spec fields&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A Service is a stable address in front of changing Pods
&lt;/h2&gt;

&lt;p&gt;Every Pod gets its own IP address. A Deployment creates and destroys Pods all day, so the set of IPs behind your app keeps changing.&lt;/p&gt;

&lt;p&gt;Clients need 1 address that does not change.&lt;/p&gt;

&lt;p&gt;Service = 1 virtual IP + 1 DNS name + a list of the Pods behind it.&lt;/p&gt;

&lt;p&gt;What happens when you create one:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You apply a Service with a selector, for example &lt;code&gt;app: web&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The Service gets a cluster IP from the Service IP range, and a DNS name&lt;/li&gt;
&lt;li&gt;A controller scans for Pods whose labels match the selector, continuously&lt;/li&gt;
&lt;li&gt;It writes their IPs, ports and readiness into EndpointSlices&lt;/li&gt;
&lt;li&gt;kube-proxy on every node watches Services and EndpointSlices, and sets up the rules that redirect traffic for the Service IP to one of the Pods&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A Pod dies → it leaves the EndpointSlices. A new Pod with the same labels starts → it joins. Nobody edits a config file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Floubhlveqml2vvuj17en.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Floubhlveqml2vvuj17en.webp" alt="How a Kubernetes Service works: a client calls the Service web on port 80, and the Service sends the connection to one of 3 Pods on targetPort 8080, and the EndpointSlice lists the Pods behind the Service" width="799" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;1 address in front. The list behind it updates itself.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Service IP is virtual. The docs' words: it "never hits the wire". No single host answers for it. Each node rewrites the destination of the packet to a real Pod IP.&lt;/p&gt;

&lt;p&gt;Why not plain DNS with several records? The Kubernetes docs give the reasons: DNS clients ignore TTLs (how long an answer may be cached), some apps look a name up once and cache the result forever, and low TTLs put a heavy load on DNS.&lt;/p&gt;
&lt;h3&gt;
  
  
  Service vs Deployment
&lt;/h3&gt;

&lt;p&gt;A Deployment runs your app: it manages ReplicaSets and Pods. A Service exposes it: it gives those Pods an address.&lt;/p&gt;

&lt;p&gt;They are linked by labels only. The Service does not know the Deployment exists.&lt;/p&gt;

&lt;p&gt;That is why the same Service keeps working through a rollout: old Pods and new Pods carry the same label. (The rollout side is covered in the &lt;a href="https://meteorops.com/blog/kubernetes-deployment" rel="noopener noreferrer"&gt;Kubernetes Deployment guide&lt;/a&gt;.)&lt;/p&gt;
&lt;h2&gt;
  
  
  A Service YAML you can copy: port, targetPort and nodePort
&lt;/h2&gt;

&lt;p&gt;The Deployment side and the Service side, with the 3 lines that must agree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# In the Deployment's Pod template
metadata:
  labels:
    app: web            # 1. the label
spec:
  containers:
  - name: web
    image: registry.example.com/web:1.4.2
    ports:
    - name: http-web    # 2. the port name
      containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector:
    app: web            # 1. must match the Pod label
  ports:
  - name: http
    protocol: TCP
    port: 80            # 3. the port clients call
    targetPort: http-web  # 2. the container port, by name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 3 port fields, in 1 line each:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;port:&lt;/strong&gt; the port of the Service. Clients call &lt;code&gt;web:80&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;targetPort:&lt;/strong&gt; the port on the Pod. A number from 1 to 65535, or the name of a container port. It defaults to the value of &lt;code&gt;port&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;nodePort:&lt;/strong&gt; the port opened on every node, for NodePort and LoadBalancer Services only. Kubernetes picks one from 30000 to 32767 unless you set it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsjtzb9ydh7wgi7ua80y2.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsjtzb9ydh7wgi7ua80y2.webp" alt="nodePort, port and targetPort in a Kubernetes Service: nodePort 30080 is the port on every node, port 80 is the port clients call, targetPort 8080 is the port on the Pod" width="799" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;3 port fields, 3 different places.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I use a named &lt;code&gt;targetPort&lt;/code&gt;. The next release of the app can move from 8080 to 9090, and the Service does not change.&lt;/p&gt;

&lt;p&gt;2 rules for the ports list:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Service with more than 1 port needs a unique name on every port&lt;/li&gt;
&lt;li&gt;Port names are lowercase letters, digits and &lt;code&gt;-&lt;/code&gt;. &lt;code&gt;123-abc&lt;/code&gt; is valid, &lt;code&gt;123_abc&lt;/code&gt; is rejected. A container port name (the one a named &lt;code&gt;targetPort&lt;/code&gt; points at) is also limited to 15 characters&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The quick way, when a Deployment already exists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl expose deployment web --port=80 --target-port=8080 --name=web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What you get back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get svc web
NAME   TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
web    ClusterIP   10.0.1.175           80/TCP    5s

$ kubectl get endpointslices -l kubernetes.io/service-name=web
NAME        ADDRESSTYPE   PORTS   ENDPOINTS                          AGE
web-ytpni   IPv4          8080    10.244.0.5,10.244.0.6,10.244.0.7   5s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 addresses = 3 Pods that match the selector. The column lists Pods that are not ready too, so it proves the selector works and nothing more.&lt;/p&gt;

&lt;p&gt;An empty ENDPOINTS column (&lt;code&gt;or&lt;/code&gt;, by kubectl version) is the first thing to look for when a Service does not answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 4 Service types and when to use each
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;type&lt;/code&gt; field takes 4 values. ClusterIP is the default.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;What you get&lt;/th&gt;
&lt;th&gt;Reachable from&lt;/th&gt;
&lt;th&gt;Use it for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ClusterIP&lt;/td&gt;
&lt;td&gt;A virtual IP inside the cluster&lt;/td&gt;
&lt;td&gt;Pods in the cluster&lt;/td&gt;
&lt;td&gt;Almost every Service: APIs, databases, queues&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NodePort&lt;/td&gt;
&lt;td&gt;ClusterIP + the same port on every node&lt;/td&gt;
&lt;td&gt;Anything that reaches a node IP&lt;/td&gt;
&lt;td&gt;Your own load balancer in front, quick tests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LoadBalancer&lt;/td&gt;
&lt;td&gt;NodePort + a load balancer from your cloud&lt;/td&gt;
&lt;td&gt;The internet or your VPC&lt;/td&gt;
&lt;td&gt;The entry point: an Ingress or Gateway controller, or a TCP service&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ExternalName&lt;/td&gt;
&lt;td&gt;A DNS alias (a CNAME record) to an outside name&lt;/td&gt;
&lt;td&gt;Pods in the cluster&lt;/td&gt;
&lt;td&gt;An alias for an external database or API&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The first 3 are nested. Each level adds to the previous one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg9r787sino4voup0wfml.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg9r787sino4voup0wfml.webp" alt="The 4 Kubernetes Service types: ClusterIP is a virtual IP inside the cluster, NodePort adds the same port on every node, LoadBalancer adds a load balancer from your cloud, and ExternalName is a DNS alias" width="799" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;ClusterIP inside NodePort inside LoadBalancer. ExternalName stands apart.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The one exception: a LoadBalancer Service with &lt;code&gt;allocateLoadBalancerNodePorts: false&lt;/code&gt;, for load balancers that send traffic straight to Pod IPs.&lt;/p&gt;

&lt;h3&gt;
  
  
  ClusterIP: the default, and the one you want most of the time
&lt;/h3&gt;

&lt;p&gt;The IP comes from the range set by the API server flag &lt;code&gt;--service-cluster-ip-range&lt;/code&gt;. It is reachable from inside the cluster only.&lt;/p&gt;

&lt;p&gt;The cluster IP stays the same for the life of the Service. Delete and recreate the Service and it usually gets a different one, which is one more reason to call Services by name.&lt;/p&gt;

&lt;h3&gt;
  
  
  NodePort: a port on every node
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The default range is 30000 to 32767. The API server flag &lt;code&gt;--service-node-port-range&lt;/code&gt; changes it&lt;/li&gt;
&lt;li&gt;Every node listens on the port and forwards to a ready Pod, on any node&lt;/li&gt;
&lt;li&gt;Ask for a specific &lt;code&gt;nodePort&lt;/code&gt; and you get it, or the API call fails&lt;/li&gt;
&lt;li&gt;Pick your own ports from 30000 to 30085. Automatic assignment uses 30086 to 32767 first, so a collision is unlikely (stable since v1.29)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One difference to know before you change proxy mode: in iptables mode a NodePort answers on all node IPs by default, and in nftables mode only on the node's primary IP.&lt;/p&gt;

&lt;h3&gt;
  
  
  LoadBalancer: your cloud does the work
&lt;/h3&gt;

&lt;p&gt;Kubernetes does not ship a load balancer. The type asks your cloud provider for one.&lt;/p&gt;

&lt;p&gt;The steps: the Service starts as a NodePort → the cloud controller creates the load balancer and points it at the nodes → the address shows up under EXTERNAL-IP.&lt;/p&gt;

&lt;p&gt;It is asynchronous. Until the load balancer exists, &lt;code&gt;kubectl get svc&lt;/code&gt; shows ``.&lt;/p&gt;

&lt;p&gt;On a cluster with nothing that provides load balancers (bare metal, many local clusters) it stays pending forever. MetalLB is the one I see most on bare metal.&lt;/p&gt;

&lt;p&gt;What each cloud creates:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cloud&lt;/th&gt;
&lt;th&gt;What a LoadBalancer Service creates&lt;/th&gt;
&lt;th&gt;Internal instead of public&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS (EKS)&lt;/td&gt;
&lt;td&gt;A Network Load Balancer with the AWS Load Balancer Controller or EKS Auto Mode. The legacy built-in controller creates Classic Load Balancers and gets critical fixes only&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;service.beta.kubernetes.io/aws-load-balancer-scheme: "internal"&lt;/code&gt; with the AWS Load Balancer Controller and Auto Mode. The legacy controller reads &lt;code&gt;service.beta.kubernetes.io/aws-load-balancer-internal: "true"&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Cloud (GKE)&lt;/td&gt;
&lt;td&gt;A passthrough Network Load Balancer&lt;/td&gt;
&lt;td&gt;&lt;code&gt;networking.gke.io/load-balancer-type: "Internal"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure (AKS)&lt;/td&gt;
&lt;td&gt;A new frontend IP and rules on the cluster's Standard Load Balancer&lt;/td&gt;
&lt;td&gt;&lt;code&gt;service.beta.kubernetes.io/azure-load-balancer-internal: "true"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On AWS, check the scheme before you apply. With the AWS Load Balancer Controller a new Network Load Balancer is internal by default, and &lt;code&gt;internet-facing&lt;/code&gt; is something you ask for.&lt;/p&gt;

&lt;p&gt;Check which controller owns the Service too. The AWS Load Balancer Controller picks a Service up only through &lt;code&gt;loadBalancerClass: service.k8s.aws/nlb&lt;/code&gt; or the annotation &lt;code&gt;service.beta.kubernetes.io/aws-load-balancer-type: "external"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2 fields I set on a public LoadBalancer Service:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;loadBalancerSourceRanges&lt;/code&gt;, when only known IP ranges should connect (if the cloud supports it)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;externalTrafficPolicy: Local&lt;/code&gt;, when the app needs the real client IP. More on that below&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  ExternalName: a DNS alias, with 2 traps
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
apiVersion: v1&lt;br&gt;
kind: Service&lt;br&gt;
metadata:&lt;br&gt;
  name: orders-db&lt;br&gt;
spec:&lt;br&gt;
  type: ExternalName&lt;br&gt;
  externalName: my.database.example.com&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Pods look up &lt;code&gt;orders-db&lt;/code&gt; and get a CNAME to the outside name. No proxying, no selector, kube-proxy is not involved.&lt;/p&gt;

&lt;p&gt;The 2 traps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;HTTP and TLS:&lt;/strong&gt; the client sends the Host header &lt;code&gt;orders-db&lt;/code&gt;, which the origin does not recognize, and the origin's certificate does not match the name the client used&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IP addresses:&lt;/strong&gt; an IPv4 string in &lt;code&gt;externalName&lt;/code&gt; is treated as a DNS name made of digits and does not resolve. For an IP, use a Service without a selector&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Headless: no virtual IP at all
&lt;/h3&gt;

&lt;p&gt;Set &lt;code&gt;clusterIP: None&lt;/code&gt;. The type stays ClusterIP.&lt;/p&gt;

&lt;p&gt;No virtual IP, no kube-proxy, no load balancing. DNS returns the IPs of the ready Pods and the client picks one.&lt;/p&gt;

&lt;p&gt;Use it when the client must know every Pod: StatefulSet members such as a database cluster, and gRPC clients that balance on their own.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Service without a selector
&lt;/h3&gt;

&lt;p&gt;Leave the selector out and Kubernetes creates no EndpointSlices. You write them yourself:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
apiVersion: discovery.k8s.io/v1&lt;br&gt;
kind: EndpointSlice&lt;br&gt;
metadata:&lt;br&gt;
  name: legacy-db-1&lt;br&gt;
  labels:&lt;br&gt;
    kubernetes.io/service-name: legacy-db&lt;br&gt;
addressType: IPv4&lt;br&gt;
ports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;name: postgres
protocol: TCP
port: 5432
endpoints:&lt;/li&gt;
&lt;li&gt;addresses:

&lt;ul&gt;
&lt;li&gt;"10.4.5.6"
&lt;code&gt;&lt;/code&gt;`&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2 things must match the Service: the &lt;code&gt;kubernetes.io/service-name&lt;/code&gt; label, and the port name (the Service needs a port named &lt;code&gt;postgres&lt;/code&gt; too). The name of the EndpointSlice does not matter.&lt;/p&gt;

&lt;p&gt;I use this during migrations: the app calls &lt;code&gt;legacy-db&lt;/code&gt; from day 1, the database moves into the cluster later, and the app config never changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  DNS: call a Service by its name
&lt;/h2&gt;

&lt;p&gt;Every Service gets a DNS record:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
web.shop.svc.cluster.local&lt;br&gt;
 |    |&lt;br&gt;
 |    namespace&lt;br&gt;
 Service name&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What to type, by where the client runs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Client is in&lt;/th&gt;
&lt;th&gt;Name to use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The same namespace&lt;/td&gt;
&lt;td&gt;&lt;code&gt;web&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Another namespace&lt;/td&gt;
&lt;td&gt;&lt;code&gt;web.shop&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Anywhere, spelled out&lt;/td&gt;
&lt;td&gt;&lt;code&gt;web.shop.svc.cluster.local&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The short name works because each Pod's &lt;code&gt;/etc/resolv.conf&lt;/code&gt; carries 3 Kubernetes search domains, starting with its own namespace, and &lt;code&gt;ndots:5&lt;/code&gt;. (&lt;code&gt;cluster.local&lt;/code&gt; is the default cluster domain. Yours can differ.)&lt;/p&gt;

&lt;p&gt;A bare &lt;code&gt;web&lt;/code&gt; resolves only inside the Service's own namespace. A team that copies a config from one &lt;a href="https://meteorops.com/blog/kubernetes-namespace" rel="noopener noreferrer"&gt;namespace&lt;/a&gt; to another finds this out fast.&lt;/p&gt;

&lt;p&gt;A normal Service resolves to its cluster IP. A headless Service resolves to the IPs of all its ready Pods. Named ports also get SRV records (DNS records that carry a port).&lt;/p&gt;

&lt;p&gt;Kubernetes also injects environment variables such as &lt;code&gt;WEB_SERVICE_HOST&lt;/code&gt; and &lt;code&gt;WEB_SERVICE_PORT&lt;/code&gt; into Pods. They exist only for Services created before the Pod started. Use DNS.&lt;/p&gt;

&lt;h2&gt;
  
  
  How traffic gets from the Service IP to a Pod
&lt;/h2&gt;

&lt;p&gt;kube-proxy runs on every node. It watches Services and EndpointSlices and programs the node's kernel to redirect Service traffic.&lt;/p&gt;

&lt;p&gt;It works at layer 4, the transport layer: TCP, UDP and SCTP.&lt;/p&gt;

&lt;p&gt;The path of a connection, in the default iptables mode:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Pod opens a connection to the Service IP and port&lt;/li&gt;
&lt;li&gt;A rule on the node picks 1 backend Pod at random&lt;/li&gt;
&lt;li&gt;The destination is rewritten to that Pod's IP and &lt;code&gt;targetPort&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Every packet of that connection goes to the same Pod&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The 3 modes on Linux, as of v1.37:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;What to do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;iptables&lt;/td&gt;
&lt;td&gt;The default in v1.37. A future version changes the default to nftables&lt;/td&gt;
&lt;td&gt;Set the mode explicitly, so an upgrade does not switch it for you&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;nftables&lt;/td&gt;
&lt;td&gt;Stable since v1.33. Needs kernel 5.13 or newer&lt;/td&gt;
&lt;td&gt;The direction to plan for. Rule updates are faster on large clusters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ipvs&lt;/td&gt;
&lt;td&gt;Deprecated since v1.35. Planned: off by default in v1.40, gone by v1.43 at the latest&lt;/td&gt;
&lt;td&gt;Migrate to nftables&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To see what a kubeadm cluster runs:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
kubectl -n kube-system get configmap kube-proxy \&lt;br&gt;
  -o jsonpath='{.data.config\.conf}' | grep 'mode:'&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;An empty &lt;code&gt;mode: ""&lt;/code&gt; means the default, iptables.&lt;/p&gt;

&lt;p&gt;kube-proxy is the default, and it can be replaced. Cilium, for example, can take over its job completely. The Service API stays the same for you.&lt;/p&gt;

&lt;h3&gt;
  
  
  gRPC and HTTP/2 stick to 1 Pod
&lt;/h3&gt;

&lt;p&gt;The backend is picked when the connection opens.&lt;/p&gt;

&lt;p&gt;An HTTP/1.1 connection carries 1 request at a time, so clients open several connections and replace them often, and requests spread out. A gRPC client opens 1 long-lived HTTP/2 connection and sends every request over it.&lt;/p&gt;

&lt;p&gt;The result: 1 client, 5 Pods, and 1 of them does all of that client's work. (The other 4 are very relaxed.)&lt;/p&gt;

&lt;p&gt;The 2 fixes the Kubernetes blog describes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A headless Service, and a client that balances across the Pod IPs it gets from DNS&lt;/li&gt;
&lt;li&gt;A proxy or service mesh that balances per request&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Session affinity and traffic distribution
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sessionAffinity: ClientIP&lt;/code&gt; sends a client IP to the same Pod. The timeout defaults to 10800 seconds (3 hours). Affinity by cookie or header does not exist at this layer&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;trafficDistribution: PreferSameZone&lt;/code&gt; keeps traffic in the client's zone when a Pod is available there, and falls back to the whole cluster. Stable since v1.35. It can cut cross-zone data transfer cost&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;trafficDistribution: PreferSameNode&lt;/code&gt; prefers a Pod on the same node, then the zone, then the cluster&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;internalTrafficPolicy: Local&lt;/code&gt; is strict: with no Pod on the client's node, the traffic is dropped&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Only ready Pods receive traffic
&lt;/h2&gt;

&lt;p&gt;Readiness is the switch between a Pod and its Services.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Pod passes its readiness probe → its IP is a ready endpoint&lt;/li&gt;
&lt;li&gt;A Pod fails its readiness probe → its endpoint is marked not ready, and every Service that matches it stops sending it traffic&lt;/li&gt;
&lt;li&gt;A Pod with no readiness probe counts as ready when its containers run, even while the app is still booting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo941fkss2uh2zrhctwdg.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo941fkss2uh2zrhctwdg.webp" alt="Only ready Pods receive traffic from a Kubernetes Service: 2 ready Pods get connections, and a Pod whose readiness probe fails gets no traffic" width="799" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The readiness probe decides who gets traffic.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Each endpoint in an EndpointSlice has 3 conditions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;serving&lt;/td&gt;
&lt;td&gt;The Pod is passing its readiness check&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;terminating&lt;/td&gt;
&lt;td&gt;The Pod is being deleted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ready&lt;/td&gt;
&lt;td&gt;serving and not terminating&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;During shutdown, 2 things run in parallel: the kubelet starts stopping the containers, and the control plane marks the endpoint as not ready.&lt;/p&gt;

&lt;p&gt;In parallel means a Pod can receive a few more connections after it got SIGTERM. The usual fix is a short preStop sleep and a graceful shutdown.&lt;/p&gt;

&lt;p&gt;One safety net: when all endpoints of a Service are terminating, proxies send traffic to the ones that are still serving. That keeps a rolling update from dropping everything.&lt;/p&gt;

&lt;p&gt;A Service with no endpoints at all: kube-proxy, in its iptables and nftables modes, rejects the connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  The client IP is lost on NodePort and LoadBalancer by default
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Traffic&lt;/th&gt;
&lt;th&gt;Source IP the Pod sees&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod to ClusterIP&lt;/td&gt;
&lt;td&gt;The client Pod's IP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NodePort, default&lt;/td&gt;
&lt;td&gt;A node IP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LoadBalancer, default&lt;/td&gt;
&lt;td&gt;A node IP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NodePort or LoadBalancer with &lt;code&gt;externalTrafficPolicy: Local&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The real client IP&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Why: with the default policy (&lt;code&gt;Cluster&lt;/code&gt;), any node accepts the traffic and may forward it to a Pod on another node. To get the reply back, the node replaces the source address with its own.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;externalTrafficPolicy: Local&lt;/code&gt; = a node sends traffic to its own Pods only.&lt;/p&gt;

&lt;p&gt;The trade-offs of Local:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nodes without a Pod of the Service fail the load balancer's health check and get no traffic&lt;/li&gt;
&lt;li&gt;The spread across Pods can be uneven: 1 Pod on node A gets as much as 3 Pods on node B&lt;/li&gt;
&lt;li&gt;No second hop between nodes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A load balancer that terminates the connection itself (a proxy) hides the client IP either way. There you read &lt;code&gt;X-Forwarded-For&lt;/code&gt;, or turn on the PROXY protocol (a header the load balancer adds with the client address).&lt;/p&gt;

&lt;h2&gt;
  
  
  A LoadBalancer Service costs money per Service on AWS
&lt;/h2&gt;

&lt;p&gt;On AWS, every LoadBalancer Service gets its own load balancer. AWS says it plainly: a Network Load Balancer cannot be shared across Services.&lt;/p&gt;

&lt;p&gt;(AKS works differently: Services share 1 Standard Load Balancer, and each one gets its own frontend IP.)&lt;/p&gt;

&lt;p&gt;The math, with the $0.0225 per hour from AWS's us-east-1 pricing examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 load balancer: $0.0225 x 730 hours = about $16.43 a month, before capacity units and data&lt;/li&gt;
&lt;li&gt;12 Services of type LoadBalancer: about $197 a month, before any traffic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The bill is the small problem. 12 public entry points = 12 places for TLS, firewall rules and DNS records.&lt;/p&gt;

&lt;p&gt;My rule: 1 load balancer per cluster for HTTP, and ClusterIP for everything behind it.&lt;/p&gt;

&lt;p&gt;How: 1 LoadBalancer Service in front of an Ingress or Gateway controller, which routes by host and path to ClusterIP Services.&lt;/p&gt;

&lt;h2&gt;
  
  
  Service vs Ingress vs Gateway API
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Ingress&lt;/th&gt;
&lt;th&gt;Gateway API&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Layer&lt;/td&gt;
&lt;td&gt;4: TCP, UDP, SCTP&lt;/td&gt;
&lt;td&gt;7: HTTP and HTTPS&lt;/td&gt;
&lt;td&gt;4 and 7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routes by&lt;/td&gt;
&lt;td&gt;IP and port&lt;/td&gt;
&lt;td&gt;Host and path&lt;/td&gt;
&lt;td&gt;Host, path, headers, and TCP or UDP routes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backends are&lt;/td&gt;
&lt;td&gt;Pods&lt;/td&gt;
&lt;td&gt;Services&lt;/td&gt;
&lt;td&gt;Services&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Status&lt;/td&gt;
&lt;td&gt;Stable&lt;/td&gt;
&lt;td&gt;Frozen: stable, kept, no new features&lt;/td&gt;
&lt;td&gt;The successor. v1.7.0 is the latest release (October 29, 2026)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Ingress is a way in for HTTP. It is a separate object from a Service, and it needs Services behind it.&lt;/p&gt;

&lt;p&gt;Non-HTTP traffic from outside (a database port, a message broker) goes through a NodePort or LoadBalancer Service, or through the Gateway API's TCP and UDP routes.&lt;/p&gt;

&lt;p&gt;The ingress-nginx project was retired in March 2026, and the Kubernetes project recommends Gateway over Ingress. For a new cluster I start with the Gateway API. The details are in the &lt;a href="https://meteorops.com/blog/kubernetes-ingress" rel="noopener noreferrer"&gt;Kubernetes Ingress guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  12 spec fields and their defaults
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;type&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ClusterIP&lt;/td&gt;
&lt;td&gt;ClusterIP, NodePort, LoadBalancer or ExternalName&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;selector&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;The Pod labels to match. Equality only. Empty = you manage the endpoints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ports[].port&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;required&lt;/td&gt;
&lt;td&gt;The port of the Service&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ports[].targetPort&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the value of &lt;code&gt;port&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The port on the Pod, by number or name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ports[].protocol&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TCP&lt;/td&gt;
&lt;td&gt;TCP, UDP or SCTP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ports[].nodePort&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;assigned from 30000 to 32767&lt;/td&gt;
&lt;td&gt;The port on every node&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;clusterIP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;assigned&lt;/td&gt;
&lt;td&gt;An IP from the Service range, or &lt;code&gt;None&lt;/code&gt; for headless. Cannot be changed later, except by a type change to or from ExternalName&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sessionAffinity&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;None or ClientIP (timeout 10800 seconds)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;externalTrafficPolicy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Cluster&lt;/td&gt;
&lt;td&gt;Cluster or Local, for traffic from outside&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;internalTrafficPolicy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Cluster&lt;/td&gt;
&lt;td&gt;Cluster or Local, for traffic from inside&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;trafficDistribution&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;unset: spread evenly&lt;/td&gt;
&lt;td&gt;PreferSameZone or PreferSameNode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ipFamilyPolicy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;SingleStack&lt;/td&gt;
&lt;td&gt;SingleStack, PreferDualStack or RequireDualStack&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;2 fields to stop using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;externalIPs&lt;/code&gt;: deprecated since v1.36 (the reason is CVE-2020-8554). The EXTERNAL-IP column of &lt;code&gt;kubectl get svc&lt;/code&gt; is a different thing and stays&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;loadBalancerIP&lt;/code&gt;: deprecated since v1.24. Use your provider's annotation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Debug a Service in 8 checks
&lt;/h2&gt;

&lt;p&gt;The checks come from the Kubernetes "Debug Services" page, reordered so the common causes come early. Checks 4, 5 and 7 run from a Pod inside the cluster:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
kubectl run -it --rm --restart=Never busybox \&lt;br&gt;
  --image=registry.k8s.io/busybox:1.27.2 sh&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;A failure means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;The Service exists&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get svc web&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;NotFound: nobody created it, or wrong name or namespace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;It has endpoints&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get endpointslices -l kubernetes.io/service-name=web&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Empty: the selector matches no Pod in this namespace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;The Pods are ready&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -l app=web&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;READY shows 0/1: the Pod matches and fails its readiness probe, so it gets no traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;DNS resolves&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;nslookup web&lt;/code&gt;, then &lt;code&gt;nslookup web.shop&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The client is in another namespace, or cluster DNS is down&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;The Service IP answers&lt;/td&gt;
&lt;td&gt;&lt;code&gt;wget -qO- 10.0.1.175:80&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;DNS is fine and the path behind it is broken: go on&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;The ports are right&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get service web -o json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Wrong &lt;code&gt;targetPort&lt;/code&gt;, a named port the Pods do not have, wrong protocol&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;The Pods answer directly&lt;/td&gt;
&lt;td&gt;&lt;code&gt;wget -qO- 10.244.0.5:8080&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The app is the problem. Use the Pod port here: 8080&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Nothing blocks the path&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl get networkpolicy&lt;/code&gt;, then kube-proxy logs on the node&lt;/td&gt;
&lt;td&gt;A NetworkPolicy that does not list the client, or kube-proxy is not running&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In a hurry, start with checks 2 and 3. A selector that matches nothing and Pods that are not ready are the 2 causes I see most often.&lt;/p&gt;

&lt;p&gt;The 2 usual causes of an empty list:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A label typo.&lt;/strong&gt; The Service selects &lt;code&gt;app=web&lt;/code&gt; and the Deployment labels its Pods &lt;code&gt;run=web&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The wrong namespace.&lt;/strong&gt; A Service selects Pods in its own namespace only&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Addresses are listed and the Service still does not answer → the Pods are not ready, or the port is wrong.&lt;/p&gt;

&lt;p&gt;2 notes on the commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;kubectl get endpoints&lt;/code&gt; still works and prints a deprecation warning since v1.33. The Endpoints API also cuts off at 1000 addresses. Use EndpointSlices&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl port-forward service/web 8080:80&lt;/code&gt; forwards to 1 Pod picked from the Service. It proves the Pod works. It does not test the Service's balancing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More commands, grouped by task, are in the &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet" rel="noopener noreferrer"&gt;kubectl cheat sheet&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed for Services in Kubernetes v1.33 to v1.37
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;v1.33:&lt;/strong&gt; nftables mode for kube-proxy became stable. The Endpoints API was deprecated in favor of EndpointSlices. &lt;code&gt;trafficDistribution&lt;/code&gt; became stable&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v1.35:&lt;/strong&gt; ipvs mode was deprecated. &lt;code&gt;PreferSameZone&lt;/code&gt; and &lt;code&gt;PreferSameNode&lt;/code&gt; became stable, and &lt;code&gt;PreferClose&lt;/code&gt; is now a deprecated alias of &lt;code&gt;PreferSameZone&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v1.36:&lt;/strong&gt; &lt;code&gt;externalIPs&lt;/code&gt; was deprecated&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v1.37:&lt;/strong&gt; a Service name may start with a digit. kube-proxy warns when no proxy mode is set explicitly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your notes about Services are from 2022, the commands still run, and 3 things they recommend are deprecated: the Endpoints API, ipvs mode and &lt;code&gt;externalIPs&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist before a Service takes production traffic
&lt;/h2&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ClusterIP unless something outside the cluster must connect&lt;/li&gt;
&lt;li&gt;The selector uses a label that only this app's Pods carry&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;targetPort&lt;/code&gt; points at a named container port&lt;/li&gt;
&lt;li&gt;Every port has a name&lt;/li&gt;
&lt;li&gt;The Pods have a readiness probe that reflects the app&lt;/li&gt;
&lt;li&gt;Clients call the DNS name, and the namespace is part of it across namespaces&lt;/li&gt;
&lt;li&gt;1 shared entry point for HTTP, through an Ingress or Gateway controller&lt;/li&gt;
&lt;li&gt;Internal load balancers carry the internal annotation of your cloud and of your controller&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;externalTrafficPolicy: Local&lt;/code&gt; where the app needs the client IP&lt;/li&gt;
&lt;li&gt;gRPC goes through a headless Service or a proxy that balances per request&lt;/li&gt;
&lt;li&gt;The kube-proxy mode is set explicitly, and no cluster still runs ipvs&lt;/li&gt;
&lt;li&gt;No &lt;code&gt;externalIPs&lt;/code&gt;, no &lt;code&gt;loadBalancerIP&lt;/code&gt;, no &lt;code&gt;kubectl get endpoints&lt;/code&gt; in scripts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Kubernetes Service FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a Kubernetes Service?
&lt;/h3&gt;

&lt;p&gt;A Service is the Kubernetes object that exposes an app running in 1 or more Pods under 1 stable IP address and DNS name. It finds its Pods by label and sends each new connection to one of the ready ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the 4 types of Services in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;ClusterIP, NodePort, LoadBalancer and ExternalName. ClusterIP is the default and is reachable inside the cluster only, NodePort opens a port on every node, LoadBalancer adds a cloud load balancer, and ExternalName is a DNS alias. A headless Service is a ClusterIP Service with &lt;code&gt;clusterIP: None&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a Service and a Deployment?
&lt;/h3&gt;

&lt;p&gt;A Deployment runs and replaces Pods. A Service gives those Pods a stable address. They are separate objects linked only by labels, and most apps need both.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between ClusterIP, NodePort and LoadBalancer?
&lt;/h3&gt;

&lt;p&gt;Each one includes the previous. ClusterIP is an internal virtual IP, NodePort adds a port from 30000 to 32767 on every node, and LoadBalancer adds an external load balancer from your cloud provider that forwards to those nodes.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between port, targetPort and nodePort?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;port&lt;/code&gt; is the port clients call on the Service. &lt;code&gt;targetPort&lt;/code&gt; is the port the container listens on, and it defaults to &lt;code&gt;port&lt;/code&gt;. &lt;code&gt;nodePort&lt;/code&gt; is the port opened on every node for NodePort and LoadBalancer Services.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need an Ingress if I have a LoadBalancer Service?
&lt;/h3&gt;

&lt;p&gt;For 1 HTTP app, no. For several, yes: an Ingress or Gateway controller behind 1 load balancer routes by host and path, and you stop paying for a load balancer per app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does my Service have no endpoints?
&lt;/h3&gt;

&lt;p&gt;The selector does not match the labels of any Pod in the Service's namespace. Compare &lt;code&gt;kubectl describe svc NAME&lt;/code&gt; with &lt;code&gt;kubectl get pods --show-labels&lt;/code&gt;. If the addresses are listed and traffic still fails, check whether the Pods pass their readiness probe.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does a Kubernetes Service load balance?
&lt;/h3&gt;

&lt;p&gt;Yes, per connection: each new connection goes to a ready Pod picked at random. Requests inside 1 long-lived connection, as with gRPC, all go to the same Pod.&lt;/p&gt;

&lt;h2&gt;
  
  
  A recap
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing, let it be this:&lt;/p&gt;

&lt;p&gt;A Service is a label selector with a stable address. When it breaks, check the selector, the readiness probe and the port.&lt;/p&gt;

&lt;p&gt;You don't need a DevOps expert for that. The YAML above and the 8 checks cover most cases.&lt;/p&gt;

&lt;p&gt;If you would like a second pair of eyes on your cluster networking anyway (yes, I sell DevOps engineers), the &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt; is where a senior engineer reviews your Kubernetes and cloud setup.&lt;/p&gt;

&lt;p&gt;Related guides: &lt;a href="https://meteorops.com/blog/kubernetes-deployment" rel="noopener noreferrer"&gt;Kubernetes Deployment&lt;/a&gt;, &lt;a href="https://meteorops.com/blog/kubernetes-ingress" rel="noopener noreferrer"&gt;Kubernetes Ingress&lt;/a&gt; and &lt;a href="https://meteorops.com/blog/kubernetes-vs-docker" rel="noopener noreferrer"&gt;Kubernetes vs Docker&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>CI/CD Pipeline: Stages, an Example and What to Build First</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Tue, 01 Dec 2026 15:30:34 +0000</pubDate>
      <link>https://dev.to/meteorops/cicd-pipeline-stages-an-example-and-what-to-build-first-3ip0</link>
      <guid>https://dev.to/meteorops/cicd-pipeline-stages-an-example-and-what-to-build-first-3ip0</guid>
      <description>&lt;p&gt;Liquid syntax error: Unknown tag 'endraw'&lt;/p&gt;
</description>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes Deployment: How Rollouts and Rollbacks Work</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Mon, 30 Nov 2026 15:30:08 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-deployment-how-rollouts-and-rollbacks-work-122b</link>
      <guid>https://dev.to/meteorops/kubernetes-deployment-how-rollouts-and-rollbacks-work-122b</guid>
      <description>&lt;p&gt;A Kubernetes Deployment keeps a set of identical Pods running and replaces them gradually when you ship a new version. 5 things to know before you trust it with a release:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Deployment = the desired state of an app, usually a stateless one.&lt;/strong&gt; Which image, how many copies, how to replace them. A controller moves the cluster to that state&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deployment → ReplicaSet → Pods.&lt;/strong&gt; Every version of your Pod template gets its own ReplicaSet. A rollout scales the new one up and the old one down&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A rollout starts ONLY when &lt;code&gt;.spec.template&lt;/code&gt; changes.&lt;/strong&gt; Scaling does not start one, and a rollback restores the template and nothing else&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Readiness is the brake.&lt;/strong&gt; The rollout waits for new Pods to become ready. A Pod with no readiness probe counts as ready the moment its containers run&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A stuck rollout is reported and left alone.&lt;/strong&gt; After 600 seconds without progress you get a condition. Kubernetes does not roll back for you&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A small Deployment that works, on Kubernetes v1.37:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: registry.example.com/web:1.4.2
        ports:
        - containerPort: 8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 4 commands you will use most:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f deployment.yaml
kubectl rollout status deployment/web
kubectl rollout history deployment/web
kubectl rollout undo deployment/web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Rollouts that hang, or releases that drop requests?&lt;/strong&gt; Get a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt;: a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are writing your first manifest: &lt;a href="https://meteorops.com/blog/kubernetes-deployment#a-deployment-yaml-you-can-copy" rel="noopener noreferrer"&gt;a Deployment YAML you can copy&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A rollout is stuck right now: &lt;a href="https://meteorops.com/blog/kubernetes-deployment#a-stuck-rollout-is-reported-and-never-rolled-back" rel="noopener noreferrer"&gt;read the conditions and the 6 causes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You need to go back to the previous version: &lt;a href="https://meteorops.com/blog/kubernetes-deployment#roll-back-restart-and-pause-with-kubectl-rollout" rel="noopener noreferrer"&gt;roll back with kubectl rollout&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Releases drop a few requests every time: &lt;a href="https://meteorops.com/blog/kubernetes-deployment#readiness-and-termination-decide-whether-a-rollout-drops-requests" rel="noopener noreferrer"&gt;readiness and termination&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are choosing between a Deployment and a StatefulSet: &lt;a href="https://meteorops.com/blog/kubernetes-deployment#deployment-vs-statefulset-daemonset-job-and-a-bare-pod" rel="noopener noreferrer"&gt;the comparison table&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You want every field with its default: &lt;a href="https://meteorops.com/blog/kubernetes-deployment#the-10-spec-fields-and-their-defaults" rel="noopener noreferrer"&gt;the 10 spec fields&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A Deployment manages ReplicaSets, and ReplicaSets manage Pods
&lt;/h2&gt;

&lt;p&gt;You declare a state. The Deployment controller changes the actual state to match it, at a controlled rate.&lt;/p&gt;

&lt;p&gt;Deployment = which Pod template, how many replicas, how to replace them.&lt;/p&gt;

&lt;p&gt;ReplicaSet = keep N Pods of exactly 1 template version alive.&lt;/p&gt;

&lt;p&gt;Pod = the containers that run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwv94np3927y1cq8sktud.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwv94np3927y1cq8sktud.webp" alt="Kubernetes Deployment to ReplicaSet to Pods: a Deployment holds the template, replicas and strategy, the new ReplicaSet runs 3 Pods, the old ReplicaSet is kept at 0 Pods for rollback" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;1 ReplicaSet per version of the Pod template. The old one is your rollback.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The chain shows up in the names:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get deployment,rs,pods -l app=web
NAME                  READY   UP-TO-DATE   AVAILABLE
deployment.apps/web   3/3     3            3

NAME                             DESIRED   CURRENT   READY
replicaset.apps/web-75675f5897   3         3         3

NAME                       READY   STATUS
pod/web-75675f5897-7ci7o   1/1     Running
pod/web-75675f5897-kzszj   1/1     Running
pod/web-75675f5897-qqcnn   1/1     Running
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A ReplicaSet created by a Deployment is named &lt;code&gt;[deployment name]-[hash]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The hash is the &lt;code&gt;pod-template-hash&lt;/code&gt; label: a hash of the Pod template that the controller adds to the ReplicaSet, to its selector and to every Pod. Leave that label alone.&lt;/p&gt;

&lt;p&gt;The 3 columns of &lt;code&gt;kubectl get deployments&lt;/code&gt; that matter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;READY:&lt;/strong&gt; ready replicas out of desired replicas&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UP-TO-DATE:&lt;/strong&gt; replicas already on the newest template&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AVAILABLE:&lt;/strong&gt; replicas your users can reach&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2 rules follow from the chain:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Edit the Deployment and never the ReplicaSets it owns. The docs say the same&lt;/li&gt;
&lt;li&gt;Deleting a Deployment deletes its Pods. &lt;code&gt;kubectl delete deployment web --cascade=orphan&lt;/code&gt; keeps them&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Kill a Pod, or lose a node, and the ReplicaSet creates a replacement on a node that has room. A bare Pod gets no such favor: when its node dies, it stays dead.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Deployment YAML you can copy
&lt;/h2&gt;

&lt;p&gt;Only 2 fields are required: &lt;code&gt;.spec.selector&lt;/code&gt; and &lt;code&gt;.spec.template&lt;/code&gt;. Everything else has a default.&lt;/p&gt;

&lt;p&gt;The defaults keep a demo alive. This is the version I would put in front of customers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 3
  revisionHistoryLimit: 5
  progressDeadlineSeconds: 300
  minReadySeconds: 10
  selector:
    matchLabels:
      app: web
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: web
    spec:
      terminationGracePeriodSeconds: 45
      topologySpreadConstraints:
      - maxSkew: 1
        topologyKey: topology.kubernetes.io/zone
        whenUnsatisfiable: ScheduleAnyway
        labelSelector:
          matchLabels:
            app: web
        matchLabelKeys:
        - pod-template-hash
      containers:
      - name: web
        image: registry.example.com/web:1.4.2
        ports:
        - containerPort: 8080
        resources:
          requests:
            cpu: 250m
            memory: 256Mi
          limits:
            memory: 256Mi
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
          periodSeconds: 5
        lifecycle:
          preStop:
            sleep:
              seconds: 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What each addition buys you:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Line&lt;/th&gt;
&lt;th&gt;Why it is there&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;maxUnavailable: 0&lt;/code&gt;, &lt;code&gt;maxSurge: 1&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Capacity never drops during a rollout. 1 extra Pod at a time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;readinessProbe&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The rollout and the Service wait for the app, where the default waits only for the process&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;minReadySeconds: 10&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A Pod that crashes 3 seconds after start never counts as available&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;progressDeadlineSeconds: 300&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The pipeline hears about a stuck rollout after 5 minutes, where the default is 10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;preStop&lt;/code&gt; sleep&lt;/td&gt;
&lt;td&gt;Old Pods keep serving while the endpoints update, then get the stop signal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;resources.requests&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The scheduler places Pods by requests, and CPU autoscaling needs them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;topologySpreadConstraints&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Asks the scheduler to spread replicas across zones. &lt;code&gt;ScheduleAnyway&lt;/code&gt; is a preference, &lt;code&gt;DoNotSchedule&lt;/code&gt; makes it a rule. &lt;code&gt;matchLabelKeys&lt;/code&gt; is beta and on by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A fixed image tag&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;:latest&lt;/code&gt; makes a rollback hard, and the docs advise against it in production&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The numbers in it are starting points. The &lt;a href="https://meteorops.com/blog/how-to-set-kubernetes-resource-requests-and-limits-without-throttling-apps" rel="noopener noreferrer"&gt;requests and limits guide&lt;/a&gt; covers how to size the resources block.&lt;/p&gt;

&lt;p&gt;3 details that surprise people:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The selector must match the template labels, or the API rejects the Deployment&lt;/li&gt;
&lt;li&gt;The selector is immutable in &lt;code&gt;apps/v1&lt;/code&gt;. To change it you delete the Deployment and create it again&lt;/li&gt;
&lt;li&gt;The Pod template of a Deployment accepts only &lt;code&gt;restartPolicy: Always&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And 1 that hurts: Kubernetes does not stop 2 controllers from using overlapping selectors. If another Deployment selects &lt;code&gt;app: web&lt;/code&gt;, the 2 controllers fight over the same Pods. Give every Deployment labels that are its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Only a template change starts a rollout
&lt;/h2&gt;

&lt;p&gt;Rollout = a new ReplicaSet for a new Pod template.&lt;/p&gt;

&lt;p&gt;The docs are exact about the trigger: a rollout starts if and only if &lt;code&gt;.spec.template&lt;/code&gt; changes.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You change&lt;/th&gt;
&lt;th&gt;New ReplicaSet&lt;/th&gt;
&lt;th&gt;New revision&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Image, env, resources, labels or annotations of the template&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;replicas&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;strategy&lt;/code&gt;, &lt;code&gt;minReadySeconds&lt;/code&gt;, &lt;code&gt;revisionHistoryLimit&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A ConfigMap or Secret the Pods read&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last row is the one that bites. The ConfigMap sits outside the template, so editing it changes no Deployment and running Pods keep the environment variables they started with. (Files from a mounted ConfigMap do update in place, after a delay.)&lt;/p&gt;

&lt;p&gt;That is what &lt;code&gt;kubectl rollout restart&lt;/code&gt; is for (more on it below).&lt;/p&gt;

&lt;p&gt;What happens on &lt;code&gt;kubectl set image deployment/web web=registry.example.com/web:1.4.3&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;Template changes → new hash → new ReplicaSet at 0 → new scales up, old scales down → old ReplicaSet stays at 0 replicas as history&lt;/p&gt;

&lt;p&gt;The old ReplicaSet is the rollback. A Deployment keeps 10 of them by default (&lt;code&gt;revisionHistoryLimit&lt;/code&gt;). Set it to 0 and there is nothing to roll back to.&lt;/p&gt;

&lt;p&gt;2 edge cases the docs name:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rollover:&lt;/strong&gt; update again in the middle of a rollout and the controller starts a third ReplicaSet at once. The half-finished one is scaled down with the old one. It does not wait&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proportional scaling:&lt;/strong&gt; scale in the middle of a rollout and the extra replicas are split across the active ReplicaSets, the larger share to the larger one&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Rolling update math: maxSurge and maxUnavailable
&lt;/h2&gt;

&lt;p&gt;A Deployment has exactly 2 strategies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;RollingUpdate (the default):&lt;/strong&gt; new Pods come up while old ones go down. Both versions serve traffic for a while&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recreate:&lt;/strong&gt; every old Pod is killed before a new one is created. There is downtime&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;RollingUpdate is steered by 2 numbers, and both default to 25%:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;maxSurge:&lt;/strong&gt; how many Pods above &lt;code&gt;replicas&lt;/code&gt; may exist. A percentage rounds up&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;maxUnavailable:&lt;/strong&gt; how many Pods below &lt;code&gt;replicas&lt;/code&gt; may be unavailable. A percentage rounds down&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rounding is why small Deployments behave differently from what "25%" suggests:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Replicas&lt;/th&gt;
&lt;th&gt;maxSurge 25%&lt;/th&gt;
&lt;th&gt;maxUnavailable 25%&lt;/th&gt;
&lt;th&gt;During the rollout&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;At least 3 available, at most 4 in total&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Between 3 and 5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;At least 8 available, at most 13 in total&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;With 3 replicas and the defaults, the documented sequence is:&lt;/p&gt;

&lt;p&gt;new 1 → old 2 → new 2 → old 1 → new 3 → old 0&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo71ddsj0azpfef2x609e.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo71ddsj0azpfef2x609e.webp" alt="Kubernetes rolling update with 3 replicas: maxSurge 25% rounds up to 1, maxUnavailable 25% rounds down to 0, so at least 3 Pods are available and at most 4 exist" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The first 2 steps and the end state. 25% of 3 is 1 extra Pod and 0 missing Pods.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The controller never kills an old Pod until enough new ones are up, and never creates a new Pod until enough old ones are gone.&lt;/p&gt;

&lt;p&gt;The 2 numbers cannot both be 0 (nothing could move).&lt;/p&gt;

&lt;p&gt;How I pick them:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Goal&lt;/th&gt;
&lt;th&gt;maxSurge&lt;/th&gt;
&lt;th&gt;maxUnavailable&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Never lose capacity (most web services)&lt;/td&gt;
&lt;td&gt;1 or 25%&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The cluster has no spare room for extra Pods&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;50 replicas and you want it fast&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2 versions must never run together&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;Recreate&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;Recreate&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;1 thing the numbers leave out: Pods that are still shutting down.&lt;/p&gt;

&lt;p&gt;A terminating Pod is no longer counted as available, yet it still holds CPU and memory until it exits. So a rollout can briefly use more than &lt;code&gt;replicas + maxSurge&lt;/code&gt; worth of resources. Since v1.35 the Deployment reports them in &lt;code&gt;status.terminatingReplicas&lt;/code&gt; (beta, on by default).&lt;/p&gt;

&lt;p&gt;Recreate has fine print too. Its "old first, then new" promise holds for upgrades only. Delete a Pod by hand and the replacement is created at once, before the old one is gone. For "at most 1 copy, always", the docs point you to a StatefulSet.&lt;/p&gt;

&lt;p&gt;Rolling, Recreate, blue green and canary are compared in the &lt;a href="https://meteorops.com/blog/deployment-strategies" rel="noopener noreferrer"&gt;deployment strategies guide&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Readiness and termination decide whether a rollout drops requests
&lt;/h2&gt;

&lt;p&gt;A rolling update is as careful as your readiness signal. Argo's docs say it in 1 line: the rolling update gives you a basic set of safety guarantees, and they are readiness probes.&lt;/p&gt;

&lt;p&gt;Available = ready for at least &lt;code&gt;minReadySeconds&lt;/code&gt; (default 0).&lt;/p&gt;

&lt;p&gt;With no probe configured, the probe result counts as success. So a Pod with no readiness probe is ready as soon as its containers run, whether the app inside can answer or cannot.&lt;/p&gt;

&lt;p&gt;What each probe does when it fails:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Probe&lt;/th&gt;
&lt;th&gt;On failure&lt;/th&gt;
&lt;th&gt;Effect on a rollout&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Readiness&lt;/td&gt;
&lt;td&gt;Pod leaves the Service endpoints. No restart&lt;/td&gt;
&lt;td&gt;The rollout waits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Startup&lt;/td&gt;
&lt;td&gt;The container is killed. Liveness and readiness are held back until it passes&lt;/td&gt;
&lt;td&gt;The rollout waits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Liveness&lt;/td&gt;
&lt;td&gt;The container is restarted&lt;/td&gt;
&lt;td&gt;None directly. A bad one causes restart loops&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Probe defaults: every 10 seconds, 1 second timeout, 3 failures in a row to fail. The &lt;a href="https://meteorops.com/blog/how-to-configure-kubernetes-liveness-probes-without-causing-restart-loops" rel="noopener noreferrer"&gt;liveness probes guide&lt;/a&gt; has the settings that avoid restart loops.&lt;/p&gt;

&lt;p&gt;The other half is how the old Pods leave. When a Pod is deleted:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Pod is marked terminating and the grace period starts (&lt;code&gt;terminationGracePeriodSeconds&lt;/code&gt;, 30 seconds by default)&lt;/li&gt;
&lt;li&gt;At the same time, its endpoint is marked &lt;code&gt;ready: false&lt;/code&gt; so Services stop sending new traffic&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;preStop&lt;/code&gt; hook runs, if there is one&lt;/li&gt;
&lt;li&gt;The container gets SIGTERM&lt;/li&gt;
&lt;li&gt;When the grace period ends, whatever is still running gets SIGKILL&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo9wtcn1w5avc2zbt6dil.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo9wtcn1w5avc2zbt6dil.webp" alt="What happens when a Kubernetes Pod is deleted: the endpoint is marked ready false, the preStop hook runs, the app gets SIGTERM, and SIGKILL arrives when the 30 second grace period ends" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The hook and the shutdown share 1 grace period.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Steps 2 and 3 run in parallel. That is the gap where requests die: the app gets SIGTERM while a load balancer still holds its address.&lt;/p&gt;

&lt;p&gt;The fix is a &lt;code&gt;preStop&lt;/code&gt; sleep. I use 5 to 15 seconds. The Pod keeps serving while the endpoints update, then shuts down.&lt;/p&gt;

&lt;p&gt;The grace period countdown includes the hook. The docs' example: a 60 second grace period, a hook that takes 55 seconds and an app that needs 10 seconds to stop = the app is killed 5 seconds early. (If the hook itself is still running when the grace period ends, the kubelet adds 2 seconds, once. Do not plan around it.)&lt;/p&gt;

&lt;p&gt;Grace period &amp;gt; preStop sleep + the time your app needs to finish its requests.&lt;/p&gt;
&lt;h2&gt;
  
  
  A stuck rollout is reported and never rolled back
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;progressDeadlineSeconds&lt;/code&gt; defaults to 600. If a rollout makes no progress for that long, the Deployment gets this condition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Type:    Progressing
Status:  False
Reason:  ProgressDeadlineExceeded
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is all it does. The docs are explicit: Kubernetes takes no action on a stalled Deployment other than reporting the condition. It keeps retrying, and the old Pods that &lt;code&gt;maxUnavailable&lt;/code&gt; did not release keep serving.&lt;/p&gt;

&lt;p&gt;(A smoke detector with no sprinkler.)&lt;/p&gt;

&lt;p&gt;The good news is in the same design: a bad rollout stops on its own. In the docs' example of an image tag with a typo, 1 new Pod sits in ImagePullBackOff and the 3 old Pods keep running.&lt;/p&gt;

&lt;p&gt;How to read a Deployment's conditions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;th&gt;Reason&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Progressing = True&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ReplicaSetUpdated&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A rollout is running&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Progressing = True&lt;/td&gt;
&lt;td&gt;&lt;code&gt;NewReplicaSetAvailable&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The rollout is complete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Progressing = False&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ProgressDeadlineExceeded&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stuck&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Available = True&lt;/td&gt;
&lt;td&gt;&lt;code&gt;MinimumReplicasAvailable&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Enough Pods are up for the strategy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ReplicaFailure = True&lt;/td&gt;
&lt;td&gt;&lt;code&gt;FailedCreate&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pods cannot be created, a quota for example&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Progressing stays True after a rollout completes, so read the reason and never the status alone.&lt;/p&gt;

&lt;p&gt;The docs list 6 causes of a failed Deployment. The symptoms next to them are where I would look first:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cause&lt;/th&gt;
&lt;th&gt;What you see&lt;/th&gt;
&lt;th&gt;Where to look&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Image pull errors&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;ImagePullBackOff&lt;/code&gt;, the wait between pulls grows up to 5 minutes&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe pod&lt;/code&gt;: image name, pull secret&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Readiness probe failures&lt;/td&gt;
&lt;td&gt;Pods Running, 0/1 ready&lt;/td&gt;
&lt;td&gt;The probe path and port, the app logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application runtime misconfiguration&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;CrashLoopBackOff&lt;/code&gt;: restarts after 10 s, 20 s, 40 s, up to 5 minutes by default&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs --previous&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Insufficient quota&lt;/td&gt;
&lt;td&gt;ReplicaFailure, "exceeded quota"&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe deployment&lt;/code&gt; for the condition, &lt;code&gt;kubectl get deployment web -o yaml&lt;/code&gt; for the message&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Limit ranges&lt;/td&gt;
&lt;td&gt;Pods rejected at admission&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe rs&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Insufficient permissions&lt;/td&gt;
&lt;td&gt;Pods never created&lt;/td&gt;
&lt;td&gt;Events on the ReplicaSet&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A seventh from daily life: Pods stuck in Pending because no node has room for the surge Pod. &lt;code&gt;kubectl describe pod&lt;/code&gt; shows the scheduler's reason.&lt;/p&gt;

&lt;p&gt;In a pipeline, make the rollout the test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f deployment.yaml
kubectl rollout status deployment/web --timeout=5m || {
  kubectl rollout undo deployment/web
  exit 1
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;kubectl rollout status&lt;/code&gt; exits 0 when the rollout completes. It exits non-zero in 2 cases: the Deployment passed its progress deadline, or &lt;code&gt;--timeout&lt;/code&gt; ran out first.&lt;/p&gt;

&lt;p&gt;Progress deadline = time with no progress. &lt;code&gt;--timeout&lt;/code&gt; = total time you are willing to wait.&lt;/p&gt;

&lt;p&gt;Set &lt;code&gt;--timeout&lt;/code&gt; above your longest healthy rollout, or the script undoes a release that was only slow.&lt;/p&gt;

&lt;p&gt;That exit code is your automatic rollback, the one Kubernetes leaves to you.&lt;/p&gt;

&lt;p&gt;The command names live in the &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet" rel="noopener noreferrer"&gt;kubectl cheat sheet&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roll back, restart and pause with kubectl rollout
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;kubectl rollout&lt;/code&gt; works on Deployments, DaemonSets and StatefulSets. It has 6 subcommands (pause and resume are for Deployments only). The 7 forms you will type:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout status deployment/web&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Watches until the rollout is done or failed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout history deployment/web&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Lists the revisions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout history deployment/web --revision=2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shows the Pod template of revision 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout undo deployment/web&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Goes back to the previous revision&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout undo deployment/web --to-revision=2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Goes back to revision 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout restart deployment/web&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Replaces every Pod with the same template&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;kubectl rollout pause&lt;/code&gt; / &lt;code&gt;resume deployment/web&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Holds rollouts, then releases them&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Rollback
&lt;/h3&gt;

&lt;p&gt;Rollback = scale an old ReplicaSet back up.&lt;/p&gt;

&lt;p&gt;It restores the Pod template only. The replica count and the strategy stay as they are.&lt;/p&gt;

&lt;p&gt;It also creates a new revision. In the docs' example, going back to revision 2 turns it into revision 4.&lt;/p&gt;

&lt;p&gt;The CHANGE-CAUSE column of the history is empty (`&lt;code&gt;) until you fill it. The old&lt;/code&gt;--record` flag is deprecated. Set the annotation:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
kubectl annotate deployment/web kubernetes.io/change-cause="web 1.4.3, payment retry fix"&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;My position on &lt;code&gt;rollout undo&lt;/code&gt;: use it to stop the bleeding, then revert the commit.&lt;/p&gt;

&lt;p&gt;After an undo, the cluster runs 1.4.2 and Git says 1.4.3. The next &lt;code&gt;kubectl apply&lt;/code&gt; or GitOps sync ships the broken version again. kubectl has warned about exactly this since v1.36 when you undo a resource managed with &lt;code&gt;kubectl apply&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Restart
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;kubectl rollout restart&lt;/code&gt; adds a &lt;code&gt;kubectl.kubernetes.io/restartedAt&lt;/code&gt; annotation to the Pod template.&lt;/p&gt;

&lt;p&gt;The template changed, so a normal rolling update runs: same image, new Pods, same surge and readiness rules.&lt;/p&gt;

&lt;p&gt;When to use it: a ConfigMap or Secret changed, or you want fresh Pods without downtime. Deleting Pods by hand skips the rollout rules. Restart keeps them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pause
&lt;/h3&gt;

&lt;p&gt;Pause to make several template changes and pay for 1 rollout:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
kubectl rollout pause deployment/web&lt;br&gt;
kubectl set image deployment/web web=registry.example.com/web:1.4.3&lt;br&gt;
kubectl set resources deployment/web -c web --requests=cpu=500m&lt;br&gt;
kubectl rollout resume deployment/web&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Existing Pods keep running while it is paused. 2 limits: a paused Deployment cannot be rolled back until you resume it, and its progress deadline is not checked.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 10 spec fields and their defaults
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;What it controls&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;replicas&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;How many Pods&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;selector&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Required&lt;/td&gt;
&lt;td&gt;Which Pods belong to it. Immutable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;template&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Required&lt;/td&gt;
&lt;td&gt;The Pod. Changing it starts a rollout&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;strategy.type&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;RollingUpdate&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;RollingUpdate or Recreate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;strategy.rollingUpdate.maxSurge&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;25%, rounds up&lt;/td&gt;
&lt;td&gt;Extra Pods allowed during a rollout&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;strategy.rollingUpdate.maxUnavailable&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;25%, rounds down&lt;/td&gt;
&lt;td&gt;Missing Pods allowed during a rollout&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;minReadySeconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;How long a Pod must stay ready to count as available&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;progressDeadlineSeconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;600&lt;/td&gt;
&lt;td&gt;When a rollout is reported as stuck. Must be greater than &lt;code&gt;minReadySeconds&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;revisionHistoryLimit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;Old ReplicaSets kept for rollback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;paused&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;td&gt;Template changes start no rollout while true&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you learned Deployments before 2019: the old API versions (&lt;code&gt;extensions/v1beta1&lt;/code&gt;, &lt;code&gt;apps/v1beta1&lt;/code&gt;, &lt;code&gt;apps/v1beta2&lt;/code&gt;) have not been served since v1.16. The oldest, &lt;code&gt;extensions/v1beta1&lt;/code&gt;, had different defaults: surge and unavailable of 1, no progress deadline, every old ReplicaSet kept. One of the official basics tutorials still says the default is "one".&lt;/p&gt;

&lt;h2&gt;
  
  
  Scaling, the HorizontalPodAutoscaler and PodDisruptionBudgets
&lt;/h2&gt;

&lt;p&gt;Scaling is 1 command, and it starts no rollout:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
kubectl scale deployment/web --replicas=5&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--replicas=0&lt;/code&gt; removes every Pod and keeps the Deployment and its ReplicaSet. Useful for parking an environment overnight.&lt;/p&gt;

&lt;h3&gt;
  
  
  With an autoscaler, delete the replicas line
&lt;/h3&gt;

&lt;p&gt;The HorizontalPodAutoscaler (HPA) writes &lt;code&gt;.spec.replicas&lt;/code&gt; on the Deployment. Your manifest writes it too.&lt;/p&gt;

&lt;p&gt;HPA scales to 9 → you run &lt;code&gt;kubectl apply&lt;/code&gt; with &lt;code&gt;replicas: 3&lt;/code&gt; → 6 Pods are killed → HPA scales back up&lt;/p&gt;

&lt;p&gt;The docs' advice: when an HPA manages a Deployment, leave &lt;code&gt;spec.replicas&lt;/code&gt; out of the manifest.&lt;/p&gt;

&lt;p&gt;1 trap on the way there. If the Deployment was created with &lt;code&gt;kubectl apply&lt;/code&gt;, deleting the line and applying scales it to 1 Pod, once (1 is the default of the field).&lt;/p&gt;

&lt;p&gt;The docs' way around it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
kubectl apply edit-last-applied deployment/web&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Remove &lt;code&gt;spec.replicas&lt;/code&gt; in the editor and save. No Pod count changes at this step. Then delete the line from the manifest. From that point an apply keeps whatever the autoscaler set.&lt;/p&gt;

&lt;p&gt;Utilization targets need resource requests on the containers. The &lt;a href="https://meteorops.com/blog/how-to-configure-kubernetes-hpa-without-causing-scaling-flaps" rel="noopener noreferrer"&gt;HPA guide&lt;/a&gt; covers the settings that stop the count from flapping.&lt;/p&gt;

&lt;h3&gt;
  
  
  A PodDisruptionBudget does not slow a rollout
&lt;/h3&gt;

&lt;p&gt;A PodDisruptionBudget (PDB) limits how many Pods are down at once from voluntary evictions: a node drain, a cluster upgrade, the autoscaler removing a node.&lt;/p&gt;

&lt;p&gt;What it does not limit, in the docs' words: rolling updates. Pods that are down during a rollout count against the budget, and the rollout goes on anyway.&lt;/p&gt;

&lt;p&gt;Deleting a Deployment or a Pod bypasses the budget too. The Eviction API is what enforces it (&lt;code&gt;kubectl drain&lt;/code&gt; uses it).&lt;/p&gt;

&lt;p&gt;Rollouts = &lt;code&gt;maxUnavailable&lt;/code&gt; on the Deployment.&lt;/p&gt;

&lt;p&gt;Node drains = a PDB.&lt;/p&gt;

&lt;p&gt;You need both. A PDB that allows 0 evictions means a node drain never finishes, which the &lt;a href="https://meteorops.com/blog/how-to-drain-kubernetes-nodes-without-evicting-critical-workloads" rel="noopener noreferrer"&gt;node draining guide&lt;/a&gt; walks through.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment vs StatefulSet, DaemonSet, Job and a bare Pod
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Workload&lt;/th&gt;
&lt;th&gt;Use it when&lt;/th&gt;
&lt;th&gt;Pod names&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Deployment&lt;/td&gt;
&lt;td&gt;Any Pod can replace any other: APIs, web apps, workers&lt;/td&gt;
&lt;td&gt;&lt;code&gt;web-75675f5897-kzszj&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;StatefulSet&lt;/td&gt;
&lt;td&gt;Each Pod needs a stable identity and its own volume: databases, queues&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;web-0&lt;/code&gt;, &lt;code&gt;web-1&lt;/code&gt;, &lt;code&gt;web-2&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DaemonSet&lt;/td&gt;
&lt;td&gt;1 copy on every node (or on some): log shippers, node agents&lt;/td&gt;
&lt;td&gt;1 per node&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Job / CronJob&lt;/td&gt;
&lt;td&gt;The work runs to completion, once or on a schedule&lt;/td&gt;
&lt;td&gt;Pods that are expected to exit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bare Pod&lt;/td&gt;
&lt;td&gt;Debugging, for a few minutes&lt;/td&gt;
&lt;td&gt;The one you typed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ReplicaSet&lt;/td&gt;
&lt;td&gt;Almost never directly. It cannot do a rolling update&lt;/td&gt;
&lt;td&gt;Managed by the Deployment&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo2a4pyxyctqx0ev7ghxa.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo2a4pyxyctqx0ev7ghxa.webp" alt="Which Kubernetes workload to use: Deployment when any Pod can replace any other, StatefulSet for stable identity and its own volume, DaemonSet for 1 copy on every node, Job for work that runs to completion" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;4 workloads, 4 questions.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The test from the StatefulSet docs: if the app needs no stable identity and no ordered rollout, use a Deployment.&lt;/p&gt;

&lt;p&gt;The docs recommend a controller even for a single Pod. &lt;code&gt;replicas: 1&lt;/code&gt; in a Deployment still gets you self-healing and rollouts.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Deployment with a volume
&lt;/h3&gt;

&lt;p&gt;"Deployments are for stateless apps only" is stricter than the docs. They run a single MySQL instance as a Deployment with a PersistentVolumeClaim.&lt;/p&gt;

&lt;p&gt;The 2 conditions they attach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;replicas: 1&lt;/code&gt;, and do not scale it. Every replica of a Deployment shares the same claim&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;strategy: Recreate&lt;/code&gt;, because a rolling update would run 2 Pods on 1 volume&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If each replica needs its own disk, that is a StatefulSet with &lt;code&gt;volumeClaimTemplates&lt;/code&gt;: 1 claim per Pod.&lt;/p&gt;

&lt;h2&gt;
  
  
  Canary and blue green need more than a Deployment
&lt;/h2&gt;

&lt;p&gt;A Deployment knows 2 strategies. Canary and blue green are patterns you build around it.&lt;/p&gt;

&lt;p&gt;The native canary from the Kubernetes docs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;2 Deployments with a shared label (&lt;code&gt;app: web&lt;/code&gt;) and a different one (&lt;code&gt;track: stable&lt;/code&gt;, &lt;code&gt;track: canary&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;1 Service that selects only the shared label&lt;/li&gt;
&lt;li&gt;Traffic splits by Pod count: 3 stable + 1 canary = about 25% to the canary&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It works, and it has 2 limits: the split is as fine as your replica count, and a human reads the dashboards and decides.&lt;/p&gt;

&lt;p&gt;What the 2 progressive delivery controllers add:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Argo Rollouts&lt;/th&gt;
&lt;th&gt;Flagger&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;How it attaches&lt;/td&gt;
&lt;td&gt;A &lt;code&gt;Rollout&lt;/code&gt; resource that replaces the Deployment, or references one&lt;/td&gt;
&lt;td&gt;A &lt;code&gt;Canary&lt;/code&gt; resource that targets your Deployment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strategies&lt;/td&gt;
&lt;td&gt;Canary and blue green&lt;/td&gt;
&lt;td&gt;Canary, A/B and blue green&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Decides with&lt;/td&gt;
&lt;td&gt;Steps (&lt;code&gt;setWeight&lt;/code&gt;, &lt;code&gt;pause&lt;/code&gt;) and metric analysis that aborts on failure&lt;/td&gt;
&lt;td&gt;Metrics such as success rate and request duration, then promote or roll back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latest release (Nov 28, 2026)&lt;/td&gt;
&lt;td&gt;v1.10.2&lt;/td&gt;
&lt;td&gt;v1.45.0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Both are graduated Cloud Native Computing Foundation (CNCF) projects (Flagger as part of Flux).&lt;/p&gt;

&lt;p&gt;My rule: start with a plain Deployment, a real readiness probe and a pipeline that checks &lt;code&gt;rollout status&lt;/code&gt;. Add a controller the day a bad release that passes its readiness probe costs you money.&lt;/p&gt;

&lt;p&gt;The setup for that day is in the &lt;a href="https://meteorops.com/blog/how-to-deploy-zero-downtime-kubernetes-releases-with-helm-and-argo-rollouts" rel="noopener noreferrer"&gt;zero-downtime releases guide with Helm and Argo Rollouts&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed for Deployments in Kubernetes v1.35 to v1.37
&lt;/h2&gt;

&lt;p&gt;The Deployment API has been stable since &lt;code&gt;apps/v1&lt;/code&gt;. The recent changes are small and useful to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;v1.35 (Dec 2025):&lt;/strong&gt; &lt;code&gt;status.terminatingReplicas&lt;/code&gt; on Deployments and ReplicaSets became beta and on by default. You can see how many Pods are still shutting down&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v1.36 (Apr 2026):&lt;/strong&gt; kubectl warns when you run &lt;code&gt;rollout undo&lt;/code&gt; on a resource managed with &lt;code&gt;kubectl apply&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;v1.37 (Aug 2026):&lt;/strong&gt; the HPA can scale a workload to 0 (beta, on by default, with object and external metrics only), and StatefulSets got a Recreate strategy modeled on the Deployment one (alpha)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Still a proposal: a &lt;code&gt;podReplacementPolicy&lt;/code&gt; field that would let a Deployment wait for old Pods to finish terminating before it creates new ones. It is absent from the v1.37 API reference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist before a Deployment goes to production
&lt;/h2&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A fixed image tag or digest. Never &lt;code&gt;:latest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A readiness probe that checks what a user request needs&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;maxUnavailable: 0&lt;/code&gt;, unless the service has capacity to spare&lt;/li&gt;
&lt;li&gt;At least 2 replicas, with a topology spread constraint across zones&lt;/li&gt;
&lt;li&gt;CPU and memory requests on every container&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;preStop&lt;/code&gt; sleep, and a grace period longer than the sleep plus the shutdown&lt;/li&gt;
&lt;li&gt;No &lt;code&gt;replicas&lt;/code&gt; line when an HPA owns the count (removed with &lt;code&gt;edit-last-applied&lt;/code&gt; first)&lt;/li&gt;
&lt;li&gt;A PDB for node drains&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl rollout status&lt;/code&gt; in the pipeline, with a timeout and a failure path&lt;/li&gt;
&lt;li&gt;Rollbacks end with a reverted commit&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Kubernetes Deployment FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a Kubernetes Deployment?
&lt;/h3&gt;

&lt;p&gt;A Deployment is the Kubernetes object that describes the desired state of a set of identical Pods: the Pod template, the number of replicas and the update strategy. Its controller creates a ReplicaSet for each version of the template and replaces Pods gradually when the template changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a Deployment and a Pod?
&lt;/h3&gt;

&lt;p&gt;A Pod is 1 running instance. A Deployment keeps N of them alive and replaces them when you ship a new version. A bare Pod that loses its node is gone, and a Pod owned by a Deployment is created again on another node.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a Deployment and a ReplicaSet?
&lt;/h3&gt;

&lt;p&gt;A ReplicaSet keeps a fixed number of Pods of 1 template running, and changing its template does not touch the Pods that exist. A Deployment owns ReplicaSets and adds rollouts, history and rollbacks. You create Deployments and let them create the ReplicaSets.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I restart a Kubernetes Deployment?
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;kubectl rollout restart deployment/NAME&lt;/code&gt;. It adds a timestamp annotation to the Pod template, which starts a normal rolling update with the same image, so the restart follows your surge and readiness settings.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I roll back a Kubernetes Deployment?
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;kubectl rollout undo deployment/NAME&lt;/code&gt; for the previous revision, or add &lt;code&gt;--to-revision=N&lt;/code&gt; for a specific one from &lt;code&gt;kubectl rollout history&lt;/code&gt;. Then revert the change in Git, or the next apply ships the same version again.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Kubernetes roll back a failed Deployment automatically?
&lt;/h3&gt;

&lt;p&gt;No. After &lt;code&gt;progressDeadlineSeconds&lt;/code&gt; (600 by default) it sets the Progressing condition to False with the reason ProgressDeadlineExceeded and keeps retrying. An automatic rollback comes from your pipeline, or from Argo Rollouts or Flagger.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is a rolling update zero downtime?
&lt;/h3&gt;

&lt;p&gt;Yes, with a readiness probe that reflects the app, a graceful shutdown and enough capacity left during the update (&lt;code&gt;maxUnavailable: 0&lt;/code&gt; is the safe setting). Without a readiness probe, a Pod counts as ready when its containers start, and traffic reaches an app that may still be booting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should a database run as a Deployment or a StatefulSet?
&lt;/h3&gt;

&lt;p&gt;A StatefulSet, when it has more than 1 replica: each Pod gets a stable name and its own volume. A single instance can run as a Deployment with 1 replica, a PersistentVolumeClaim and the Recreate strategy, which is how the Kubernetes docs run their MySQL example.&lt;/p&gt;

&lt;h2&gt;
  
  
  A recap
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing, let it be this:&lt;/p&gt;

&lt;p&gt;A Deployment moves as fast as it is allowed and as safely as it is told. The telling is yours: a readiness probe, 2 rollout numbers, a graceful shutdown and a pipeline that reads the exit code.&lt;/p&gt;

&lt;p&gt;You don't need a DevOps expert for that. The YAML above and the checklist cover most services.&lt;/p&gt;

&lt;p&gt;If you would like a second pair of eyes on your rollouts anyway (yes, I sell DevOps engineers), the &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free DevOps assessment&lt;/a&gt; is where a senior engineer reviews your Kubernetes and CI/CD setup.&lt;/p&gt;

&lt;p&gt;Related guides: &lt;a href="https://meteorops.com/blog/deployment-strategies" rel="noopener noreferrer"&gt;deployment strategies&lt;/a&gt;, &lt;a href="https://meteorops.com/blog/kubernetes-vs-docker" rel="noopener noreferrer"&gt;Kubernetes vs Docker&lt;/a&gt; and &lt;a href="https://meteorops.com/blog/kubernetes-namespace" rel="noopener noreferrer"&gt;Kubernetes namespaces&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes vs Docker: What Each Does and When You Need Both</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Sun, 29 Nov 2026 15:30:45 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-vs-docker-what-each-does-and-when-you-need-both-3f2m</link>
      <guid>https://dev.to/meteorops/kubernetes-vs-docker-what-each-does-and-when-you-need-both-3f2m</guid>
      <description>&lt;p&gt;Docker and Kubernetes do 2 different jobs, and the choice you are really making is between 1 machine and many:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Docker = build an image and run it as a container on 1 machine.&lt;/strong&gt; A laptop, a CI runner or a single server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes = keep containers running across many machines.&lt;/strong&gt; It places them, restarts them, replaces them and routes traffic to them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They work together.&lt;/strong&gt; You build the image with Docker, push it to a registry, and Kubernetes runs it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes stopped using Docker Engine in v1.24.&lt;/strong&gt; Nodes on EKS, GKE and AKS run containerd. Your Docker-built images run on it unchanged&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The real comparisons are Docker Compose vs Kubernetes and Docker Swarm vs Kubernetes.&lt;/strong&gt; Both come down to how many machines you have to survive losing&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Docker&lt;/th&gt;
&lt;th&gt;Kubernetes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Job&lt;/td&gt;
&lt;td&gt;Build images, run containers&lt;/td&gt;
&lt;td&gt;Run containers across a cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scope&lt;/td&gt;
&lt;td&gt;1 machine by default&lt;/td&gt;
&lt;td&gt;Up to 5,000 nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You write&lt;/td&gt;
&lt;td&gt;A Dockerfile, a &lt;code&gt;compose.yaml&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;YAML manifests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;If the machine dies&lt;/td&gt;
&lt;td&gt;The app is down&lt;/td&gt;
&lt;td&gt;Pods are rescheduled on other nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Price of the software&lt;/td&gt;
&lt;td&gt;Engine is free and open source&lt;/td&gt;
&lt;td&gt;Open source. A managed control plane is $0.10 an hour&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnaf5pyl2ua1eucs6tmcl.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnaf5pyl2ua1eucs6tmcl.webp" alt="Kubernetes vs Docker: Docker runs containers on 1 machine, Kubernetes runs containers on many nodes under a control plane" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Docker = 1 machine. Kubernetes = many.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What to do, by where you are today:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Your situation&lt;/th&gt;
&lt;th&gt;What I would do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1 product, 1 server, a small team&lt;/td&gt;
&lt;td&gt;Docker Compose with a restart policy and a healthcheck&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Containers in the cloud and nobody to run a platform&lt;/td&gt;
&lt;td&gt;ECS on Fargate, Cloud Run or Azure Container Apps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Several teams, many services, deploys every day&lt;/td&gt;
&lt;td&gt;Managed Kubernetes: EKS, GKE or AKS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Already on Docker Swarm and it works&lt;/td&gt;
&lt;td&gt;Stay. Plan the move the day you need something it lacks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;On Kubernetes with scripts that call &lt;code&gt;docker&lt;/code&gt; on the nodes&lt;/td&gt;
&lt;td&gt;Replace them with &lt;code&gt;kubectl&lt;/code&gt; and &lt;code&gt;crictl&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Deciding whether your product needs Kubernetes yet?&lt;/strong&gt; Book a &lt;a href="https://meteorops.com/devops-setup-for-production-free-consultation" rel="noopener noreferrer"&gt;free consultation call&lt;/a&gt; to examine what it would take to get your DevOps setup production-grade: environments, deployments, monitoring, security, and costs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want the 2 definitions in plain words: &lt;a href="https://meteorops.com/blog/kubernetes-vs-docker#docker-builds-and-runs-containers-on-1-machine" rel="noopener noreferrer"&gt;what Docker does&lt;/a&gt; and &lt;a href="https://meteorops.com/blog/kubernetes-vs-docker#kubernetes-keeps-containers-running-across-many-machines" rel="noopener noreferrer"&gt;what Kubernetes does&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Someone told you Kubernetes dropped Docker: &lt;a href="https://meteorops.com/blog/kubernetes-vs-docker#kubernetes-stopped-using-docker-engine-in-v1-24" rel="noopener noreferrer"&gt;what changed in v1.24&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You want to see the code: &lt;a href="https://meteorops.com/blog/kubernetes-vs-docker#the-same-web-server-in-docker-compose-swarm-and-kubernetes" rel="noopener noreferrer"&gt;the same web server, 4 ways&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You run Compose in production and wonder how long it lasts: &lt;a href="https://meteorops.com/blog/kubernetes-vs-docker#docker-compose-vs-kubernetes-1-host-vs-a-cluster" rel="noopener noreferrer"&gt;Docker Compose vs Kubernetes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are choosing a platform this quarter: &lt;a href="https://meteorops.com/blog/kubernetes-vs-docker#when-to-move-from-docker-to-kubernetes" rel="noopener noreferrer"&gt;the 5 questions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Docker builds and runs containers on 1 machine
&lt;/h2&gt;

&lt;p&gt;Docker is 4 things that people call by 1 name.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A build tool.&lt;/strong&gt; &lt;code&gt;docker build&lt;/code&gt; reads a Dockerfile and produces an image&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An image format.&lt;/strong&gt; An image is a package of everything the app needs to start: OS files, runtime, dependencies, code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A registry.&lt;/strong&gt; Docker Hub stores images so other machines can pull them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An engine.&lt;/strong&gt; Docker Engine runs the image as a container on the machine it is installed on&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A container, in Docker's own words, is "an ordinary process on your computer" that runs in isolation.&lt;/p&gt;

&lt;p&gt;It shares the machine's kernel, which is what makes it lighter than a virtual machine.&lt;/p&gt;

&lt;p&gt;Inside Docker Engine there are 3 layers:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dockerd&lt;/code&gt; (the daemon and its API) → containerd (the container lifecycle) → runc (starts the process)&lt;/p&gt;

&lt;p&gt;Remember containerd. It comes back in the Kubernetes story.&lt;/p&gt;

&lt;p&gt;Docker Desktop is the app for Mac, Windows and Linux that bundles the Engine, the CLI, Compose and a local Kubernetes.&lt;/p&gt;

&lt;p&gt;Docker Engine is free and open source. Docker Desktop needs a paid subscription for companies with 250 or more employees or $10 million or more in annual revenue.&lt;/p&gt;

&lt;p&gt;Docker = 1 machine. Out of the box, everything Docker Engine does, it does on the host it runs on. (Swarm mode, further down, is the exception you switch on.)&lt;/p&gt;
&lt;h2&gt;
  
  
  Kubernetes keeps containers running across many machines
&lt;/h2&gt;

&lt;p&gt;The Kubernetes site defines it as "an open source system for automating deployment, scaling, and management of containerized applications."&lt;/p&gt;

&lt;p&gt;In simple words: you tell Kubernetes what should be running, and it keeps it running across a group of machines.&lt;/p&gt;

&lt;p&gt;A cluster has 2 parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The control plane:&lt;/strong&gt; the API server, etcd (the database), the scheduler and the controllers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The nodes:&lt;/strong&gt; machines that run your containers. Each one runs a kubelet and a container runtime&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What it does that a single Docker host does not:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Scheduling.&lt;/strong&gt; You say how much CPU and memory a container needs. Kubernetes picks the node&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-healing.&lt;/strong&gt; A failed container is restarted. A failed node's workloads are rescheduled on other nodes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rollouts and rollbacks.&lt;/strong&gt; New Pods come up while old ones go down, at a controlled rate. By default at most 25% are unavailable at a time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service discovery and load balancing.&lt;/strong&gt; A Service gives a changing set of Pods 1 stable name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Autoscaling.&lt;/strong&gt; More Pods when CPU rises, more nodes when Pods do not fit. Both need an add-on: Metrics Server and a node autoscaler&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Config and secrets.&lt;/strong&gt; Changed without rebuilding the image&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Kubernetes v1.37 supports clusters of up to 5,000 nodes and 150,000 Pods.&lt;/p&gt;

&lt;p&gt;The docs also list what Kubernetes is not, and this is the part most comparisons skip:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It "does not deploy source code and does not build your application". You still need something that builds images&lt;/li&gt;
&lt;li&gt;It "does not dictate logging, monitoring, or alerting solutions". You bring those&lt;/li&gt;
&lt;li&gt;It does not come with a database, a cache or a message bus&lt;/li&gt;
&lt;li&gt;A Service of type LoadBalancer needs a cloud, or a load balancer you provide: "Kubernetes does not directly offer a load balancing component"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kubernetes = many machines that behave like 1. You pay for that with moving parts.&lt;/p&gt;
&lt;h2&gt;
  
  
  Kubernetes stopped using Docker Engine in v1.24
&lt;/h2&gt;

&lt;p&gt;In December 2020 the Kubernetes project announced it was deprecating Docker as a container runtime.&lt;/p&gt;

&lt;p&gt;The internet read it as "Kubernetes is dropping Docker". The project later admitted: "We didn't do a great job communicating this".&lt;/p&gt;

&lt;p&gt;What actually happened:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the early days Kubernetes supported 1 runtime: Docker Engine&lt;/li&gt;
&lt;li&gt;Kubernetes then defined the Container Runtime Interface (CRI), so the kubelet could talk to any runtime&lt;/li&gt;
&lt;li&gt;Docker Engine does not speak CRI, so Kubernetes carried an adapter inside the kubelet, called dockershim&lt;/li&gt;
&lt;li&gt;v1.20 announced the removal of dockershim. v1.24 removed it&lt;/li&gt;
&lt;li&gt;Nodes now run a CRI runtime directly, and the common one is containerd&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before v1.24, with Docker as the runtime: kubelet → dockershim → Docker Engine → containerd → runc&lt;/p&gt;

&lt;p&gt;Since v1.24: kubelet → containerd → runc&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F52zewbbmi5y85cx3zo3f.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F52zewbbmi5y85cx3zo3f.webp" alt="Kubernetes stopped using Docker Engine in v1.24. Before: kubelet, dockershim, Docker Engine, containerd, runc. Since: kubelet, containerd, runc" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The 2 pink boxes left the chain. containerd and runc stayed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Kubernetes cut out the middle of the chain. The part that starts your container was containerd before, and it is containerd now.&lt;/p&gt;

&lt;p&gt;The 3 big managed services agree: EKS-optimized Amazon Linux images come with containerd, GKE uses containerd on all node images, and AKS uses containerd on Linux node pools.&lt;/p&gt;
&lt;h3&gt;
  
  
  Your Docker images still run
&lt;/h3&gt;

&lt;p&gt;The Kubernetes blog, in a post titled "Don't Panic: Kubernetes and Docker": "Docker-produced images will continue to work in your cluster with all runtimes, as they always have."&lt;/p&gt;

&lt;p&gt;Why? An image built by Docker is an Open Container Initiative (OCI) image. containerd and CRI-O both pull and run OCI images.&lt;/p&gt;

&lt;p&gt;Docker on your laptop and in your CI is unaffected. Building with Docker does not make you depend on Docker as a runtime.&lt;/p&gt;
&lt;h3&gt;
  
  
  What changes on a node
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;docker ps&lt;/code&gt; and &lt;code&gt;docker exec&lt;/code&gt; do not see Kubernetes containers. They are "not visible to Docker"&lt;/li&gt;
&lt;li&gt;An image you build with &lt;code&gt;docker build&lt;/code&gt; on a node is invisible to Kubernetes until you push it to a registry&lt;/li&gt;
&lt;li&gt;A Pod that mounts &lt;code&gt;/var/run/docker.sock&lt;/code&gt; to build images breaks&lt;/li&gt;
&lt;li&gt;Monitoring or security agents that expect Docker Engine on the node need a version that talks to containerd&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The replacements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Which runtime does each node use? Read the CONTAINER-RUNTIME column
kubectl get nodes -o wide

# On the node itself, instead of docker ps
crictl ps -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can still run Docker Engine under Kubernetes through an adapter called cri-dockerd, maintained by Mirantis and Docker. I would only do it for a workload that truly needs the Docker socket.&lt;/p&gt;

&lt;h3&gt;
  
  
  containerd vs Docker is a part vs the whole
&lt;/h3&gt;

&lt;p&gt;containerd was born at Docker in 2014 as the lower layer of the Docker engine. Today it is a graduated Cloud Native Computing Foundation (CNCF) project.&lt;/p&gt;

&lt;p&gt;Docker Engine = containerd + a build tool + a CLI + an API + networking and volumes for 1 host.&lt;/p&gt;

&lt;p&gt;A Kubernetes node needs only the first item on that list. GKE says it plainly: "You cannot use containerd to build container images."&lt;/p&gt;

&lt;p&gt;So you keep both: Docker where images are built, containerd where they run.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same web server in Docker, Compose, Swarm and Kubernetes
&lt;/h2&gt;

&lt;p&gt;4 ways to run nginx, from the smallest to the largest. Every command and field below is taken from the Docker and Kubernetes references.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. docker run: 1 container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d -p 8080:80 --name web --restart unless-stopped nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-d&lt;/code&gt; runs it in the background, &lt;code&gt;-p 8080:80&lt;/code&gt; publishes container port 80 on host port 8080, and &lt;code&gt;--restart unless-stopped&lt;/code&gt; brings it back after a crash or a reboot.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Docker Compose: 1 application on 1 host
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# compose.yaml
services:
  web:
    image: nginx:latest
    ports:
      - "8080:80"
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost"]
      interval: 1m30s
      timeout: 10s
      retries: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command in &lt;code&gt;test&lt;/code&gt; runs inside the container, so the image has to contain it.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Docker Swarm: several hosts, Docker commands
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker swarm init --advertise-addr 

docker service create --name web \
  --replicas 3 \
  --publish published=8080,target=80 \
  nginx

docker service update --image nginx:stable web
docker service update --rollback web
docker service scale web=5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Port 8080 answers on every node of the swarm, including nodes that run no copy of the service.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Kubernetes: a cluster, declared in YAML
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# web.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: nginx:latest
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  type: LoadBalancer
  selector:
    app: web
  ports:
  - port: 80
    targetPort: 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl apply -f web.yaml
kubectl rollout status deployment/web

kubectl set image deployment/web web=nginx:stable
kubectl rollout undo deployment/web

kubectl scale deployment/web --replicas=5
kubectl autoscale deployment web --min=2 --max=10 --cpu=60%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;1 line became about 30. They buy you 3 copies that the scheduler tries to spread across machines, a cloud load balancer in front of them, and a rollout you can undo.&lt;/p&gt;

&lt;p&gt;If you need the rest of the commands, the &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet" rel="noopener noreferrer"&gt;kubectl cheat sheet&lt;/a&gt; lists them by task.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Compose vs Kubernetes: 1 host vs a cluster
&lt;/h2&gt;

&lt;p&gt;"Docker for development, Kubernetes for production" is what half the internet tells you.&lt;/p&gt;

&lt;p&gt;Docker disagrees: "Compose supports production deployments on single hosts."&lt;/p&gt;

&lt;p&gt;I agree with Docker. A single server running Compose is a fine production setup for a product with 1 team and a tolerance for a few minutes of downtime.&lt;/p&gt;

&lt;p&gt;What Compose gives you in production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Restart policies:&lt;/strong&gt; &lt;code&gt;restart: unless-stopped&lt;/code&gt; brings a container back after a crash or a daemon restart&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healthchecks:&lt;/strong&gt; Docker marks a container healthy or unhealthy. It does not restart an unhealthy one by itself&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Override files:&lt;/strong&gt; &lt;code&gt;docker compose -f compose.yaml -f compose.production.yaml up -d&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote deploys:&lt;/strong&gt; point &lt;code&gt;DOCKER_HOST&lt;/code&gt; at the server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Where it ends:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Docker Compose&lt;/th&gt;
&lt;th&gt;Kubernetes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Machines&lt;/td&gt;
&lt;td&gt;1 host&lt;/td&gt;
&lt;td&gt;A cluster of nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The host dies&lt;/td&gt;
&lt;td&gt;Everything on it is down&lt;/td&gt;
&lt;td&gt;Pods move to other nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deploying a new version&lt;/td&gt;
&lt;td&gt;Stops and recreates the container&lt;/td&gt;
&lt;td&gt;Rolling update, old and new overlap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rollback&lt;/td&gt;
&lt;td&gt;Deploy the previous image again&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout undo&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scaling&lt;/td&gt;
&lt;td&gt;By hand, within 1 host&lt;/td&gt;
&lt;td&gt;By hand or automatic, across nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secrets&lt;/td&gt;
&lt;td&gt;Environment variables and files&lt;/td&gt;
&lt;td&gt;Secret objects (unencrypted in etcd by default in upstream Kubernetes)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Time to learn (my estimate)&lt;/td&gt;
&lt;td&gt;An afternoon&lt;/td&gt;
&lt;td&gt;Months&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The 2 rows that matter are the first 2. Compose = 1 host. When 1 host is no longer acceptable, you need a scheduler.&lt;/p&gt;

&lt;p&gt;2 traps on the way out of Compose:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;deploy&lt;/code&gt; section (replicas, update_config, placement) is an optional part of the Compose Specification. A platform that does not support it ignores it, and the file is still valid&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docker stack deploy&lt;/code&gt;, the Swarm command that takes a Compose file, reads only the legacy version 3 format. The current Compose Specification format "isn't compatible" with it&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To move a Compose file to Kubernetes, start with a converter and then edit by hand: &lt;code&gt;kompose convert&lt;/code&gt; (a Kubernetes project) or &lt;code&gt;docker compose bridge convert&lt;/code&gt; (Docker Desktop 4.43.0 and later).&lt;/p&gt;

&lt;p&gt;(The converter writes the YAML. It does not write your readiness probes, your resource requests or your on-call rotation.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Swarm vs Kubernetes: the smaller cluster
&lt;/h2&gt;

&lt;p&gt;Swarm mode is the clustering that ships inside Docker Engine. No extra software, 1 command to start: &lt;code&gt;docker swarm init&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It does more than its reputation says:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Replicated services that are rescheduled when a node fails&lt;/li&gt;
&lt;li&gt;Rolling updates, 1 task at a time by default, with rollback&lt;/li&gt;
&lt;li&gt;A routing mesh, so every node answers on a published port&lt;/li&gt;
&lt;li&gt;Service discovery through built-in DNS&lt;/li&gt;
&lt;li&gt;Secrets, encrypted in transit and at rest&lt;/li&gt;
&lt;li&gt;Mutual TLS between nodes by default&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Docker Swarm&lt;/th&gt;
&lt;th&gt;Kubernetes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Install&lt;/td&gt;
&lt;td&gt;Built into Docker Engine&lt;/td&gt;
&lt;td&gt;A managed service, or a project of its own&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Control plane&lt;/td&gt;
&lt;td&gt;3 or 5 manager nodes. Docker recommends 7 at most&lt;/td&gt;
&lt;td&gt;API server, etcd, scheduler, controllers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scaling&lt;/td&gt;
&lt;td&gt;You set the number of replicas&lt;/td&gt;
&lt;td&gt;You set it, or an autoscaler does&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Managed offering on AWS, Google Cloud, Azure&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;EKS, GKE, AKS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ecosystem&lt;/td&gt;
&lt;td&gt;Docker tooling&lt;/td&gt;
&lt;td&gt;Helm, operators, Gateway API, most vendors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Commercial support&lt;/td&gt;
&lt;td&gt;Mirantis&lt;/td&gt;
&lt;td&gt;Every cloud and most vendors&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Is Swarm dead? No.&lt;/p&gt;

&lt;p&gt;Classic Swarm, the 2014 standalone project, is archived, and Docker Engine dropped support for it in v23.0. Swarm mode is still in the Engine.&lt;/p&gt;

&lt;p&gt;Mirantis, which sells it commercially, wrote in July 2025: "Swarm will be fully supported through at least 2030 as part of Mirantis Kubernetes Engine 3."&lt;/p&gt;

&lt;p&gt;The Swarm docs describe no autoscaler: you declare the number of tasks and the manager keeps it.&lt;/p&gt;

&lt;p&gt;My position: a Swarm that works today is no emergency. For a new platform I would not pick it, because the people, the tools and the cloud services you will hire and buy next year all assume Kubernetes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Kubernetes costs before it runs your app
&lt;/h2&gt;

&lt;p&gt;The software is free. Running it has 3 prices.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The control plane fee
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Standard&lt;/th&gt;
&lt;th&gt;Extended support for an old version&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Amazon EKS&lt;/td&gt;
&lt;td&gt;$0.10 per cluster per hour&lt;/td&gt;
&lt;td&gt;$0.60 per cluster per hour&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google GKE&lt;/td&gt;
&lt;td&gt;$0.10 per cluster per hour&lt;/td&gt;
&lt;td&gt;$0.60 per cluster per hour&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure AKS&lt;/td&gt;
&lt;td&gt;Free tier, or Standard at $0.10 per cluster per hour (East US)&lt;/td&gt;
&lt;td&gt;$0.60 per cluster per hour for Long Term Support (East US)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;$0.10 an hour = about $73 a month per cluster. Before nodes, load balancers and disks.&lt;/p&gt;

&lt;p&gt;$0.60 an hour = about $438 a month per cluster. On EKS that is what a cluster nobody upgraded costs, because extended support is on by default. On GKE and AKS you pay it only if you opt in.&lt;/p&gt;

&lt;p&gt;GKE gives $74.40 of credit a month per billing account, which covers 1 zonal or Autopilot cluster. Microsoft says its Free tier clusters "are not meant to run at scale (&amp;gt;10 nodes)".&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The upgrade treadmill
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Kubernetes ships about 3 releases a year&lt;/li&gt;
&lt;li&gt;Each release gets about 1 year of patches&lt;/li&gt;
&lt;li&gt;On EKS a version has 14 months of standard support, then the fee rises for 12 months, then AWS upgrades the control plane for you&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kubernetes = 1 upgrade project every few months, forever. (There is a &lt;a href="https://meteorops.com/blog/practical-tips-for-kubernetes-upgrades-for-startups" rel="noopener noreferrer"&gt;guide for that too&lt;/a&gt;.)&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Everything the docs say it does not include
&lt;/h3&gt;

&lt;p&gt;An ingress or gateway controller. Metrics Server, without which autoscaling on CPU does nothing (GKE and AKS ship it). Logging. Monitoring. Encryption of Secrets at rest (off in upstream Kubernetes, on by default on EKS and GKE). A way to build images.&lt;/p&gt;

&lt;p&gt;Each one is a choice, an install and something to upgrade.&lt;/p&gt;

&lt;p&gt;The fee is the small part. The person who owns all of the above is the real price.&lt;/p&gt;

&lt;h2&gt;
  
  
  Containers without running Kubernetes yourself
&lt;/h2&gt;

&lt;p&gt;Between "1 server with Compose" and "a Kubernetes cluster" there is a third option that most comparisons leave out.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;Limits worth knowing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Amazon ECS on Fargate&lt;/td&gt;
&lt;td&gt;AWS's own orchestrator, with no servers to manage and no control plane fee&lt;/td&gt;
&lt;td&gt;Fixed task sizes, from 0.25 vCPU up to 32 vCPU&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Cloud Run&lt;/td&gt;
&lt;td&gt;Runs a container per request load and scales to zero&lt;/td&gt;
&lt;td&gt;Request timeout of 5 minutes by default, 60 at most. 8 vCPU and 32 GiB per instance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure Container Apps&lt;/td&gt;
&lt;td&gt;Serverless containers, built on Kubernetes&lt;/td&gt;
&lt;td&gt;No access to the Kubernetes APIs. Up to 1,000 replicas per revision&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;AWS App Runner used to be on this list. It is closed to new customers, and AWS points them to ECS Express Mode.&lt;/p&gt;

&lt;p&gt;These services take a Docker-built image, give you rollouts and autoscaling, and leave you no cluster to upgrade.&lt;/p&gt;

&lt;p&gt;What you give up: the Kubernetes ecosystem and the option to run the same setup on another cloud or in a customer's data center.&lt;/p&gt;

&lt;p&gt;If you are on AWS and stuck between the two, I compared them in &lt;a href="https://meteorops.com/blog/ecs-vs-eks" rel="noopener noreferrer"&gt;ECS vs EKS&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to move from Docker to Kubernetes
&lt;/h2&gt;

&lt;p&gt;5 questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does the product have to survive the loss of a machine with nobody awake?&lt;/li&gt;
&lt;li&gt;Do you deploy several times a day and need every deploy to cause zero downtime?&lt;/li&gt;
&lt;li&gt;Do more than 2 teams deploy more than 10 services to the same environment?&lt;/li&gt;
&lt;li&gt;Does load change enough during the day that fixed capacity wastes real money?&lt;/li&gt;
&lt;li&gt;Do you need something only the Kubernetes ecosystem has: operators, GPU scheduling, a Helm chart your customers install on their own clusters?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7tiu78daxphpskhu4uos.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7tiu78daxphpskhu4uos.webp" alt="5 questions before Kubernetes: survive losing a machine, zero downtime deploys, many teams and many services, load that changes, needs the ecosystem. 2 yes answers means you need a scheduler" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The 5 questions on 1 card.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you answered yes to 2 of the 5, you need a scheduler.&lt;/p&gt;

&lt;p&gt;If the yes answers are only 1 and 2, a managed container service is enough.&lt;/p&gt;

&lt;p&gt;If 3 or 5 is among them, it is Kubernetes.&lt;/p&gt;

&lt;p&gt;The order I would walk it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run&lt;/code&gt; → Docker Compose on 1 server → a managed container service → managed Kubernetes&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwsu09expm5zw70aosmw3.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwsu09expm5zw70aosmw3.webp" alt="From 1 container to a cluster: docker run, Docker Compose on 1 host, a managed container service, managed Kubernetes" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;4 steps. Most products can stop before the last one for a long time.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Skip a step when you have a reason. "Everyone uses Kubernetes" is a fact about everyone.&lt;/p&gt;

&lt;p&gt;When you do move, pick a managed control plane. I wrote about the options in &lt;a href="https://meteorops.com/blog/how-to-choose-kubernetes-hosting-for-production" rel="noopener noreferrer"&gt;how to choose Kubernetes hosting for production&lt;/a&gt;, and about the move itself in &lt;a href="https://meteorops.com/blog/how-to-plan-a-kubernetes-migration" rel="noopener noreferrer"&gt;how to plan a Kubernetes migration&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  8 mistakes on the way from Docker to Kubernetes
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mistake&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CI jobs in the cluster mount the Docker socket to build images&lt;/td&gt;
&lt;td&gt;Build outside the cluster, or with a daemonless builder such as buildah or rootless BuildKit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debugging a node with &lt;code&gt;docker ps&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;crictl ps -a&lt;/code&gt; on the node, &lt;code&gt;kubectl&lt;/code&gt; everywhere else&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pulling public images from Docker Hub with no login&lt;/td&gt;
&lt;td&gt;Authenticate the pulls or mirror the images. The anonymous limit is 100 pulls per 6 hours per IPv4 address, and a cluster behind 1 NAT is 1 address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image names without a registry&lt;/td&gt;
&lt;td&gt;Know that Kubernetes assumes Docker Hub when the registry is missing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;-p 80:80&lt;/code&gt; on a server with a public IP&lt;/td&gt;
&lt;td&gt;Docker publishes on all interfaces and manages its own firewall rules. Bind to &lt;code&gt;127.0.0.1&lt;/code&gt; when a reverse proxy sits in front&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An autoscaler that never scales&lt;/td&gt;
&lt;td&gt;Check that Metrics Server is running (GKE and AKS ship it) and set CPU requests on the Pods&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copying &lt;code&gt;kubectl autoscale ... --cpu-percent&lt;/code&gt; from an old tutorial&lt;/td&gt;
&lt;td&gt;The current kubectl reference uses &lt;code&gt;--cpu=60%&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Docker Desktop on every laptop of a 300 person company with no subscription&lt;/td&gt;
&lt;td&gt;Buy the subscription, or use Docker Engine on Linux, which is open source&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Kubernetes vs Docker checklist
&lt;/h2&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build images with Docker (or any OCI builder) and push them to a registry&lt;/li&gt;
&lt;li&gt;Pin image tags. &lt;code&gt;latest&lt;/code&gt; is for examples like the ones above&lt;/li&gt;
&lt;li&gt;Set a restart policy and a healthcheck on anything that runs under Docker in production&lt;/li&gt;
&lt;li&gt;Authenticate Docker Hub pulls from servers and clusters&lt;/li&gt;
&lt;li&gt;Answer the 5 questions before choosing a platform&lt;/li&gt;
&lt;li&gt;Take the managed control plane&lt;/li&gt;
&lt;li&gt;Budget the upgrades: about 3 Kubernetes releases a year&lt;/li&gt;
&lt;li&gt;Check that Metrics Server is running before you promise anyone autoscaling&lt;/li&gt;
&lt;li&gt;Check the CONTAINER-RUNTIME column before you write a node script&lt;/li&gt;
&lt;li&gt;Keep 1 person accountable for the cluster (shared accountability is how clusters reach extended support)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Kubernetes vs Docker FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Which is better, Kubernetes or Docker?
&lt;/h3&gt;

&lt;p&gt;Neither, because they do different jobs. Docker builds images and runs containers on 1 machine, Kubernetes runs containers across many machines, and you can use Docker to build what Kubernetes runs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Kubernetes replacing Docker?
&lt;/h3&gt;

&lt;p&gt;No. Kubernetes replaced Docker Engine as the runtime on its own nodes in v1.24, and developers kept Docker everywhere else. In the Stack Overflow 2026 survey, 59.1% of the developers who answered the cloud tools question had done extensive work with Docker or Docker Compose in the past year, and 26.0% with Kubernetes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I use Kubernetes without Docker?
&lt;/h3&gt;

&lt;p&gt;Yes, and on a managed cluster you already do. The nodes run containerd, and any tool that produces an OCI image can build for them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need to learn Docker before Kubernetes?
&lt;/h3&gt;

&lt;p&gt;I would. Kubernetes runs images, and you cannot debug a Pod without knowing what an image, a container, a port and a volume are. Learn &lt;code&gt;docker build&lt;/code&gt;, &lt;code&gt;docker run&lt;/code&gt; and Compose first.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between Docker Compose and Kubernetes?
&lt;/h3&gt;

&lt;p&gt;Compose runs a multi-container application on 1 host. Kubernetes runs it across a cluster and replaces what fails. Start with Compose and move when 1 host stops being acceptable.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between containerd and Docker?
&lt;/h3&gt;

&lt;p&gt;containerd is the runtime inside Docker Engine that manages the container lifecycle. Docker adds the build tool, the CLI, the API and single-host networking on top of it. Most Kubernetes nodes run containerd alone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Docker Swarm still supported?
&lt;/h3&gt;

&lt;p&gt;Yes. Swarm mode ships in Docker Engine, and Mirantis has committed to supporting it through at least 2030 in its commercial product. Classic Swarm, the older standalone project, is archived.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why are people moving away from Kubernetes?
&lt;/h3&gt;

&lt;p&gt;In my view, the teams that leave are the ones that adopted it before they needed it. A cluster costs a control plane fee, an upgrade every few months and a person who owns it, and a product that fits on a managed container service gets none of that back.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Recap!
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing from this guide, let it be this:&lt;/p&gt;

&lt;p&gt;Docker vs Kubernetes = 1 machine vs many. Count your machines before you pick a tool.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Docker builds the image and runs it on 1 machine. Kubernetes keeps it running across many&lt;/li&gt;
&lt;li&gt;Kubernetes has not needed Docker Engine since v1.24. Your Docker-built images did not notice&lt;/li&gt;
&lt;li&gt;Compose is a production tool for 1 host. Docker says so&lt;/li&gt;
&lt;li&gt;A cluster costs $73 a month before it runs anything, and an owner after that&lt;/li&gt;
&lt;li&gt;2 yes answers out of 5 = you need a scheduler. Kubernetes is 1 of 3 ways to get one&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You don't NEED anyone for this. The 5 questions and the checklist above are the whole decision.&lt;/p&gt;

&lt;p&gt;If you would rather talk it through with someone who has run both (yes, I sell DevOps engineers), book the &lt;a href="https://meteorops.com/devops-setup-for-production-free-consultation" rel="noopener noreferrer"&gt;free production setup consultation&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes Namespace: What It Isolates and What It Doesn't</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Sat, 28 Nov 2026 15:30:13 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-namespace-what-it-isolates-and-what-it-doesnt-p3a</link>
      <guid>https://dev.to/meteorops/kubernetes-namespace-what-it-isolates-and-what-it-doesnt-p3a</guid>
      <description>&lt;p&gt;A Kubernetes namespace separates names and permissions, and by default it blocks 0 network traffic between your teams:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Namespace = a scope for names inside 1 cluster.&lt;/strong&gt; Two teams can each have a Service called &lt;code&gt;api&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It is also where policy attaches.&lt;/strong&gt; The Kubernetes docs: "A mechanism to attach authorization and policy to a subsection of the cluster"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The walls are sold separately.&lt;/strong&gt; The docs again: "By default, all pods in a Kubernetes cluster are allowed to communicate with each other"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;4 additions turn a namespace into a boundary.&lt;/strong&gt; A RoleBinding, a ResourceQuota, a NetworkPolicy and Pod Security labels&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tenants who do not trust each other get separate clusters.&lt;/strong&gt; AWS: "the cluster is the only construct that provides a strong security boundary"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What to do, by where you are today:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Your situation&lt;/th&gt;
&lt;th&gt;What I would do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Everything runs in &lt;code&gt;default&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Create 1 namespace per application and leave &lt;code&gt;default&lt;/code&gt; empty&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2 or more teams share a cluster&lt;/td&gt;
&lt;td&gt;1 namespace per team and application, each with the 4 additions below&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dev, staging and production share a cluster&lt;/td&gt;
&lt;td&gt;Move production to its own cluster. Namespaces are fine for the rest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You host workloads of customers who do not trust each other&lt;/td&gt;
&lt;td&gt;A cluster per customer, or a virtual control plane per customer on isolated nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A namespace is stuck in &lt;code&gt;Terminating&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Read its &lt;code&gt;status.conditions&lt;/code&gt; before you touch a finalizer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Create a namespace, list them all, and make it your default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create namespace shop

kubectl get namespaces

kubectl config set-context --current --namespace=shop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every version, default and quote in this guide comes from the Kubernetes documentation, the Kubernetes source and design documents, the AWS, Google and Microsoft docs and the Helm, Argo CD, Kustomize and Gateway API docs, as read on November 26, 2026 (Kubernetes is at v1.37).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Do several teams share your cluster, and you are not sure what separates them?&lt;/strong&gt; In a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free assessment&lt;/a&gt;, a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup, the namespace boundaries included.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You are new to namespaces:&lt;/strong&gt; start at &lt;a href="https://meteorops.com/blog/kubernetes-namespace#a-namespace-is-a-scope-for-names-and-a-hook-for-policy" rel="noopener noreferrer"&gt;a namespace is a scope for names&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You need the commands:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-namespace#create-list-switch-and-delete-a-namespace-with-kubectl" rel="noopener noreferrer"&gt;create, list, switch and delete&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Service in another namespace does not resolve:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-namespace#reach-a-service-in-another-namespace-with-service-namespace" rel="noopener noreferrer"&gt;reach a Service in another namespace&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You were asked "are our teams isolated?":&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-namespace#a-namespace-isolates-nothing-by-default" rel="noopener noreferrer"&gt;what a namespace leaves shared&lt;/a&gt;, then &lt;a href="https://meteorops.com/blog/kubernetes-namespace#turn-a-namespace-into-a-boundary-with-4-additions" rel="noopener noreferrer"&gt;the 4 additions&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You are deciding how to slice the cluster:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-namespace#slice-by-team-and-application-keep-environments-apart" rel="noopener noreferrer"&gt;slice by team and application&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You are choosing between namespaces and clusters:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-namespace#namespaces-vs-clusters-trust-decides" rel="noopener noreferrer"&gt;namespaces vs clusters&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A namespace will not delete:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-namespace#fix-a-namespace-stuck-in-terminating" rel="noopener noreferrer"&gt;fix a namespace stuck in Terminating&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A namespace is a scope for names and a hook for policy
&lt;/h2&gt;

&lt;p&gt;The docs' definition: "In Kubernetes, namespaces provide a mechanism for isolating groups of resources within a single cluster."&lt;/p&gt;

&lt;p&gt;The word "isolating" does a lot of work in that sentence. What you get on day 1 is narrower:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A scope for names.&lt;/strong&gt; "Names of resources need to be unique within a namespace, but not across namespaces"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A place to attach policy.&lt;/strong&gt; Permissions, quotas, network rules and Pod security rules are all written per namespace&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Namespace = a folder for Kubernetes objects, with a permission system that understands folders.&lt;/p&gt;

&lt;p&gt;(Nobody ever called a folder a firewall.)&lt;/p&gt;

&lt;p&gt;A namespace holds most of what you deploy. A few kinds live outside every namespace:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Inside a namespace&lt;/th&gt;
&lt;th&gt;Cluster-scoped (outside every namespace)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pods, Services, Deployments&lt;/td&gt;
&lt;td&gt;Nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secrets, ConfigMaps&lt;/td&gt;
&lt;td&gt;PersistentVolumes, StorageClasses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Roles, RoleBindings, ServiceAccounts&lt;/td&gt;
&lt;td&gt;ClusterRoles, ClusterRoleBindings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NetworkPolicies, ResourceQuotas, LimitRanges&lt;/td&gt;
&lt;td&gt;CustomResourceDefinitions (CRDs), admission webhooks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PersistentVolumeClaims&lt;/td&gt;
&lt;td&gt;Namespaces themselves&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft119u8evc9d6br6qdhr2.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft119u8evc9d6br6qdhr2.webp" alt="What lives inside a Kubernetes namespace: Pods, Services, Deployments, Secrets and Roles are inside it, while Nodes, PersistentVolumes, StorageClasses, ClusterRoles and CRDs are cluster-scoped" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The dashed box is the namespace. Everything on the right belongs to the whole cluster.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ask your own cluster which is which:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl api-resources --namespaced=true
kubectl api-resources --namespaced=false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 rules about the object itself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Flat:&lt;/strong&gt; "Namespaces cannot be nested inside one another and each Kubernetes resource can only be in one namespace"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Named like a DNS label:&lt;/strong&gt; at most 63 characters of lowercase letters, digits and &lt;code&gt;-&lt;/code&gt;, with a letter or a digit at both ends. The name becomes part of every Service's DNS name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No &lt;code&gt;kube-&lt;/code&gt; prefix:&lt;/strong&gt; "it is reserved for Kubernetes system namespaces"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same namespace as a manifest, for the Git repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Namespace
metadata:
  name: shop
  labels:
    team: payments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(The short definition is in the glossary: &lt;a href="https://meteorops.com/glossary/kubernetes-namespace" rel="noopener noreferrer"&gt;Kubernetes Namespace&lt;/a&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Every cluster starts with 4 namespaces
&lt;/h2&gt;

&lt;p&gt;"Kubernetes starts with four initial namespaces":&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Namespace&lt;/th&gt;
&lt;th&gt;What it is for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;default&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;So that "you can start using your new cluster without first creating a namespace"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kube-system&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"The namespace for objects created by the Kubernetes system"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kube-public&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"Readable by all clients (including those not authenticated)"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kube-node-lease&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1 Lease object per node. Every kubelet heartbeat is an update to it&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The docs on &lt;code&gt;default&lt;/code&gt;: "For a production cluster, consider not using the default namespace."&lt;/p&gt;

&lt;p&gt;Why? Because every command without &lt;code&gt;-n&lt;/code&gt; lands there until you change your context, and so does every manifest without a namespace.&lt;/p&gt;

&lt;p&gt;3 of the 4 cannot be deleted. An admission controller that is on by default "prevents deletion of three system reserved namespaces default, kube-system, kube-public".&lt;/p&gt;

&lt;p&gt;On a managed cluster, &lt;code&gt;kube-system&lt;/code&gt; belongs to the provider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GKE Autopilot:&lt;/strong&gt; "doesn't allow deploying workloads in GKE-managed namespaces, such as kube-system"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AKS:&lt;/strong&gt; "We don't recommend deploying your own applications to this namespace"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My rule: your workloads never go in a namespace you did not create.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create, list, switch and delete a namespace with kubectl
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You want to&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Create one&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl create namespace shop&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Get the YAML without creating it&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl create namespace shop --dry-run=client -o yaml&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List all namespaces&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get namespaces&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;See its labels, quota and limit ranges&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe namespace shop&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run 1 command in it&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -n shop&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Look across all namespaces&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -A&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Make it the default of your context&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl config set-context --current --namespace=shop&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check which namespace you are in&lt;/td&gt;
&lt;td&gt;`kubectl config view --minify \&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delete it, with everything in it&lt;/td&gt;
&lt;td&gt;{% raw %}&lt;code&gt;kubectl delete namespace shop&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;kubectl get namespaces&lt;/code&gt; on a new cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAME              STATUS   AGE
default           Active   11d
kube-node-lease   Active   11d
kube-public       Active   11d
kube-system       Active   11d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;STATUS has 2 values: &lt;code&gt;Active&lt;/code&gt; and &lt;code&gt;Terminating&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;4 things worth knowing about these commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The default namespace is stored on your laptop.&lt;/strong&gt; &lt;code&gt;set-context&lt;/code&gt; writes it into the context in your &lt;a href="https://meteorops.com/glossary/kubeconfig" rel="noopener noreferrer"&gt;kubeconfig&lt;/a&gt;. The cluster knows nothing about it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-A&lt;/code&gt; wins over everything.&lt;/strong&gt; With &lt;code&gt;--all-namespaces&lt;/code&gt;, the "namespace in current context is ignored even if specified with --namespace"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A manifest and a flag that disagree = an error.&lt;/strong&gt; If the YAML says &lt;code&gt;namespace: shop&lt;/code&gt; and you pass &lt;code&gt;-n billing&lt;/code&gt;, kubectl stops and reports that the namespace of the object "does not match" the one you passed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete means everything.&lt;/strong&gt; The docs put it with an exclamation mark: "This deletes everything under the namespace!"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;kubectl does not ask first unless you add &lt;code&gt;--interactive&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;(More commands like these are in the &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet" rel="noopener noreferrer"&gt;kubectl cheat sheet&lt;/a&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Reach a Service in another namespace with service.namespace
&lt;/h2&gt;

&lt;p&gt;Every Service gets a DNS name of this form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;..svc.cluster.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What a Pod in namespace &lt;code&gt;test&lt;/code&gt; gets when it looks up a Service called &lt;code&gt;data&lt;/code&gt; that lives in namespace &lt;code&gt;prod&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;The Pod asks for&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;data&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Nothing. A short name is looked up in the Pod's own namespace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;data.prod&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The Service in &lt;code&gt;prod&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;data.prod.svc.cluster.local&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The Service in &lt;code&gt;prod&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The short form works because the kubelet writes a search list into each Pod's &lt;code&gt;/etc/resolv.conf&lt;/code&gt;: the Pod's own namespace first, then &lt;code&gt;svc.cluster.local&lt;/code&gt;, the entry that completes &lt;code&gt;data.prod&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is also why the same manifest works in every namespace: an app that calls &lt;code&gt;data&lt;/code&gt; finds its own namespace's &lt;code&gt;data&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2 warnings from the docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DNS crosses namespaces by default.&lt;/strong&gt; "By default, the Kubernetes DNS service allows lookups across all namespaces in the cluster"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A namespace named like a top-level domain hijacks lookups.&lt;/strong&gt; Call a namespace &lt;code&gt;com&lt;/code&gt;, and Services in it can take "precedence over public DNS" for every workload in the cluster. The fix in the docs: "limit privileges for creating namespaces to trusted users"&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A namespace isolates nothing by default
&lt;/h2&gt;

&lt;p&gt;Create 2 namespaces, deploy into both, and this is what they still share:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Shared by default&lt;/th&gt;
&lt;th&gt;What the docs say&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The network&lt;/td&gt;
&lt;td&gt;"If no policies exist in a namespace, then all ingress and egress traffic is allowed to and from pods in that namespace"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The nodes and the kernel&lt;/td&gt;
&lt;td&gt;"Containers are processes running on a shared kernel"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CPU and memory&lt;/td&gt;
&lt;td&gt;No quota exists until you create one. A single namespace can take the whole cluster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cluster-scoped objects&lt;/td&gt;
&lt;td&gt;Namespace isolation "doesn't apply to Kubernetes resources that can't be namespaced, such as Custom Resource Definitions, Storage Classes, and Webhooks"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The list of namespaces&lt;/td&gt;
&lt;td&gt;AWS: "If a tenant has the ability to view a particular Namespace, it can view all Namespaces within the cluster"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feemztiu2mb0v0sfrgm5i.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feemztiu2mb0v0sfrgm5i.webp" alt="By default a Kubernetes namespace blocks nothing: a Pod in namespace team-a reaches a Pod in namespace team-b, all traffic allowed, on shared nodes and kernel" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;2 namespaces on day 1: separate names, shared everything else.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The docs say it in 1 sentence: "The namespace isolation model requires configuration of several other Kubernetes resources, networking plugins, and adherence to security best practices to properly isolate tenant workloads."&lt;/p&gt;

&lt;p&gt;Kubernetes also "does not have first-class concepts of end users or tenants". A tenant is something you build out of namespaces and policy.&lt;/p&gt;
&lt;h2&gt;
  
  
  Turn a namespace into a boundary with 4 additions
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Addition&lt;/th&gt;
&lt;th&gt;It decides&lt;/th&gt;
&lt;th&gt;Without it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RoleBinding&lt;/td&gt;
&lt;td&gt;Who can act in the namespace&lt;/td&gt;
&lt;td&gt;Access is granted for the whole cluster or for nothing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ResourceQuota (with a LimitRange)&lt;/td&gt;
&lt;td&gt;How much it can use&lt;/td&gt;
&lt;td&gt;1 team can starve the others&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NetworkPolicy&lt;/td&gt;
&lt;td&gt;Which traffic gets in&lt;/td&gt;
&lt;td&gt;Every Pod in the cluster can call it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod Security labels&lt;/td&gt;
&lt;td&gt;What a Pod may do on the node&lt;/td&gt;
&lt;td&gt;A privileged Pod can reach the node&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3c8wm1h3hiy5obc4fs3t.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3c8wm1h3hiy5obc4fs3t.webp" alt="4 additions turn a Kubernetes namespace into a boundary: a RoleBinding (who can act), a ResourceQuota (how much it can use), a NetworkPolicy (which traffic gets in) and Pod Security labels (what a Pod may do)" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Each of the 4 is its own object or label, written per namespace.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  1. A RoleBinding: who can act
&lt;/h3&gt;

&lt;p&gt;Bind a team's group to the built-in &lt;code&gt;edit&lt;/code&gt; role, inside 1 namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: payments-edit
  namespace: shop
subjects:
  - kind: Group
    name: payments-team
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: ClusterRole
  name: edit
  apiGroup: rbac.authorization.k8s.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A RoleBinding can point at a ClusterRole, and it then grants those permissions "inside the RoleBinding's namespace" only.&lt;/p&gt;

&lt;p&gt;So you define the roles once and reuse them in every namespace. Kubernetes ships 3 for this: &lt;code&gt;admin&lt;/code&gt;, &lt;code&gt;edit&lt;/code&gt; and &lt;code&gt;view&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Check the result from the team's point of view:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl auth can-i create deployments --as=jane --as-group=payments-team -n shop
kubectl auth can-i create deployments --as=jane --as-group=payments-team -n billing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 facts decide how many namespaces you need:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a Pod = own the namespace.&lt;/strong&gt; Permission to create workloads "implicitly grants access to many other resources in that namespace, such as Secrets, ConfigMaps, and PersistentVolumes that can be mounted in Pods", plus the API access of every ServiceAccount in it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit the Namespace object = change its rules.&lt;/strong&gt; Whoever can patch a namespace can change its labels, and the labels drive Pod Security and NetworkPolicy selection&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The docs' conclusion: "boundaries within a namespace should be considered weak."&lt;/p&gt;

&lt;p&gt;(The first fact has its own guide: &lt;a href="https://meteorops.com/blog/kubernetes-secrets" rel="noopener noreferrer"&gt;Kubernetes Secrets&lt;/a&gt;. The permission model is in the glossary under &lt;a href="https://meteorops.com/glossary/kubernetes-rbac" rel="noopener noreferrer"&gt;Kubernetes RBAC&lt;/a&gt;.)&lt;/p&gt;

&lt;h3&gt;
  
  
  2. A ResourceQuota and a LimitRange: how much it can use
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute
  namespace: shop
spec:
  hard:
    requests.cpu: "8"
    requests.memory: 16Gi
    limits.memory: 32Gi
    pods: "50"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The surprise comes right after you apply it.&lt;/p&gt;

&lt;p&gt;The docs: "If you enforce a resource quota in a namespace for either cpu or memory, you and other clients, must specify either requests or limits for that resource, for every new Pod you submit."&lt;/p&gt;

&lt;p&gt;What a team sees the next morning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Deployment is created without an error&lt;/li&gt;
&lt;li&gt;Some or all of its Pods never appear&lt;/li&gt;
&lt;li&gt;The reason sits in the events of the ReplicaSet: the Pod "is forbidden", because of an exceeded quota or a missing request&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So a quota ships with a LimitRange, which fills in defaults for containers that set nothing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: LimitRange
metadata:
  name: defaults
  namespace: shop
spec:
  limits:
    - type: Container
      defaultRequest:
        cpu: 100m
        memory: 128Mi
      default:
        memory: 256Mi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;1 catch: a container that requests more than 256Mi and sets no limit still gets the 256Mi default limit, and that Pod will not run. Keep the default limit above your largest request.&lt;/p&gt;

&lt;p&gt;See what is used and what is left:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl describe quota -n shop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both apply at admission. Pods that already run are left alone: "Neither contention nor changes to quota will affect already created resources."&lt;/p&gt;

&lt;p&gt;(How to pick the numbers is in &lt;a href="https://meteorops.com/blog/how-to-set-kubernetes-resource-requests-and-limits-without-throttling-apps" rel="noopener noreferrer"&gt;the requests and limits guide&lt;/a&gt;.)&lt;/p&gt;

&lt;h3&gt;
  
  
  3. A NetworkPolicy: which traffic gets in
&lt;/h3&gt;

&lt;p&gt;The docs' default deny for incoming traffic, 1 per namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-ingress
  namespace: shop
spec:
  podSelector: {}
  policyTypes:
    - Ingress
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then allow the namespace to talk to itself, and 1 other namespace to call in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-same-namespace-and-gateway
  namespace: shop
spec:
  podSelector: {}
  policyTypes:
    - Ingress
  ingress:
    - from:
        - podSelector: {}
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: gateway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4 rules that save an afternoon:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Your network plugin has to support it.&lt;/strong&gt; "Creating a NetworkPolicy resource without a controller that implements it will have no effect." No error, no warning&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A policy selects namespaces by label.&lt;/strong&gt; Every namespace carries the label &lt;code&gt;kubernetes.io/metadata.name&lt;/code&gt; with its own name as the value, set by the control plane, so you always have one to select on&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The NetworkPolicy API has no cluster-wide default.&lt;/strong&gt; The default deny is created in each namespace&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Denying egress also denies DNS.&lt;/strong&gt; "A default deny-all egress policy also blocks DNS traffic", so add an allow rule for the cluster DNS first&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(The object itself is in the glossary: &lt;a href="https://meteorops.com/glossary/kubernetes-networkpolicy" rel="noopener noreferrer"&gt;Kubernetes NetworkPolicy&lt;/a&gt;.)&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Pod Security labels: what a Pod may do
&lt;/h3&gt;

&lt;p&gt;Pod Security Admission is built in (stable since Kubernetes v1.25) and is configured with labels on the namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl label --overwrite namespace shop \
  pod-security.kubernetes.io/enforce=baseline \
  pod-security.kubernetes.io/warn=restricted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;The docs' description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;privileged&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"Unrestricted policy"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;baseline&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"Minimally restrictive policy which prevents known privilege escalations"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;restricted&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"Heavily restricted policy, following current Pod hardening best practices"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Same surprise as with quotas: &lt;code&gt;enforce&lt;/code&gt; applies to Pods only. A Deployment that breaks the policy is accepted, and its Pods are rejected.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;warn&lt;/code&gt; label is what tells the person running &lt;code&gt;kubectl apply&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Almost nothing can be referenced across namespaces
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;From a namespace, can you use&lt;/th&gt;
&lt;th&gt;Answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A Secret or ConfigMap of another namespace in a Pod&lt;/td&gt;
&lt;td&gt;No. "The Pod and the ConfigMap must be in the same namespace", and the same goes for Secrets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A PersistentVolumeClaim of another namespace&lt;/td&gt;
&lt;td&gt;No. "Claims must exist in the same namespace as the Pod using the claim"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A Service of another namespace as an Ingress backend&lt;/td&gt;
&lt;td&gt;No. "The service must exist in the same namespace as the Ingress object"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An owner in another namespace&lt;/td&gt;
&lt;td&gt;No. "Cross-namespace owner references are disallowed by design"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A Service of another namespace over the network&lt;/td&gt;
&lt;td&gt;Yes, by DNS name, unless a NetworkPolicy blocks it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A Gateway of another namespace from a Route (Gateway API)&lt;/td&gt;
&lt;td&gt;Yes, when "the Gateway owner and Route owner both agree"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A backend or Secret of another namespace (Gateway API)&lt;/td&gt;
&lt;td&gt;Yes, when the owner of the target creates a ReferenceGrant&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The pattern: objects reference inside their namespace, and traffic crosses.&lt;/p&gt;

&lt;p&gt;So the same Secret in 2 namespaces means 2 copies, or a tool that syncs them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Slice by team and application, keep environments apart
&lt;/h2&gt;

&lt;p&gt;The docs set the bar for when to start: "For clusters with a few to tens of users, you should not need to create or think about namespaces at all."&lt;/p&gt;

&lt;p&gt;I would start earlier, for a boring reason. Moving a running application to another namespace later means recreating every object in it.&lt;/p&gt;

&lt;p&gt;How I would slice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;1 namespace per team and application.&lt;/strong&gt; &lt;code&gt;payments-api&lt;/code&gt;, &lt;code&gt;payments-worker&lt;/code&gt;, &lt;code&gt;search-api&lt;/code&gt;. Permissions, quotas and network rules then line up with who owns what&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Versions of the same software share a namespace.&lt;/strong&gt; The docs: "use labels to distinguish resources within the same namespace"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environments get clusters when you can afford it.&lt;/strong&gt; At least production. A bad upgrade, a broken CRD or a noisy node ignores namespace lines&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Platform tools get their own.&lt;/strong&gt; &lt;code&gt;ingress&lt;/code&gt;, &lt;code&gt;monitoring&lt;/code&gt;, &lt;code&gt;argocd&lt;/code&gt;. Never &lt;code&gt;kube-system&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On names, Google's advice is to "avoid tying the environment name (development, staging, and production) to the namespace name and instead use the same name across environments."&lt;/p&gt;

&lt;p&gt;I agree: &lt;code&gt;payments-api&lt;/code&gt; in the staging cluster and &lt;code&gt;payments-api&lt;/code&gt; in the production cluster means 1 set of manifests.&lt;/p&gt;

&lt;p&gt;How far it scales, from the Kubernetes scalability thresholds:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Limit&lt;/th&gt;
&lt;th&gt;Threshold&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Namespaces per cluster&lt;/td&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods per namespace&lt;/td&gt;
&lt;td&gt;3,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Services per namespace&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deployments per namespace&lt;/td&gt;
&lt;td&gt;2,000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most of them are soft: crossing one "results in degraded performance" before anything fails.&lt;/p&gt;

&lt;p&gt;Your deploy tools each have their own way of handling the namespace:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;How it handles the namespace&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Helm&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;--namespace&lt;/code&gt; picks it. A missing namespace is an error unless you pass &lt;code&gt;--create-namespace&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Argo CD&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;CreateNamespace=true&lt;/code&gt; as a sync option creates it. &lt;code&gt;managedNamespaceMetadata&lt;/code&gt; sets its labels&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kustomize&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;namespace:&lt;/code&gt; "will override the existing namespace if it is set on a resource"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A namespace created by a flag has no quota and no policies. I would keep the Namespace manifest in Git next to its 4 additions and let the tools deploy into it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Namespaces vs clusters: trust decides
&lt;/h2&gt;

&lt;p&gt;The docs describe a spectrum from "soft" multi-tenancy to "hard" multi-tenancy.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Who shares&lt;/th&gt;
&lt;th&gt;What separates them&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Teams of 1 company&lt;/td&gt;
&lt;td&gt;Namespaces with the 4 additions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Teams that need their own CRDs or cluster-wide settings&lt;/td&gt;
&lt;td&gt;A virtual control plane per team&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Customers, or anyone running code you did not write&lt;/td&gt;
&lt;td&gt;A cluster per tenant, or a virtual control plane on isolated nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;What the 3 clouds say about the last row:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS:&lt;/strong&gt; "the cluster is the only construct that provides a strong security boundary"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft:&lt;/strong&gt; "Kubernetes environments aren't entirely safe for hostile multi-tenant usage"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google:&lt;/strong&gt; "Kubernetes cannot guarantee perfectly secure isolation between tenants"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And what they say about the first row. Microsoft: "Minimize the number of physical AKS clusters you deploy to isolate teams or applications." Google: a tenant per cluster or per project is "harder to manage".&lt;/p&gt;

&lt;p&gt;Both are right. Trust = the variable.&lt;/p&gt;

&lt;p&gt;A virtual control plane gives each tenant its own API server. Tools like vCluster run it inside a namespace of a host cluster. It isolates the cluster-scoped objects, and it leaves the nodes shared: per-tenant control planes "do not solve isolation problems in the data plane".&lt;/p&gt;

&lt;p&gt;2 things changed here recently:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Hierarchical Namespace Controller, the project that gave namespaces a parent and child structure, was archived on April 17, 2025&lt;/li&gt;
&lt;li&gt;AKS has managed namespaces, which bundle quotas, network policies and access with the namespace. GKE has fleet namespaces and team scopes, which manage access to namespaces across clusters&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fix a namespace stuck in Terminating
&lt;/h2&gt;

&lt;p&gt;Deleting a namespace is asynchronous. What happens after &lt;code&gt;kubectl delete namespace shop&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The API server sets a deletion timestamp, and the phase becomes &lt;code&gt;Terminating&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;New objects are refused in it&lt;/li&gt;
&lt;li&gt;The namespace controller deletes the Pods first, and waits for them (the default order since Kubernetes v1.33, stable since v1.34)&lt;/li&gt;
&lt;li&gt;It deletes everything else, resource type by resource type&lt;/li&gt;
&lt;li&gt;It removes the &lt;code&gt;kubernetes&lt;/code&gt; finalizer from the namespace's &lt;code&gt;spec.finalizers&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The namespace is gone&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmqlynkslyg9lajo9nhvc.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmqlynkslyg9lajo9nhvc.webp" alt="What happens when you delete a Kubernetes namespace: kubectl delete namespace, phase Terminating, Pods are deleted first, everything else is deleted, finalizer removed and namespace gone. Stuck in Terminating means something could not be deleted" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A namespace that stays in Terminating is waiting on one of the middle steps.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Stuck in Terminating = the controller could not list or delete something in the namespace.&lt;/p&gt;

&lt;p&gt;It tells you why. Read the conditions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get namespace shop -o yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition in &lt;code&gt;status.conditions&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;th&gt;What to do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NamespaceDeletionDiscoveryFailure&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;An API group does not answer, so the controller cannot list what to delete&lt;/td&gt;
&lt;td&gt;Find the broken APIService&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NamespaceContentRemaining&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Objects are still in the namespace&lt;/td&gt;
&lt;td&gt;List them, find what blocks them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NamespaceFinalizersRemaining&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Those objects carry finalizers that nothing is removing&lt;/td&gt;
&lt;td&gt;Bring back the controller that owns the finalizer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NamespaceDeletionContentFailure&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A delete call failed&lt;/td&gt;
&lt;td&gt;Read the message, it names the resource&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A common cause of the first one is an add-on that was removed while its APIService stayed behind (a metrics adapter, for example):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get apiservice | grep False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And for the second, Google's GKE troubleshooting docs give the command that lists what is left:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl api-resources --verbs=list --namespaced -o name \
  | xargs -n 1 kubectl get -n shop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A common cause of the third: you deleted an operator before the custom resources it manages. The resources wait for a controller that no longer exists.&lt;/p&gt;

&lt;p&gt;What half the internet tells you to do is empty the finalizers and move on.&lt;/p&gt;

&lt;p&gt;The Kubernetes docs: "avoid manually removing finalizers to allow deletion to continue. Finalizers are usually added to resources for a reason."&lt;/p&gt;

&lt;p&gt;Google documents the forced route "only as a last resort", because it "could result in resources remaining in your cluster that you can't access".&lt;/p&gt;

&lt;p&gt;A load balancer or a disk that nobody can see is still on the invoice.&lt;/p&gt;

&lt;p&gt;My order: conditions, then the APIService, then the leftover objects. A finalizer gets removed by hand only after you cleaned up what it was guarding.&lt;/p&gt;

&lt;h2&gt;
  
  
  The namespace checklist
&lt;/h2&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nothing of yours runs in &lt;code&gt;default&lt;/code&gt; or &lt;code&gt;kube-system&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Every namespace is a manifest in Git, with an owner label&lt;/li&gt;
&lt;li&gt;Every namespace has a RoleBinding to a group (a list of people goes stale)&lt;/li&gt;
&lt;li&gt;Every namespace has a ResourceQuota, and a LimitRange next to it&lt;/li&gt;
&lt;li&gt;Every namespace has a default deny NetworkPolicy, and your network plugin enforces it&lt;/li&gt;
&lt;li&gt;Every namespace has a &lt;code&gt;pod-security.kubernetes.io/enforce&lt;/code&gt; label&lt;/li&gt;
&lt;li&gt;Only the platform team can create namespaces or patch them&lt;/li&gt;
&lt;li&gt;The same application has the same namespace name in every cluster&lt;/li&gt;
&lt;li&gt;Custom resources are deleted first, their operator last&lt;/li&gt;
&lt;li&gt;Tenants who do not trust each other share no control plane and no nodes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Kubernetes namespace FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a namespace in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;A namespace is a scope for names inside 1 cluster, and the unit that permissions, quotas, network policies and Pod security rules attach to. Object names have to be unique within a namespace, and can repeat across namespaces.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I list all namespaces?
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;kubectl get namespaces&lt;/code&gt;. To list Pods or any other resource across all of them, add &lt;code&gt;-A&lt;/code&gt;, as in &lt;code&gt;kubectl get pods -A&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I switch the namespace in kubectl?
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;kubectl config set-context --current --namespace=NAME&lt;/code&gt;. It saves the namespace in your kubeconfig for every later command in that context. For 1 command, pass &lt;code&gt;-n NAME&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a node and a namespace?
&lt;/h3&gt;

&lt;p&gt;A node is a machine that runs Pods. A namespace is a grouping of objects in the API. Nodes belong to no namespace, and the Pods of every namespace run side by side on the same nodes unless you schedule them apart.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a namespace and a cluster?
&lt;/h3&gt;

&lt;p&gt;A cluster has its own API server, nodes and cluster-wide settings. A namespace is a partition inside 1 cluster that shares all 3. Use namespaces for teams that trust each other and clusters for tenants that do not.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can Pods in different namespaces communicate?
&lt;/h3&gt;

&lt;p&gt;Yes, by default. All Pods in a cluster can reach each other until a NetworkPolicy says otherwise, and a Service in another namespace is reachable as &lt;code&gt;service.namespace&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does deleting a namespace delete everything in it?
&lt;/h3&gt;

&lt;p&gt;Yes. Every namespaced object in it is deleted, custom resources and PersistentVolumeClaims included. A volume that was provisioned for a claim follows its reclaim policy, and for dynamically provisioned volumes the default is Delete, so the disk goes too.&lt;/p&gt;

&lt;h3&gt;
  
  
  How many namespaces can a Kubernetes cluster have?
&lt;/h3&gt;

&lt;p&gt;The Kubernetes scalability thresholds put it at 10,000 per cluster. That is a tested threshold on the largest clusters, and Google calls it a theoretical maximum that "many factors" can keep you from reaching.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Recap!
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing from this guide, let it be this:&lt;/p&gt;

&lt;p&gt;A namespace is where isolation attaches. The isolation is what you add to it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Namespace = a scope for names, and a hook for policy&lt;/li&gt;
&lt;li&gt;By default all Pods can talk to each other, across every namespace&lt;/li&gt;
&lt;li&gt;The 4 additions: a RoleBinding, a ResourceQuota, a NetworkPolicy, Pod Security labels&lt;/li&gt;
&lt;li&gt;Create a Pod = own the namespace. Split by trust&lt;/li&gt;
&lt;li&gt;Stuck in Terminating: read the conditions before you touch a finalizer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You don't NEED anyone for this. The checklist above is the whole job, and every piece of it ships with Kubernetes.&lt;/p&gt;

&lt;p&gt;If you would rather have someone who has done it look at your cluster first (yes, I sell DevOps engineers), start with the &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free assessment&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes Secrets: What They Protect and What They Don't</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Fri, 27 Nov 2026 15:30:12 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-secrets-what-they-protect-and-what-they-dont-5ego</link>
      <guid>https://dev.to/meteorops/kubernetes-secrets-what-they-protect-and-what-they-dont-5ego</guid>
      <description>&lt;p&gt;A Kubernetes Secret is encoded in base64, and base64 is undone by 1 command that ships with every laptop:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Secret = a small object for a password, a token or a key.&lt;/strong&gt; The Kubernetes docs: base64 "provides no additional confidentiality over plain text"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It protects less than the name says.&lt;/strong&gt; By default Secrets are "stored unencrypted" in etcd, the cluster's database&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your cloud covers part of that.&lt;/strong&gt; EKS, GKE and AKS encrypt the storage under etcd by default. EKS (Kubernetes 1.28 and higher) also encrypts every Secret with KMS by default&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Whoever can create a Pod can read the Secret.&lt;/strong&gt; In the same namespace, with no permission on Secrets at all&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The real value lives outside Git.&lt;/strong&gt; In a secrets manager, synced into the cluster by a tool&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What to do, by where you are today:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Your situation&lt;/th&gt;
&lt;th&gt;What I would do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Secret manifests are committed to Git as plain YAML&lt;/td&gt;
&lt;td&gt;Rotate those values (deleting the file leaves them in the history), then move to 1 of the 4 tools below&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You run on EKS, GKE or AKS&lt;/td&gt;
&lt;td&gt;Keep the value in the cloud's secrets manager and sync it with External Secrets Operator&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You run your own control plane&lt;/td&gt;
&lt;td&gt;Turn on encryption at rest with a KMS v2 provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Developers have "edit" on a namespace&lt;/td&gt;
&lt;td&gt;They can read every Secret in it. The built-in edit role allows it directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An app still uses the old password after a rotation&lt;/td&gt;
&lt;td&gt;Restart it. Environment variables do not update&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Create a Secret, and read it back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create secret generic db-credentials \
  --namespace shop \
  --from-literal=username=shop \
  --from-literal=password='S!B\*d$zDsb='

kubectl get secret db-credentials --namespace shop \
  -o jsonpath='{.data.password}' | base64 --decode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second command is the whole "security" of base64.&lt;/p&gt;

&lt;p&gt;Every version, default and quote in this guide comes from the Kubernetes documentation, the AWS, Google and Microsoft docs, the Flux, Argo CD and HashiCorp docs and the tools' own repositories, as read on November 25, 2026 (Kubernetes is at v1.37).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Not sure who can read the Secrets in your production cluster?&lt;/strong&gt; In a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free assessment&lt;/a&gt;, a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup, the secrets handling included.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You are new to Secrets:&lt;/strong&gt; start at &lt;a href="https://meteorops.com/blog/kubernetes-secrets#a-secret-is-a-base64-object-in-the-cluster-database" rel="noopener noreferrer"&gt;a Secret is a base64 object&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You need the commands:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-secrets#create-a-secret-with-kubectl-and-read-it-back" rel="noopener noreferrer"&gt;create a Secret with kubectl&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You rotated a value and the app did not notice:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-secrets#an-updated-secret-reaches-a-pod-in-3-different-ways" rel="noopener noreferrer"&gt;how updates reach a Pod&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You are reviewing access:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-secrets#know-who-can-read-a-secret" rel="noopener noreferrer"&gt;who can read a Secret&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You were asked "are our Secrets encrypted?":&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-secrets#encryption-at-rest-has-2-layers-and-your-cloud-did-the-first" rel="noopener noreferrer"&gt;encryption at rest&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You use GitOps and Secrets are the exception:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-secrets#keep-secrets-out-of-git-with-1-of-4-tools" rel="noopener noreferrer"&gt;the 4 tools&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Pod will not start:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-secrets#fix-a-pod-that-cannot-get-its-secret" rel="noopener noreferrer"&gt;fix a Pod that cannot get its Secret&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A Secret is a base64 object in the cluster database
&lt;/h2&gt;

&lt;p&gt;The docs' definition: "A Secret is an object that contains a small amount of sensitive data such as a password, a token, or a key."&lt;/p&gt;

&lt;p&gt;It exists so that the password does not sit in the container image or in the Pod spec.&lt;/p&gt;

&lt;p&gt;That is the whole promise. Separation, with a few handling rules on top.&lt;/p&gt;

&lt;p&gt;The same Secret as a manifest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Secret
metadata:
  name: db-credentials
  namespace: shop
type: Opaque
stringData:
  username: shop
  password: "S!B\\*d$zDsb="
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are 2 fields for the values:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;You write&lt;/th&gt;
&lt;th&gt;Good to know&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;data&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;base64 strings&lt;/td&gt;
&lt;td&gt;What the API returns when you read the Secret&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;stringData&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Plain strings&lt;/td&gt;
&lt;td&gt;Write-only. Merged into &lt;code&gt;data&lt;/code&gt;, and it wins when a key is in both&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;base64 = a way to carry binary data in a text field. Encoding, with no key and no confidentiality.&lt;/p&gt;

&lt;p&gt;(A Secret in base64 is a password written backwards on a sticky note.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6ljc8gq10uk3kztyd41g.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6ljc8gq10uk3kztyd41g.webp" alt="A Kubernetes Secret is base64 and base64 is encoding: the word password becomes cGFzc3dvcmQ=, is stored in etcd unencrypted by default, and base64 --decode turns it back" width="799" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Encoding goes both ways, with no key.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;3 details that save an hour each:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Size:&lt;/strong&gt; "Individual Secrets are limited to 1MiB in size." A Secret is for credentials, a file store is for files&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Newlines:&lt;/strong&gt; &lt;code&gt;echo "value" | base64&lt;/code&gt; encodes a trailing newline into the password. Use &lt;code&gt;echo -n&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-side apply:&lt;/strong&gt; the docs warn that &lt;code&gt;stringData&lt;/code&gt; "does not work well with server-side apply". Use &lt;code&gt;data&lt;/code&gt; there&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A Secret looks like a &lt;a href="https://meteorops.com/glossary/kubernetes-configmap" rel="noopener noreferrer"&gt;ConfigMap&lt;/a&gt; on purpose. The docs: "Secrets are similar to ConfigMaps but are specifically intended to hold confidential data."&lt;/p&gt;

&lt;p&gt;The difference is in the handling. A Secret is only sent to a node when a Pod on that node needs it, and the kubelet keeps it in memory (tmpfs) "so that the confidential data is not written to durable storage".&lt;/p&gt;
&lt;h2&gt;
  
  
  Pick the Secret type by what will read it
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;type&lt;/code&gt; field tells Kubernetes which keys to expect.&lt;/p&gt;

&lt;p&gt;There are 8 built-in types:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Holds&lt;/th&gt;
&lt;th&gt;Keys&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Opaque&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Anything. The default&lt;/td&gt;
&lt;td&gt;Yours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubernetes.io/tls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A certificate and its key&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;tls.crt&lt;/code&gt;, &lt;code&gt;tls.key&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubernetes.io/dockerconfigjson&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Registry credentials&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.dockerconfigjson&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubernetes.io/dockercfg&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Registry credentials, legacy format&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.dockercfg&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubernetes.io/basic-auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A user name and a password&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;username&lt;/code&gt;, &lt;code&gt;password&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubernetes.io/ssh-auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;An SSH private key&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ssh-privatekey&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubernetes.io/service-account-token&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A long-lived ServiceAccount token (legacy)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;token&lt;/code&gt;, filled in by a controller&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;bootstrap.kubernetes.io/token&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A node bootstrap token&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;token-id&lt;/code&gt;, &lt;code&gt;token-secret&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The rule I use: if another component reads the Secret, use that component's type. Otherwise Opaque.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;An Ingress or a Gateway reads it:&lt;/strong&gt; &lt;code&gt;kubernetes.io/tls&lt;/code&gt; (how that Secret is used is in &lt;a href="https://meteorops.com/blog/kubernetes-ingress" rel="noopener noreferrer"&gt;the Kubernetes Ingress guide&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The kubelet reads it to pull an image:&lt;/strong&gt; &lt;code&gt;kubernetes.io/dockerconfigjson&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your application reads it:&lt;/strong&gt; Opaque&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The type is a shape check and nothing more.&lt;/p&gt;

&lt;p&gt;For a TLS Secret the docs say the API server "doesn't actually validate the values for each key". An expired certificate is accepted like a valid one.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create a Secret with kubectl and read it back
&lt;/h2&gt;

&lt;p&gt;4 commands cover almost every case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# From values on the command line
kubectl create secret generic db-credentials \
  --from-literal=username=shop \
  --from-literal=password='S!B\*d$zDsb='

# From files (the key is the file name, or key=path)
kubectl create secret generic app-keys \
  --from-file=ssh-privatekey=./id_ed25519

# From a .env file of key=val lines
kubectl create secret generic app-env --from-env-file=./prod.env

# TLS and registry credentials
kubectl create secret tls shop-tls --cert=./tls.crt --key=./tls.key
kubectl create secret docker-registry regcred \
  --docker-server=registry.example.com \
  --docker-username=ci --docker-password='...'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Single quotes matter. The docs: "You must use single quotes '' to escape special characters such as $, \, *, =, and ! in your strings."&lt;/p&gt;

&lt;p&gt;Without them your shell rewrites the password before kubectl sees it.&lt;/p&gt;

&lt;p&gt;Reading is where people get surprised.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Shows&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl get secret db-credentials&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Name, type, number of keys, age&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl describe secret db-credentials&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Key names and sizes (&lt;code&gt;password: 12 bytes&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl get secret db-credentials -o yaml&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Every value, in base64&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;`kubectl get secret db-credentials -o jsonpath='{.data.password}' \&lt;/td&gt;
&lt;td&gt;base64 --decode`&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Decode in 1 piped command, as above.&lt;/p&gt;

&lt;p&gt;Why? Because pasting the encoded value into a second command puts it in your shell history, where "anyone with access to your computer could find the command and decode the secret" (the docs again).&lt;/p&gt;

&lt;p&gt;For manifests kept in Git with Kustomize, &lt;code&gt;secretGenerator&lt;/code&gt; builds the Secret from files or literals and appends a hash of the data to its name (&lt;code&gt;database-creds-5hdh7hhgfk&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;A changed value = a new name = a rollout of every workload in that kustomization that references it.&lt;/p&gt;

&lt;p&gt;That solves the update problem two sections below. It does not solve where the plain value is stored.&lt;/p&gt;

&lt;p&gt;(More everyday commands are in the &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet" rel="noopener noreferrer"&gt;kubectl cheat sheet&lt;/a&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Give a Secret to a Pod in 4 ways
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Way&lt;/th&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Use it for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1 environment variable per key&lt;/td&gt;
&lt;td&gt;&lt;code&gt;env[].valueFrom.secretKeyRef&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Apps that read config from the environment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Every key as a variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;envFrom[].secretRef&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A Secret made from a .env file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Files in a directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;volumes[].secret&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Certificates, key files, anything that rotates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Registry login&lt;/td&gt;
&lt;td&gt;&lt;code&gt;imagePullSecrets&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Private images. Read by the kubelet, never by your app&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The first and the third in one Pod:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Pod
metadata:
  name: api
  namespace: shop
spec:
  containers:
  - name: api
    image: registry.example.com/shop/api:1.4.2
    env:
    - name: DB_PASSWORD
      valueFrom:
        secretKeyRef:
          name: db-credentials
          key: password
    volumeMounts:
    - name: tls
      mountPath: /etc/tls
      readOnly: true
  volumes:
  - name: tls
    secret:
      secretName: shop-tls
      defaultMode: 0400
  imagePullSecrets:
  - name: regcred
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Files from a Secret volume get mode 0644 unless you set &lt;code&gt;defaultMode&lt;/code&gt;. A private key deserves 0400 when the container runs as root, and 0440 with an &lt;code&gt;fsGroup&lt;/code&gt; when it does not (or the app cannot read its own key).&lt;/p&gt;

&lt;p&gt;The Secret has to be in the Pod's namespace. There is no cross-namespace reference.&lt;/p&gt;

&lt;p&gt;And Secrets are required by default: "None of a Pod's containers will start until all non-optional Secrets are available."&lt;/p&gt;

&lt;p&gt;Add &lt;code&gt;optional: true&lt;/code&gt; to a reference only when the app runs correctly without it.&lt;/p&gt;

&lt;p&gt;One trap with &lt;code&gt;envFrom&lt;/code&gt;: a key that is not a valid variable name is skipped, and "the Pod is allowed to start". No error. Just a Warning event (&lt;code&gt;InvalidEnvironmentVariableNames&lt;/code&gt;) and a missing variable.&lt;/p&gt;

&lt;p&gt;My default: a volume for anything that rotates, an environment variable for the rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  An updated Secret reaches a Pod in 3 different ways
&lt;/h2&gt;

&lt;p&gt;You rotated the database password and updated the Secret.&lt;/p&gt;

&lt;p&gt;What the running Pod sees depends on how it consumes it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Consumed as&lt;/th&gt;
&lt;th&gt;After the Secret changes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Volume mount&lt;/td&gt;
&lt;td&gt;Updated, eventually. Up to "the kubelet sync period + cache propagation delay"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Volume mount with &lt;code&gt;subPath&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Never updated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Environment variable&lt;/td&gt;
&lt;td&gt;Not updated "unless it is restarted"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F13ux0qbju2ef2zfx2j2v.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F13ux0qbju2ef2zfx2j2v.webp" alt="After a Kubernetes Secret changes: a volume mount is updated eventually, a volume mount with subPath is never updated, an environment variable is not updated until restart" width="799" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The same new password, 3 different outcomes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So "Secrets update automatically" is true for 1 row out of 3.&lt;/p&gt;

&lt;p&gt;And even in that row, the file changes while the process keeps the old value in memory until it reads the file again.&lt;/p&gt;

&lt;p&gt;The fix is a restart:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl rollout restart deployment/api --namespace shop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or make the restart automatic. Reloader (v1.4.25 today, with a v2 in beta) is a controller that "automatically triggers rollouts of workloads" when a Secret or ConfigMap they reference is updated.&lt;/p&gt;

&lt;p&gt;1 annotation on the Deployment turns it on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;metadata:
  annotations:
    reloader.stakater.com/auto: "true"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The opposite choice is to forbid updates.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;immutable: true&lt;/code&gt; (stable since Kubernetes v1.21) makes a Secret read-only. The docs: it "protects you from accidental (or unwanted) updates that could cause applications outages".&lt;/p&gt;

&lt;p&gt;It is a one-way door: "it is not possible to revert this change nor to mutate the contents of the data field. You can only delete and recreate the Secret."&lt;/p&gt;

&lt;p&gt;The performance benefit people quote applies to clusters with "at least tens of thousands of unique Secret to Pod mounts". For everyone else, immutable is a safety setting.&lt;/p&gt;

&lt;p&gt;Immutable Secrets pair well with the Kustomize name hash: every change is a new Secret and a normal rollout (rollouts themselves are in &lt;a href="https://meteorops.com/blog/deployment-strategies" rel="noopener noreferrer"&gt;the deployment strategies guide&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Know who can read a Secret
&lt;/h2&gt;

&lt;p&gt;More people than the &lt;a href="https://meteorops.com/glossary/kubernetes-rbac" rel="noopener noreferrer"&gt;RBAC&lt;/a&gt; (role-based access control) rules suggest.&lt;/p&gt;

&lt;p&gt;The docs list most of them. I added what each one needs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Who&lt;/th&gt;
&lt;th&gt;How&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Anyone with &lt;code&gt;get&lt;/code&gt; on Secrets&lt;/td&gt;
&lt;td&gt;Reads the Secret by name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Anyone with &lt;code&gt;list&lt;/code&gt; or &lt;code&gt;watch&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;A list "response includes the contents of all Secrets"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Anyone who can create a Pod in the namespace&lt;/td&gt;
&lt;td&gt;Mounts the Secret in a Pod and prints it. A Deployment or a Job works too&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Anyone who can exec into a Pod that uses it&lt;/td&gt;
&lt;td&gt;Reads the file or the variable from inside the container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A container running with &lt;code&gt;privileged: true&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;It "can access all Secrets used on that node"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Anyone with access to etcd or its backups&lt;/td&gt;
&lt;td&gt;Reads the database directly. This is what encryption at rest is for&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjx0ttj5gyglnwfjqs6uv.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjx0ttj5gyglnwfjqs6uv.webp" alt="Who can read a Kubernetes Secret: get, list or watch, create a Pod in the namespace, privileged: true, access to etcd or its backups" width="799" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The pink one needs no permission on Secrets.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The third row is the one teams miss.&lt;/p&gt;

&lt;p&gt;The docs say it twice: anyone "authorized to create a Pod in a namespace can use that access to read any Secret in that namespace", and "even if cluster policies do not allow a user to read the Secret directly".&lt;/p&gt;

&lt;p&gt;Create workloads = read Secrets.&lt;/p&gt;

&lt;p&gt;So the unit of isolation is the namespace. Two teams that must not see each other's credentials get two namespaces.&lt;/p&gt;

&lt;p&gt;Count your controllers too. External Secrets Operator, Sealed Secrets and Reloader all read Secrets across the cluster.&lt;/p&gt;

&lt;p&gt;Check what an identity can do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl auth can-i list secrets --namespace shop \
  --as system:serviceaccount:shop:api

kubectl auth can-i create pods --namespace shop --as jane@example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a Role that gives 1 workload 1 Secret, with &lt;code&gt;get&lt;/code&gt; only:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: read-db-credentials
  namespace: shop
rules:
- apiGroups: [""]
  resources: ["secrets"]
  resourceNames: ["db-credentials"]
  verbs: ["get"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Bind it to the workload's ServiceAccount with a RoleBinding.)&lt;/p&gt;

&lt;p&gt;Most applications need no Role at all. The kubelet delivers the Secret to the Pod, and the app never calls the API.&lt;/p&gt;

&lt;p&gt;The docs' rule for the rest: keep &lt;code&gt;watch&lt;/code&gt; and &lt;code&gt;list&lt;/code&gt; for "the most privileged, system-level components".&lt;/p&gt;

&lt;h2&gt;
  
  
  Encryption at rest has 2 layers, and your cloud did the first
&lt;/h2&gt;

&lt;p&gt;"Are our Secrets encrypted at rest?" has 2 answers, because there are 2 layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Storage layer&lt;/strong&gt; = the disk under etcd is encrypted. It protects against a stolen disk or snapshot&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes layer&lt;/strong&gt; = the API server encrypts each Secret before it writes it to etcd. It also protects against someone who reads etcd itself, or an etcd backup file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Neither changes anything for &lt;code&gt;kubectl get secret&lt;/code&gt;. The API server decrypts for everyone RBAC allows.&lt;/p&gt;

&lt;p&gt;The common advice is "you must enable it". On a managed cluster, check first which layer is already on:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cluster&lt;/th&gt;
&lt;th&gt;Storage layer&lt;/th&gt;
&lt;th&gt;Kubernetes layer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Amazon EKS&lt;/td&gt;
&lt;td&gt;On for every cluster: etcd data is "encrypted at the disk level"&lt;/td&gt;
&lt;td&gt;On by default from Kubernetes 1.28: "default envelope encryption for all Kubernetes API data", with an AWS owned key or your own KMS key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google GKE&lt;/td&gt;
&lt;td&gt;On by default: GKE "encrypts customer content stored at rest, including Secrets"&lt;/td&gt;
&lt;td&gt;Opt-in: application-layer secrets encryption with your key in Cloud KMS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure AKS&lt;/td&gt;
&lt;td&gt;On by default: Azure Storage encryption, "always enabled"&lt;/td&gt;
&lt;td&gt;Opt-in: a KMS layer with keys in Azure Key Vault&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Your own control plane&lt;/td&gt;
&lt;td&gt;Yours to set up&lt;/td&gt;
&lt;td&gt;Off: the API server stores "plain-text representations of resources" until you add an &lt;code&gt;EncryptionConfiguration&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On AKS, the newer KMS experience (platform-managed or customer-managed keys) needs Kubernetes 1.33 or later, and its how-to page is still marked Preview.&lt;/p&gt;

&lt;p&gt;On your own control plane, you pick a provider. The Kubernetes docs grade them:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;Strength in the docs&lt;/th&gt;
&lt;th&gt;The docs' note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;identity&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;The default. No encryption&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;aescbc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Weak&lt;/td&gt;
&lt;td&gt;"Not recommended due to CBC's vulnerability to padding oracle attacks"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;aesgcm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Must be rotated every 200,000 writes&lt;/td&gt;
&lt;td&gt;Not recommended without automated key rotation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;secretbox&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Strong&lt;/td&gt;
&lt;td&gt;The key still sits on the control plane host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;kms&lt;/code&gt; v1&lt;/td&gt;
&lt;td&gt;Strongest&lt;/td&gt;
&lt;td&gt;Deprecated since v1.28, disabled by default since v1.29&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;kms&lt;/code&gt; v2&lt;/td&gt;
&lt;td&gt;Strongest&lt;/td&gt;
&lt;td&gt;"A good choice if using a third party tool for key management". Stable from v1.29&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Many tutorials still show &lt;code&gt;aescbc&lt;/code&gt; with a key pasted into the file.&lt;/p&gt;

&lt;p&gt;The docs on that setup: it "only moderately improves your security posture, compared to no encryption", because the key lies next to the data it protects.&lt;/p&gt;

&lt;p&gt;Use KMS v2, so the key lives outside the cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: apiserver.config.k8s.io/v1
kind: EncryptionConfiguration
resources:
  - resources:
      - secrets
    providers:
      - kms:
          apiVersion: v2
          name: my-kms-plugin
          endpoint: unix:///var/run/kms/plugin.sock
      - identity: {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 rules for this file:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The first provider encrypts.&lt;/strong&gt; All of them are tried for reading. With &lt;code&gt;identity&lt;/code&gt; first, nothing is encrypted&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The API server loads it&lt;/strong&gt; from the path in &lt;code&gt;--encryption-provider-config&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Old Secrets stay as they were&lt;/strong&gt; until they are written again&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The docs' command for the third rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get secrets --all-namespaces -o json | kubectl replace -f -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order matters:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A KMS plugin listens on that socket on every control plane node&lt;/li&gt;
&lt;li&gt;Every API server gets the file and a restart&lt;/li&gt;
&lt;li&gt;You run the command as an administrator who can read and write every Secret. On a conflict error, run it again: the docs call it "safe to run that command more than once"&lt;/li&gt;
&lt;li&gt;You confirm it finished with no errors. Only then remove &lt;code&gt;identity&lt;/code&gt;, and restart each API server in turn&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remove &lt;code&gt;identity&lt;/code&gt; too early, and every Secret that was never rewritten becomes unreadable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep Secrets out of Git with 1 of 4 tools
&lt;/h2&gt;

&lt;p&gt;You keep everything in Git. Deployments, Services, the lot (that is &lt;a href="https://meteorops.com/blog/why-when-to-use-gitops-use-cases-principles" rel="noopener noreferrer"&gt;GitOps&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Then comes the Secret, and a manifest with base64 in it is a manifest with the password in it.&lt;/p&gt;

&lt;p&gt;The Flux docs put it plainly: "Storing Secrets in Git repositories in plain text or base64 is unsafe, regardless of the visibility or access restrictions of the repository."&lt;/p&gt;

&lt;p&gt;There are 2 families of answers. Encrypt the file, or keep the value somewhere else and fetch it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;In Git&lt;/th&gt;
&lt;th&gt;In the cluster&lt;/th&gt;
&lt;th&gt;Status today&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;External Secrets Operator&lt;/td&gt;
&lt;td&gt;A pointer (&lt;code&gt;ExternalSecret&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;A Secret, synced from your secrets manager&lt;/td&gt;
&lt;td&gt;v2.15.0. CNCF Sandbox&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Secrets Store CSI Driver&lt;/td&gt;
&lt;td&gt;A pointer (&lt;code&gt;SecretProviderClass&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Files in the Pod, with no Secret object&lt;/td&gt;
&lt;td&gt;v1.6.2. Sync to a Secret and rotation are alpha&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sealed Secrets&lt;/td&gt;
&lt;td&gt;The encrypted value (&lt;code&gt;SealedSecret&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;A Secret, decrypted by the controller&lt;/td&gt;
&lt;td&gt;v0.41.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SOPS&lt;/td&gt;
&lt;td&gt;The encrypted file&lt;/td&gt;
&lt;td&gt;A Secret, decrypted at deploy time&lt;/td&gt;
&lt;td&gt;v3.13.3. CNCF Sandbox&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvw694wy8xdsckpb74qha.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvw694wy8xdsckpb74qha.webp" alt="Keep Kubernetes Secrets out of Git with External Secrets Operator (a pointer in Git, a Secret in the cluster), Secrets Store CSI Driver (a pointer in Git, files in the Pod), Sealed Secrets (the encrypted value in Git) or SOPS (the encrypted file in Git)" width="799" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;What Git holds, and what the cluster ends up with.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  External Secrets Operator: the value stays in your secrets manager
&lt;/h3&gt;

&lt;p&gt;It "reads information from external APIs and automatically injects the values into a Kubernetes Secret".&lt;/p&gt;

&lt;p&gt;External APIs = AWS Secrets Manager, Google Secret Manager, Azure Key Vault, HashiCorp Vault and many more.&lt;/p&gt;

&lt;p&gt;A SecretStore says how to reach the store. An ExternalSecret says what to fetch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
  name: db-credentials
  namespace: shop
spec:
  refreshInterval: 1h
  secretStoreRef:
    name: aws-secrets-manager
    kind: ClusterSecretStore
  target:
    name: db-credentials
  data:
  - secretKey: password
    remoteRef:
      key: prod/shop/db
      property: password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the first line of any example you copy. &lt;code&gt;external-secrets.io/v1beta1&lt;/code&gt; stopped being served in v0.17.0 (May 2025), and tutorials that were "updated" in 2026 still carry it.&lt;/p&gt;

&lt;p&gt;Two things to know before you depend on it.&lt;/p&gt;

&lt;p&gt;In August 2025 the maintainers stopped releases until more maintainers joined. They resumed in September 2025 and have shipped every few weeks since.&lt;/p&gt;

&lt;p&gt;And only the current minor version is supported, so plan to upgrade it often.&lt;/p&gt;

&lt;h3&gt;
  
  
  Secrets Store CSI Driver: no Secret object at all
&lt;/h3&gt;

&lt;p&gt;It mounts "secrets, keys, and certs stored in enterprise-grade external secrets stores into their pods as a volume".&lt;/p&gt;

&lt;p&gt;The value goes from the store to a file in the Pod. Nothing lands in etcd, as long as the sync feature below stays off.&lt;/p&gt;

&lt;p&gt;That is the reason to choose it, and it is also the cost: no Secret object means no &lt;code&gt;secretKeyRef&lt;/code&gt;, so no environment variables.&lt;/p&gt;

&lt;p&gt;The feature that brings them back ("Sync with Kubernetes Secrets") is listed under alpha functionality on the project's own page. So is rotation, which is off by default.&lt;/p&gt;

&lt;p&gt;On EKS the AWS provider for it is an EKS add-on (&lt;code&gt;aws-secrets-store-csi-driver-provider&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Sealed Secrets: the encrypted value lives in Git
&lt;/h3&gt;

&lt;p&gt;The project states its problem in 1 line: "I can manage all my K8s config in git, except Secrets."&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubeseal&lt;/code&gt; encrypts a Secret with the controller's public key. Only the controller in that cluster can decrypt it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create secret generic db-credentials --namespace shop \
  --from-literal=password='S!B\*d$zDsb=' \
  --dry-run=client -o yaml | kubeseal --format yaml &amp;gt; sealed-db-credentials.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(kubeseal expects the controller under its default name in &lt;code&gt;kube-system&lt;/code&gt;. Installed elsewhere, pass &lt;code&gt;--controller-name&lt;/code&gt; and &lt;code&gt;--controller-namespace&lt;/code&gt;.)&lt;/p&gt;

&lt;p&gt;The output is safe to commit. By default it is "strict": it only unseals with the same name in the same namespace.&lt;/p&gt;

&lt;p&gt;The controller adds a new sealing key every 30 days and keeps the old ones. A rebuilt cluster without those keys cannot read a single SealedSecret.&lt;/p&gt;

&lt;p&gt;So back them up after every renewal (last month's backup cannot open what was sealed this month), and guard the backup like the most sensitive secret you have: it opens every SealedSecret in your Git history.&lt;/p&gt;

&lt;h3&gt;
  
  
  SOPS: an encrypted file and a key
&lt;/h3&gt;

&lt;p&gt;SOPS is "an editor of encrypted files" that encrypts with AWS KMS, GCP KMS, Azure Key Vault, age or PGP.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sops --age=age1example... --encrypt \
  --encrypted-regex '^(data|stringData)$' --in-place secret.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keys stay readable, values are encrypted, and a pull request shows which key changed.&lt;/p&gt;

&lt;p&gt;Flux decrypts SOPS files "by itself, without the need of additional controllers".&lt;/p&gt;

&lt;p&gt;Argo CD takes the other side. Its docs "strongly recommend" tools that fill in the Secret on the destination cluster (it names Sealed Secrets, External Secrets Operator and the CSI driver) and "strongly caution against" decrypting during manifest generation, because generated manifests sit "in plaintext in its Redis cache".&lt;/p&gt;

&lt;h3&gt;
  
  
  How I would pick
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You are on a cloud:&lt;/strong&gt; the cloud's secrets manager + External Secrets Operator. This is my default&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A rule says the value must never be in etcd:&lt;/strong&gt; Secrets Store CSI Driver, files only&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You have no secrets manager and use Flux:&lt;/strong&gt; SOPS with age or a KMS key&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You have no secrets manager and use Argo CD:&lt;/strong&gt; Sealed Secrets&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You already run Vault:&lt;/strong&gt; the Vault Secrets Operator (v1.6.2), which "synchronizes secrets from Vault to native Kubernetes Secrets"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HashiCorp documents 3 integrations for Vault: that operator, a CSI provider, and the Agent Injector, which runs a sidecar and renders secrets "to a shared memory volume".&lt;/p&gt;

&lt;p&gt;One rule covers all of them: 1 place holds the real value, and everything else is a copy that can be rebuilt.&lt;/p&gt;

&lt;p&gt;(The wider topic has its own page: &lt;a href="https://meteorops.com/glossary/secrets-management" rel="noopener noreferrer"&gt;secrets management&lt;/a&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  ServiceAccount tokens stopped being Secrets
&lt;/h2&gt;

&lt;p&gt;If you learned Kubernetes before 2022, you remember a &lt;code&gt;default-token-xxxxx&lt;/code&gt; Secret in every namespace.&lt;/p&gt;

&lt;p&gt;Before v1.24, Kubernetes generated a token Secret for every ServiceAccount. Those tokens never expired.&lt;/p&gt;

&lt;p&gt;The docs now call that "a legacy mechanism".&lt;/p&gt;

&lt;p&gt;What a Pod gets today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;→ A token from the TokenRequest API, mounted through a projected volume&lt;/li&gt;
&lt;li&gt;→ Requested for 1 hour, and refreshed by the kubelet before it expires&lt;/li&gt;
&lt;li&gt;→ Bound to the Pod: it stops working when the Pod is deleted&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before you promise an auditor "1 hour", decode a token from your own cluster. The API server can extend the expiry of these tokens (the &lt;code&gt;--service-account-extend-token-expiration&lt;/code&gt; flag, on by default).&lt;/p&gt;

&lt;p&gt;Old auto-generated tokens that stay unused for a year are marked invalid (from v1.29), and later removed.&lt;/p&gt;

&lt;p&gt;You can still create a &lt;code&gt;kubernetes.io/service-account-token&lt;/code&gt; Secret by hand. The docs allow it only when "the security exposure of persisting a non-expiring token credential in a readable API object is acceptable to you".&lt;/p&gt;

&lt;p&gt;For a CI system that needs a token, &lt;code&gt;kubectl create token&lt;/code&gt; gives a short-lived one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix a Pod that cannot get its Secret
&lt;/h2&gt;

&lt;p&gt;Start with the events at the bottom of &lt;code&gt;kubectl describe pod&lt;/code&gt;. The kubelet "reports an Event for that Pod, including details of the problem fetching the Secret".&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you see&lt;/th&gt;
&lt;th&gt;Usual cause&lt;/th&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pod stuck in &lt;code&gt;CreateContainerConfigError&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;An environment variable points at a Secret or a key that does not exist&lt;/td&gt;
&lt;td&gt;The name, the namespace and the key in &lt;code&gt;secretKeyRef&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod stuck in &lt;code&gt;ContainerCreating&lt;/code&gt; with a &lt;code&gt;FailedMount&lt;/code&gt; event&lt;/td&gt;
&lt;td&gt;A volume points at a Secret that does not exist&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;secretName&lt;/code&gt;, and that the Secret is in the Pod's namespace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;ImagePullBackOff&lt;/code&gt; on a private image&lt;/td&gt;
&lt;td&gt;A pull "from a private registry without imagePullSecret", or with a wrong one&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;imagePullSecrets&lt;/code&gt; on the Pod or on its ServiceAccount&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The app gets "access denied" with the right password&lt;/td&gt;
&lt;td&gt;A trailing newline was encoded with it&lt;/td&gt;
&lt;td&gt;Decode and pipe to &lt;code&gt;wc -c&lt;/code&gt;. Recreate with &lt;code&gt;echo -n&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The app still uses the old value&lt;/td&gt;
&lt;td&gt;Environment variable or &lt;code&gt;subPath&lt;/code&gt; mount&lt;/td&gt;
&lt;td&gt;Restart the workload&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1 variable is missing and the Pod runs&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;envFrom&lt;/code&gt; skipped a key that is not a valid variable name&lt;/td&gt;
&lt;td&gt;The Pod's events, then the key names in the Secret&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;illegal base64 data&lt;/code&gt; on apply&lt;/td&gt;
&lt;td&gt;A plain value under &lt;code&gt;data&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Move it to &lt;code&gt;stringData&lt;/code&gt; or encode it. A plain value that happens to be valid base64 is accepted, and decoded into garbage&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;(What that first status means is in the glossary: &lt;a href="https://meteorops.com/glossary/createcontainerconfigerror" rel="noopener noreferrer"&gt;CreateContainerConfigError&lt;/a&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Secrets checklist
&lt;/h2&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The real value lives in 1 place outside Git&lt;/li&gt;
&lt;li&gt;No Secret manifest with &lt;code&gt;data&lt;/code&gt; or &lt;code&gt;stringData&lt;/code&gt; is committed unencrypted&lt;/li&gt;
&lt;li&gt;You know at which layer your cluster encrypts Secrets at rest, and with whose key&lt;/li&gt;
&lt;li&gt;1 namespace per trust boundary&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;list&lt;/code&gt; and &lt;code&gt;watch&lt;/code&gt; on Secrets belong to system components and cluster admins, never to a team role&lt;/li&gt;
&lt;li&gt;Anything that rotates is mounted as a volume, without &lt;code&gt;subPath&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;A rotation ends with a restart, by hand or by Reloader&lt;/li&gt;
&lt;li&gt;Private keys are mounted with a tight &lt;code&gt;defaultMode&lt;/code&gt; (0400 or 0440), never the default 0644&lt;/li&gt;
&lt;li&gt;Every value was created with &lt;code&gt;echo -n&lt;/code&gt; or &lt;code&gt;--from-literal&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The application never logs the value&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Kubernetes Secrets FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Are Kubernetes Secrets encrypted?
&lt;/h3&gt;

&lt;p&gt;Not by default. The values are base64 encoded, and Kubernetes stores them unencrypted in etcd unless encryption at rest is configured. EKS, GKE and AKS encrypt the storage under etcd, EKS (Kubernetes 1.28 and higher) also encrypts each Secret with KMS by default, and on your own control plane you turn it on with an EncryptionConfiguration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are Kubernetes Secrets secure?
&lt;/h3&gt;

&lt;p&gt;They are as secure as your RBAC and your etcd. A Secret keeps a password out of the image and the Pod spec, and that is all. Anyone who can create a Pod in the namespace can read it.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a ConfigMap and a Secret?
&lt;/h3&gt;

&lt;p&gt;Both hold key and value pairs for Pods. A Secret is meant for confidential data: it is only sent to nodes that need it, it is kept in memory on the node, kubectl hides its values by default, and it can be encrypted at rest and locked down with RBAC separately.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the maximum size of a Kubernetes Secret?
&lt;/h3&gt;

&lt;p&gt;1MiB per Secret. The limit exists "to discourage creation of very large Secrets that could exhaust the API server and kubelet memory". A namespace can also be limited in the number of Secrets with a resource quota.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I decode a Kubernetes Secret?
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;kubectl get secret NAME -o jsonpath='{.data.KEY}' | base64 --decode&lt;/code&gt;. Keep it as 1 piped command so the encoded value does not land in your shell history.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I list the Secrets in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;kubectl get secrets&lt;/code&gt; for the current namespace, or &lt;code&gt;kubectl get secrets --all-namespaces&lt;/code&gt;. The output shows names, types and key counts, never the values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do Pods pick up a changed Secret without a restart?
&lt;/h3&gt;

&lt;p&gt;Only when the Secret is mounted as a volume without &lt;code&gt;subPath&lt;/code&gt;, and then after a delay. Environment variables keep the old value until the container restarts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I use External Secrets Operator or Sealed Secrets?
&lt;/h3&gt;

&lt;p&gt;External Secrets Operator when you have a secrets manager, which on a cloud you do. Sealed Secrets when you have none and want the encrypted value in Git next to everything else.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Recap!
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing from this guide, let it be this:&lt;/p&gt;

&lt;p&gt;A Secret separates the password from the code. Protecting it is your job.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;base64 = encoding. Anyone who can read the object can read the value&lt;/li&gt;
&lt;li&gt;Create a Pod = read the Secrets of that namespace&lt;/li&gt;
&lt;li&gt;Encryption at rest has 2 layers. Check which one your cloud gives you before you build anything&lt;/li&gt;
&lt;li&gt;A volume updates eventually. An environment variable needs a restart&lt;/li&gt;
&lt;li&gt;Git gets a pointer or an encrypted file. Never the value&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You don't NEED anyone for this. The checklist above is the whole job, and the 4 tools are all open source.&lt;/p&gt;

&lt;p&gt;If you would rather have someone who has done it look at your setup first (yes, I sell DevOps engineers), start with the &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free assessment&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Kubernetes Ingress: How It Works After ingress-nginx</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Thu, 26 Nov 2026 15:30:34 +0000</pubDate>
      <link>https://dev.to/meteorops/kubernetes-ingress-how-it-works-after-ingress-nginx-8fc</link>
      <guid>https://dev.to/meteorops/kubernetes-ingress-how-it-works-after-ingress-nginx-8fc</guid>
      <description>&lt;p&gt;Kubernetes Ingress still works on every cluster, but the controller that about half of cloud native environments ran it on (the Kubernetes committees' figure) got its last release in March 2026:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Ingress = routing rules.&lt;/strong&gt; An API object that maps a host and a path to a Service, for HTTP and HTTPS only&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A controller does the work.&lt;/strong&gt; The Kubernetes docs: "Only creating an Ingress resource has no effect"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The API is frozen, and it stays.&lt;/strong&gt; No new features, and "no plans to remove Ingress from Kubernetes"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ingress-nginx is retired.&lt;/strong&gt; Last release on March 19, 2026, repository archived on March 24, 2026&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New work goes to Gateway API.&lt;/strong&gt; That is the Kubernetes project's own recommendation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What to do, by where you are today:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Your situation&lt;/th&gt;
&lt;th&gt;What I would do&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;New cluster, nothing exposed yet&lt;/td&gt;
&lt;td&gt;Start on Gateway API with your cloud's controller&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ingress objects on a maintained controller (AWS, Traefik, F5 NGINX, HAProxy, Cilium)&lt;/td&gt;
&lt;td&gt;Keep them. Write new routes as HTTPRoutes when the controller supports both&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ingress objects on ingress-nginx&lt;/td&gt;
&lt;td&gt;Migrate now. It has had no patches for 8 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AKS with the managed NGINX add-on&lt;/td&gt;
&lt;td&gt;Migrate this month. Microsoft's support ends in November 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GKE Ingress&lt;/td&gt;
&lt;td&gt;Plan the move to GKE Gateway. Google put GKE Ingress in maintenance mode&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The object itself, in its smallest valid form (from the Kubernetes docs):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
spec:
  ingressClassName: nginx-example
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the command from the retirement announcement, to check whether a cluster runs ingress-nginx (run it with cluster administrator permissions):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods --all-namespaces --selector app.kubernetes.io/name=ingress-nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every version, date and quote in this guide comes from the Kubernetes documentation and blog, the Gateway API site, the projects' own repositories and the AWS, Google and Microsoft docs, as read on November 24, 2026.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Still running ingress-nginx in production?&lt;/strong&gt; In a &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free assessment&lt;/a&gt;, a senior engineer reviews your CI/CD, infra, Kubernetes, cloud cost and on-call setup, the ingress layer included.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your situation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You are new to Ingress:&lt;/strong&gt; start at &lt;a href="https://meteorops.com/blog/kubernetes-ingress#an-ingress-is-a-list-of-rules-and-a-controller-does-the-work" rel="noopener noreferrer"&gt;an Ingress is a list of rules&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A path does not match:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-ingress#pathtype-decides-which-requests-match" rel="noopener noreferrer"&gt;pathType decides which requests match&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You run ingress-nginx:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-ingress#ingress-nginx-is-retired-the-timeline" rel="noopener noreferrer"&gt;the timeline&lt;/a&gt;, then &lt;a href="https://meteorops.com/blog/kubernetes-ingress#migrate-off-ingress-nginx-in-8-steps" rel="noopener noreferrer"&gt;the 8 steps&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You are choosing a controller:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-ingress#what-to-run-in-place-of-ingress-nginx" rel="noopener noreferrer"&gt;what to run in its place&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An Ingress returns 404 or 503:&lt;/strong&gt; go to &lt;a href="https://meteorops.com/blog/kubernetes-ingress#fix-an-ingress-that-does-not-route" rel="noopener noreferrer"&gt;fix an Ingress that does not route&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  An Ingress is a list of rules, and a controller does the work
&lt;/h2&gt;

&lt;p&gt;A Service of type ClusterIP is only reachable inside the cluster.&lt;/p&gt;

&lt;p&gt;An Ingress is the object that says which outside requests reach which Service.&lt;/p&gt;

&lt;p&gt;In the docs' words: an Ingress "exposes HTTP and HTTPS routes from outside the cluster to services within the cluster".&lt;/p&gt;

&lt;p&gt;The object stores rules. It moves no traffic.&lt;/p&gt;

&lt;p&gt;An Ingress controller reads the rules and configures a proxy or a cloud load balancer to follow them.&lt;/p&gt;

&lt;p&gt;What happens to one request:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A user opens shop.example.com/api&lt;/li&gt;
&lt;li&gt;→ DNS points to the load balancer in front of the controller&lt;/li&gt;
&lt;li&gt;→ The controller compares the host and the path to every Ingress rule it owns&lt;/li&gt;
&lt;li&gt;→ The matching rule names a Service and a port&lt;/li&gt;
&lt;li&gt;→ The request goes to a Pod behind that Service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1jznagmu0u6msxi46fae.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1jznagmu0u6msxi46fae.webp" alt="How a request reaches a Pod through a Kubernetes Ingress: user, DNS, load balancer, Ingress controller, Service, Pods. The Ingress holds the rules and the Ingress controller reads them" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The Ingress is the rules. The controller is the thing that routes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;An Ingress with no controller does NOTHING. kubectl accepts it, and then: no error, no event, no address.&lt;/p&gt;

&lt;p&gt;Ingress next to the Service types, in the docs' own words:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Object&lt;/th&gt;
&lt;th&gt;What it exposes&lt;/th&gt;
&lt;th&gt;Use it for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Service, ClusterIP&lt;/td&gt;
&lt;td&gt;"a cluster-internal IP", the default&lt;/td&gt;
&lt;td&gt;Everything that sits behind an Ingress or a Gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service, NodePort&lt;/td&gt;
&lt;td&gt;"each Node's IP at a static port", 30000 to 32767 by default&lt;/td&gt;
&lt;td&gt;The plumbing under a load balancer, rarely more&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Service, LoadBalancer&lt;/td&gt;
&lt;td&gt;1 Service through "an external load balancer"&lt;/td&gt;
&lt;td&gt;TCP or UDP, or a single public Service&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ingress&lt;/td&gt;
&lt;td&gt;Many Services "behind a single listener", HTTP and HTTPS only&lt;/td&gt;
&lt;td&gt;Websites and APIs that share 1 entry point&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The reason Ingress exists is in 1 line of the docs: "An Ingress allows you to keep the number of load balancers down to a minimum."&lt;/p&gt;

&lt;p&gt;20 Services with 20 load balancers = 20 bills and 20 DNS records. 20 Services behind 1 Ingress = 1.&lt;/p&gt;
&lt;h2&gt;
  
  
  Read an Ingress manifest field by field
&lt;/h2&gt;

&lt;p&gt;A realistic Ingress: 1 host, TLS, 2 paths to 2 Services.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: shop
  namespace: shop
spec:
  ingressClassName: public
  tls:
  - hosts:
    - shop.example.com
    secretName: shop-tls
  rules:
  - host: shop.example.com
    http:
      paths:
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: api
            port:
              number: 8080
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web
            port:
              number: 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;The rule to remember&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ingressClassName&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Names the IngressClass, which names the controller&lt;/td&gt;
&lt;td&gt;Always set it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;rules[].host&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The hostname to match. Optional&lt;/td&gt;
&lt;td&gt;No host = the rule applies to all inbound HTTP traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;paths[].path&lt;/code&gt; and &lt;code&gt;pathType&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The path to match and how to match it&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pathType&lt;/code&gt; is required. Without it the object fails validation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;backend.service&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The Service name and port that gets the request&lt;/td&gt;
&lt;td&gt;"Both the host and path must match" before traffic is sent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Hosts and the Secret that holds the certificate&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;tls.hosts&lt;/code&gt; has to match &lt;code&gt;rules.host&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;defaultBackend&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Where requests go when no rule matches&lt;/td&gt;
&lt;td&gt;Usually set on the controller. Without it, the controller decides&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Everything else you have seen on an Ingress (rewrites, rate limits, CORS, canary weights, timeouts) is an annotation.&lt;/p&gt;

&lt;p&gt;Annotations belong to the controller. Change the controller and they stop meaning anything.&lt;/p&gt;

&lt;p&gt;Annotation = a feature you rent from 1 controller.&lt;/p&gt;

&lt;p&gt;The docs admit the gap: "Ideally, all Ingress controllers should fit the reference specification. In reality, the various Ingress controllers operate slightly differently."&lt;/p&gt;

&lt;h2&gt;
  
  
  pathType decides which requests match
&lt;/h2&gt;

&lt;p&gt;There are 3 path types, and the difference between them is where most routing bugs live.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exact:&lt;/strong&gt; "Matches the URL path exactly and with case sensitivity"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prefix:&lt;/strong&gt; matches "a URL path prefix split by /", one path element at a time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ImplementationSpecific:&lt;/strong&gt; "matching is up to the IngressClass". Each controller picks its own behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rows from the official examples table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;pathType&lt;/th&gt;
&lt;th&gt;Path in the rule&lt;/th&gt;
&lt;th&gt;Request path&lt;/th&gt;
&lt;th&gt;Match&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Exact&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/foo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/foo/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exact&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/foo/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/foo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prefix&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/foo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;/foo&lt;/code&gt;, &lt;code&gt;/foo/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prefix&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/aaa/bbb&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/aaa/bbb/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Yes, matches trailing slash&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prefix&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/aaa/bbb&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/aaa/bbbxyz&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No, does not match string prefix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prefix&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/aaa&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/ccc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No, uses default backend&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mixed&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;/foo&lt;/code&gt; (Prefix), &lt;code&gt;/foo&lt;/code&gt; (Exact)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/foo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Yes, prefers Exact&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;3 rules cover the table:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Exact cares about the trailing slash.&lt;/strong&gt; Prefix ignores it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prefix matches whole elements.&lt;/strong&gt; &lt;code&gt;/foo/bar&lt;/code&gt; matches &lt;code&gt;/foo/bar/baz&lt;/code&gt; and does not match &lt;code&gt;/foo/barbaz&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The longest matching path wins.&lt;/strong&gt; On a tie, Exact beats Prefix&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F04lj2b7tlt48o4azpruv.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F04lj2b7tlt48o4azpruv.webp" alt="Kubernetes Ingress pathType matching: Exact /foo matches /foo and not /foo/. Prefix /foo/bar matches /foo/bar/ and /foo/bar/baz and not /foo/barbaz. Longest path wins, on a tie Exact beats Prefix" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Exact and Prefix on the same paths.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hosts have 1 rule of their own: a wildcard covers exactly 1 DNS label.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;*.foo.com&lt;/code&gt; matches &lt;code&gt;bar.foo.com&lt;/code&gt;. It does not match &lt;code&gt;baz.bar.foo.com&lt;/code&gt;, and it does not match &lt;code&gt;foo.com&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My default: Prefix for applications, Exact for single endpoints such as a health check or a webhook, and ImplementationSpecific never.&lt;/p&gt;

&lt;p&gt;Why never? Because it is the 1 value that changes meaning on the day you change controllers. Cilium, for example, documents it as a regex.&lt;/p&gt;
&lt;h2&gt;
  
  
  IngressClass picks the controller
&lt;/h2&gt;

&lt;p&gt;A cluster can run several Ingress controllers. IngressClass tells each one which Ingresses are its own.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: public
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"
spec:
  controller: example.com/ingress-controller
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;controller&lt;/code&gt; string comes from your controller's docs. On EKS Auto Mode, for example, it is &lt;code&gt;eks.amazonaws.com/alb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;List what a cluster has:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get ingressclass
kubectl get ingress --all-namespaces
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4 facts that save an afternoon:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The default class:&lt;/strong&gt; the &lt;code&gt;ingressclass.kubernetes.io/is-default-class&lt;/code&gt; annotation set to &lt;code&gt;true&lt;/code&gt; assigns that class to new Ingresses that name none&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2 defaults:&lt;/strong&gt; with more than 1 default class, the admission controller blocks every new Ingress that has no &lt;code&gt;ingressClassName&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The old annotation:&lt;/strong&gt; &lt;code&gt;kubernetes.io/ingress.class&lt;/code&gt; is deprecated since v1.18 and "was never formally defined". The AWS docs still show it as &lt;code&gt;kubernetes.io/ingress.class: alb&lt;/code&gt;, and many charts still ship it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The scope:&lt;/strong&gt; IngressClass is cluster-scoped. One name, one meaning, in every namespace&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Migration uses this directly: 2 controllers, 2 classes.&lt;/p&gt;

&lt;p&gt;Copy each Ingress under a new name with the new class, test it on the new controller's IP, switch DNS, then delete the old copy.&lt;/p&gt;

&lt;p&gt;Do not edit &lt;code&gt;ingressClassName&lt;/code&gt; on the live object: the old controller drops the host the moment you do.&lt;/p&gt;

&lt;h2&gt;
  
  
  TLS on an Ingress is port 443 and 1 Secret
&lt;/h2&gt;

&lt;p&gt;The TLS part of the API is short, and so is its list of limits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1 port:&lt;/strong&gt; "The Ingress resource only supports a single TLS port, 443"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Termination at the edge:&lt;/strong&gt; the API "assumes TLS termination at the ingress point (traffic to the Service and its Pods is in plaintext)"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Secret:&lt;/strong&gt; "must contain keys named tls.crt and tls.key"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The namespace:&lt;/strong&gt; &lt;code&gt;secretName&lt;/code&gt; is a bare name with no namespace field, so the Secret sits in the namespace of the Ingress&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Several hosts:&lt;/strong&gt; multiplexed on the same port by Server Name Indication (SNI), "provided the Ingress controller supports SNI"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No TLS on the catch-all rule:&lt;/strong&gt; "hosts in the tls section need to explicitly match the host in the rules section"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create the Secret from a certificate and a key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create secret tls shop-tls --cert=tls.crt --key=tls.key --namespace shop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In practice cert-manager creates and renews that Secret for you.&lt;/p&gt;

&lt;p&gt;On a cloud load balancer the certificate usually lives in the cloud (AWS Certificate Manager on an ALB) and the Secret is not used.&lt;/p&gt;

&lt;p&gt;cert-manager (v1.21.3 today) watches Ingresses through annotations. Its Gateway support is still marked beta, since version 1.15.&lt;/p&gt;

&lt;p&gt;Redirects from HTTP to HTTPS, TLS versions, ciphers, mutual TLS, passthrough: all annotations, all different per controller.&lt;/p&gt;

&lt;p&gt;The docs say so in 1 line: "There is a gap between TLS features supported by various ingress controllers."&lt;/p&gt;

&lt;h2&gt;
  
  
  The Ingress API is frozen, not deprecated
&lt;/h2&gt;

&lt;p&gt;These 2 words get mixed up in every thread about Ingress, so here is the official text.&lt;/p&gt;

&lt;p&gt;From the Ingress page of the Kubernetes docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"The Kubernetes project recommends using Gateway instead of Ingress. The Ingress API has been frozen."&lt;/li&gt;
&lt;li&gt;"The Ingress API is no longer being developed, and will have no further changes or updates made to it."&lt;/li&gt;
&lt;li&gt;"The Kubernetes project has no plans to remove Ingress from Kubernetes."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From the Gateway API FAQ, under "Will Gateway API replace the Ingress API?":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"No. The Ingress API is GA since Kubernetes 1.19. There are no plans to deprecate this API and we expect most Ingress controllers to support it indefinitely."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Frozen = it will never do more than it does today.&lt;/p&gt;

&lt;p&gt;Deprecated = officially marked for removal, with a warning every time you use it. Ingress carries no such mark.&lt;/p&gt;

&lt;p&gt;(Frozen is one of the nicer things that can happen to an API you depend on.)&lt;/p&gt;

&lt;p&gt;So your Ingress manifests are safe. The question is only what runs them.&lt;/p&gt;

&lt;p&gt;One old version did go away: &lt;code&gt;networking.k8s.io/v1beta1&lt;/code&gt; Ingress has not been served since Kubernetes v1.22.&lt;/p&gt;

&lt;p&gt;A tutorial that shows &lt;code&gt;serviceName:&lt;/code&gt; and &lt;code&gt;servicePort:&lt;/code&gt; under &lt;code&gt;backend&lt;/code&gt; is written for that removed version. Its manifest fails on every supported cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  ingress-nginx is retired: the timeline
&lt;/h2&gt;

&lt;p&gt;ingress-nginx was the community controller, the one most tutorials install.&lt;/p&gt;

&lt;p&gt;The number the Kubernetes Steering and Security Response Committees cite: "about 50% of cloud native environments currently rely on this tool" (internal Datadog research, January 2026).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;What happened&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;March 24, 2025&lt;/td&gt;
&lt;td&gt;CVE-2025-1974 disclosed, rated 9.8 CVSS. Fixed in v1.12.1 and v1.11.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;November 11, 2025&lt;/td&gt;
&lt;td&gt;Retirement announced. "Best-effort maintenance will continue until March 2026"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;January 29, 2026&lt;/td&gt;
&lt;td&gt;Statement from the Steering and Security Response Committees: staying "leaves you and your users vulnerable to attack"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;February 27, 2026&lt;/td&gt;
&lt;td&gt;The Kubernetes blog lists 5 surprising ingress-nginx behaviors to know before migrating&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;March 19, 2026&lt;/td&gt;
&lt;td&gt;Last releases: controller v1.15.1, v1.14.5 and v1.13.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;March 20, 2026&lt;/td&gt;
&lt;td&gt;ingress2gateway 1.0, the conversion tool, is released&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;March 24, 2026&lt;/td&gt;
&lt;td&gt;The repository is archived and read-only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;June 30, 2026&lt;/td&gt;
&lt;td&gt;InGate, the planned successor, is archived too&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;November 2026&lt;/td&gt;
&lt;td&gt;Microsoft ends support for the AKS managed NGINX add-on&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy31nbe5n8lbk851md1u7.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy31nbe5n8lbk851md1u7.webp" alt="ingress-nginx retirement timeline: November 11, 2025 retirement announced, January 29, 2026 committees' statement, March 19, 2026 last release v1.15.1, March 24, 2026 repository archived, November 2026 AKS add-on support ends" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;From the announcement to the archive in 4 months.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  What "retired" means
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No fixes:&lt;/strong&gt; "no further releases, no bugfixes, and no updates to resolve any security vulnerabilities that may be discovered"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nothing breaks:&lt;/strong&gt; "Existing deployments of Ingress NGINX will continue to function and installation artifacts will remain available"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No comeback:&lt;/strong&gt; "it is no longer reasonable or even possible to continue maintaining the tool even if resources did materialize"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The second point is the dangerous one.&lt;/p&gt;

&lt;p&gt;The committees wrote it themselves: "Existing deployments will continue to work, so unless you proactively check, you may not know you are affected until you are compromised."&lt;/p&gt;
&lt;h3&gt;
  
  
  Why it matters for this controller in particular
&lt;/h3&gt;

&lt;p&gt;CVE-2025-1974 is the example of what an ingress-nginx bug looks like.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"anything on the Pod network has a good chance of taking over your Kubernetes cluster, with no credentials or administrative access required"&lt;/li&gt;
&lt;li&gt;"By default, ingress-nginx has access to all Secrets cluster-wide"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That one shipped with its patch on the day it was disclosed, because maintainers existed.&lt;/p&gt;

&lt;p&gt;The next one has nobody to patch it.&lt;/p&gt;

&lt;p&gt;There is a second clock. The last release, v1.15.1, lists Kubernetes 1.31 to 1.35 as its supported versions. Kubernetes is at v1.37, with v1.38 in beta.&lt;/p&gt;
&lt;h3&gt;
  
  
  ingress-nginx and NGINX Ingress Controller are 2 projects
&lt;/h3&gt;

&lt;p&gt;The names are a trap, and the Kubernetes blog spells it out: "Ingress-NGINX and NGINX Ingress are two separate Ingress controllers."&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;ingress-nginx&lt;/th&gt;
&lt;th&gt;NGINX Ingress Controller&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Repository&lt;/td&gt;
&lt;td&gt;kubernetes/ingress-nginx&lt;/td&gt;
&lt;td&gt;nginx/kubernetes-ingress&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maintained by&lt;/td&gt;
&lt;td&gt;The Kubernetes community&lt;/td&gt;
&lt;td&gt;F5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Status&lt;/td&gt;
&lt;td&gt;Retired, archived&lt;/td&gt;
&lt;td&gt;Maintained, v5.8.1 in November 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Annotation prefix&lt;/td&gt;
&lt;td&gt;&lt;code&gt;nginx.ingress.kubernetes.io/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;nginx.org/&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;"Both use NGINX as the dataplane, but are otherwise unrelated."&lt;/p&gt;

&lt;p&gt;So moving from one to the other is a migration, with its own guide from F5, and the annotations do not carry over as they are.&lt;/p&gt;
&lt;h2&gt;
  
  
  What to run in place of ingress-nginx
&lt;/h2&gt;

&lt;p&gt;The official recommendation has 2 branches: "begin migration to Gateway API or another Ingress controller immediately."&lt;/p&gt;

&lt;p&gt;And 1 warning: "None of the available alternatives are direct drop-in replacements."&lt;/p&gt;
&lt;h3&gt;
  
  
  On a managed cloud, start with the cloud's controller
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cloud&lt;/th&gt;
&lt;th&gt;Ingress today&lt;/th&gt;
&lt;th&gt;Gateway API today&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS EKS&lt;/td&gt;
&lt;td&gt;AWS Load Balancer Controller creates an Application Load Balancer for an Ingress (one each, unless you group them with IngressGroups). EKS Auto Mode has it built in&lt;/td&gt;
&lt;td&gt;The same controller creates an ALB for a Gateway from v2.14.0. Current release v3.6.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google GKE&lt;/td&gt;
&lt;td&gt;"GKE Ingress is in maintenance mode"&lt;/td&gt;
&lt;td&gt;"We recommend that you use GKE Gateway API." Both GKE Gateway controllers are generally available&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure AKS&lt;/td&gt;
&lt;td&gt;The application routing add-on is managed ingress-nginx, supported "through November 2026" for critical security patches only&lt;/td&gt;
&lt;td&gt;The add-on's Gateway API mode (built on Istio), or Application Gateway for Containers&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you run AKS with the managed NGINX add-on, the date in that table is this month.&lt;/p&gt;

&lt;p&gt;Microsoft's wording: "you must migrate to the application routing Gateway API implementation, or another supported implementation, by November 2026."&lt;/p&gt;

&lt;p&gt;(Picking the cluster itself? See &lt;a href="https://meteorops.com/blog/how-to-choose-kubernetes-hosting-for-production" rel="noopener noreferrer"&gt;how to choose Kubernetes hosting for production&lt;/a&gt; and &lt;a href="https://meteorops.com/blog/ecs-vs-eks" rel="noopener noreferrer"&gt;ECS vs EKS&lt;/a&gt;.)&lt;/p&gt;
&lt;h3&gt;
  
  
  In-cluster controllers that are maintained
&lt;/h3&gt;

&lt;p&gt;Versions are the latest releases on November 24, 2026.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Controller&lt;/th&gt;
&lt;th&gt;Ingress&lt;/th&gt;
&lt;th&gt;Gateway API&lt;/th&gt;
&lt;th&gt;Worth knowing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Traefik v3.8.0&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes, Standard v1.7.0&lt;/td&gt;
&lt;td&gt;Has a provider that reads "many of the ingress-nginx annotations" on existing Ingresses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F5 NGINX Ingress Controller v5.8.1&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (see NGINX Gateway Fabric)&lt;/td&gt;
&lt;td&gt;Same proxy, different annotations. F5 publishes a migration guide&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HAProxy Kubernetes Ingress Controller v3.4.1&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (see HAProxy Unified Gateway)&lt;/td&gt;
&lt;td&gt;Its docs: version 3.4 and newer "don't support Gateway API"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kong Ingress Controller v3.5.15&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;"All new development of Kong products on Kubernetes will land in the Kong Operator"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cilium 1.20.5&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No separate controller to install when Cilium is already your network plugin: you switch it on in Cilium (needs kube-proxy replacement)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contour v1.33.8&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Envoy underneath. No minor release since v1.33.0 in September 2025, patch releases only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Istio 1.32.0&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Can run "purely as Gateway API controller with no other service mesh features" (Kubernetes blog)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Envoy Gateway v1.10.0&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Gateway API only, by design&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NGINX Gateway Fabric v2.9.1&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;F5's Gateway API controller, with NGINX as the data plane&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kgateway v2.5.2&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;A Gateway API control plane for Envoy&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  How I would pick
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;You are on EKS, GKE or AKS and the cloud load balancer does what you need:&lt;/strong&gt; use the cloud's controller. One component fewer to patch&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You need to be off ingress-nginx this week:&lt;/strong&gt; a controller that keeps your Ingress objects (Traefik's ingress-nginx provider, or F5 NGINX with its migration guide). Test every annotation, because "many" is the vendor's word&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You have a month:&lt;/strong&gt; go to Gateway API directly, with the controller your platform already runs (Cilium, Istio) or a Gateway-only one (Envoy Gateway, NGINX Gateway Fabric)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You run multi-tenant clusters:&lt;/strong&gt; Gateway API, no debate. ingress-nginx's own FAQ said "Do not use in multi-tenant Kubernetes production installations"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Option 2 buys time. Option 3 is where everybody ends up.&lt;/p&gt;
&lt;h2&gt;
  
  
  Gateway API is Ingress split into 3 objects
&lt;/h2&gt;

&lt;p&gt;Gateway API is "the successor to the Ingress API", in the words of both kubernetes.io and its own site.&lt;/p&gt;

&lt;p&gt;The idea: the one Ingress object becomes 3, and each has an owner.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Object&lt;/th&gt;
&lt;th&gt;What it holds&lt;/th&gt;
&lt;th&gt;Who owns it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;GatewayClass&lt;/td&gt;
&lt;td&gt;Which controller, with which settings&lt;/td&gt;
&lt;td&gt;The infrastructure provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gateway&lt;/td&gt;
&lt;td&gt;Listeners: ports, protocols, hostnames, certificates&lt;/td&gt;
&lt;td&gt;The cluster operator&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTPRoute&lt;/td&gt;
&lt;td&gt;Hosts, paths, headers, weights, backends&lt;/td&gt;
&lt;td&gt;The application developer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fatzzaqmw2pt001x62ikq.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fatzzaqmw2pt001x62ikq.webp" alt="Gateway API splits the Ingress object into 3: GatewayClass for the infrastructure provider, Gateway for the cluster operator, HTTPRoute for the application developer" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;One object with one owner becomes 3 objects with 3 owners.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The HTTPS side of the shop Ingress from above, as a Gateway and an HTTPRoute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: public
  namespace: infra
spec:
  gatewayClassName: example
  listeners:
  - name: https
    protocol: HTTPS
    port: 443
    hostname: shop.example.com
    tls:
      mode: Terminate
      certificateRefs:
      - name: shop-tls
    allowedRoutes:
      namespaces:
        from: All
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: shop
  namespace: shop
spec:
  parentRefs:
  - name: public
    namespace: infra
  hostnames:
  - shop.example.com
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /api
    backendRefs:
    - name: api
      port: 8080
  - matches:
    - path:
        type: PathPrefix
        value: /
    backendRefs:
    - name: web
      port: 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 things moved.&lt;/p&gt;

&lt;p&gt;The certificate now sits with the Gateway, in the platform team's namespace. The application team never touches it.&lt;/p&gt;

&lt;p&gt;So the &lt;code&gt;shop-tls&lt;/code&gt; Secret has to exist in &lt;code&gt;infra&lt;/code&gt; now, or be shared with a ReferenceGrant.&lt;/p&gt;

&lt;p&gt;And the entry point is explicit. An Ingress has "two implicit entry points", HTTP and HTTPS. A Gateway lists its listeners.&lt;/p&gt;

&lt;p&gt;This Gateway listens on 443 only. Port 80 is a second listener you add yourself, and the redirect to HTTPS is an HTTPRoute with a &lt;code&gt;RequestRedirect&lt;/code&gt; filter.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;from: All&lt;/code&gt; is the shortest form. In production use &lt;code&gt;from: Selector&lt;/code&gt; with a namespace label, so that only the namespaces you choose can attach routes.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it adds over Ingress
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Need&lt;/th&gt;
&lt;th&gt;Ingress&lt;/th&gt;
&lt;th&gt;Gateway API&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Route on host and path&lt;/td&gt;
&lt;td&gt;In the API&lt;/td&gt;
&lt;td&gt;In the API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Route on header, query parameter or method&lt;/td&gt;
&lt;td&gt;Annotation, if the controller has one&lt;/td&gt;
&lt;td&gt;In HTTPRoute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Split traffic by weight&lt;/td&gt;
&lt;td&gt;Annotation, if the controller has one&lt;/td&gt;
&lt;td&gt;In HTTPRoute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redirects, including HTTP to HTTPS&lt;/td&gt;
&lt;td&gt;Annotation&lt;/td&gt;
&lt;td&gt;In HTTPRoute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retries&lt;/td&gt;
&lt;td&gt;Annotation&lt;/td&gt;
&lt;td&gt;In HTTPRoute, Standard since v1.7.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;gRPC, TLS passthrough, TCP, UDP&lt;/td&gt;
&lt;td&gt;Outside the API&lt;/td&gt;
&lt;td&gt;GRPCRoute, TLSRoute, TCPRoute, UDPRoute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A route to a Service in another namespace&lt;/td&gt;
&lt;td&gt;Outside the API&lt;/td&gt;
&lt;td&gt;Allowed with a ReferenceGrant from the owner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Separate permissions for platform and app teams&lt;/td&gt;
&lt;td&gt;One object for both&lt;/td&gt;
&lt;td&gt;Gateway and HTTPRoute, with &lt;code&gt;allowedRoutes&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A canary in Gateway API is 4 extra lines in the route, with no annotation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    backendRefs:
    - name: web
      port: 80
      weight: 90
    - name: web-v2
      port: 80
      weight: 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the API does not mean in your controller. Query parameter and method matching and retries are Extended features: check your controller's conformance report.&lt;/p&gt;

&lt;p&gt;(When to use a canary at all is in &lt;a href="https://meteorops.com/blog/deployment-strategies" rel="noopener noreferrer"&gt;deployment strategies: 6 types and how to pick one&lt;/a&gt;.)&lt;/p&gt;

&lt;h3&gt;
  
  
  What is stable today
&lt;/h3&gt;

&lt;p&gt;The current release is Gateway API v1.7.0, published on October 29, 2026.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GatewayClass, Gateway, HTTPRoute:&lt;/strong&gt; stable, in the Standard channel since v0.5.0&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GRPCRoute:&lt;/strong&gt; Standard since v1.1.0&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TLSRoute and ListenerSet:&lt;/strong&gt; Standard since v1.5.0 (February 27, 2026)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TCPRoute and UDPRoute:&lt;/strong&gt; Standard since v1.6.0 (June 2026)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTPRoute retries:&lt;/strong&gt; Standard since v1.7.0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2 things to know before you start:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gateway API "does not include the Ingress kind". Existing Ingresses need "a one-time conversion"&lt;/li&gt;
&lt;li&gt;Annotations are gone on purpose: using them as an extension point "is strongly discouraged"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the Standard channel. The project recommends it "by default", and a controller's docs tell you which version it supports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migrate off ingress-nginx in 8 steps
&lt;/h2&gt;

&lt;p&gt;The steps are the same whether the target is another Ingress controller or Gateway API.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Find it.&lt;/strong&gt; Run the command from the top of this guide on every cluster, then &lt;code&gt;kubectl get ingress --all-namespaces&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;List the annotations in use.&lt;/strong&gt; Every &lt;code&gt;nginx.ingress.kubernetes.io/&lt;/code&gt; annotation is a feature the new controller has to provide. Count the "snippets" first: arbitrary NGINX configuration has no equivalent anywhere&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pick the target&lt;/strong&gt; with the 4 rules above&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Install the new controller next to the old one.&lt;/strong&gt; The Gateway API guide: "They will each get a different external IP address, allowing you to test and validate your new configuration in isolation without affecting production traffic"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Convert.&lt;/strong&gt; For Gateway API, ingress2gateway reads your Ingresses and prints Gateways and HTTPRoutes. For another Ingress controller, copy each Ingress with the new class and the new controller's annotations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test against the new IP&lt;/strong&gt; with the real hostnames (&lt;code&gt;curl --resolve&lt;/code&gt;), path by path, including the paths with a trailing slash&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switch DNS&lt;/strong&gt; per hostname, with a low TTL, least important hostname first&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete the ingress-nginx release&lt;/strong&gt; when its access log has been quiet for a week. Keeping it "just in case" keeps the risk&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What ingress2gateway does
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ingress2gateway print --providers=ingress-nginx --all-namespaces &amp;gt; gwapi.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without &lt;code&gt;--all-namespaces&lt;/code&gt; it reads the current namespace only.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Version:&lt;/strong&gt; v1.2.0 (July 7, 2026). Version 1.0 came out on March 20, 2026&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Annotations:&lt;/strong&gt; before 1.0 it translated 3 ingress-nginx annotations. Since 1.0, "over 30 common annotations (CORS, backend TLS, regex matching, path rewrite, etc.)"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inputs:&lt;/strong&gt; apisix, cilium, ingress-nginx, istio, gce, kong, nginx, openapi, traefik&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Honesty:&lt;/strong&gt; it warns "about untranslatable configuration", and its authors call it "a migration assistant, not a one-shot replacement"&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The 5 behaviors that break a "correct" translation
&lt;/h3&gt;

&lt;p&gt;The Kubernetes blog published these in February 2026. Each one is something ingress-nginx did that the Ingress API never promised.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;"Regex matches are prefix-based and case insensitive"&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;use-regex&lt;/code&gt; annotation "applies to all paths of a host across all (Ingress-NGINX) Ingresses"&lt;/li&gt;
&lt;li&gt;"Rewrite target implies regex"&lt;/li&gt;
&lt;li&gt;"Requests missing a trailing slash are redirected to the same path with a trailing slash"&lt;/li&gt;
&lt;li&gt;"Ingress-NGINX normalizes URLs"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Their summary is the reason step 6 exists: "a seemingly correct translation can still cause outages if it does not consider Ingress-NGINX's quirks."&lt;/p&gt;

&lt;p&gt;Your application may depend on any of the 5 without anybody knowing. Test the paths, do not read the YAML.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix an Ingress that does not route
&lt;/h2&gt;

&lt;p&gt;Start with 2 commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get ingress --all-namespaces
kubectl describe ingress shop --namespace shop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The describe output shows the address, the default backend, every rule with the Pod IPs behind its Service, the annotations and the events.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Usual cause&lt;/th&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ADDRESS stays empty&lt;/td&gt;
&lt;td&gt;No controller owns the Ingress, or the controller cannot get a load balancer. A minute or two of `` is normal, 10 minutes is not&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;ingressClassName&lt;/code&gt; against &lt;code&gt;kubectl get ingressclass&lt;/code&gt;, then the events, the controller's Pods and its logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;404 from the controller&lt;/td&gt;
&lt;td&gt;No rule matched, so the controller's default backend or built-in 404 answered&lt;/td&gt;
&lt;td&gt;The Host header you send, the &lt;code&gt;pathType&lt;/code&gt;, the trailing slash&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;503&lt;/td&gt;
&lt;td&gt;Usually: the Service has no ready Pods behind it. On ingress-nginx, also its rate and connection limits&lt;/td&gt;
&lt;td&gt;The backend line in the describe output. A Service with no endpoints shows as &lt;code&gt;api:8080 ()&lt;/code&gt;. Then the Service selector and the readiness probe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Browser warns about the certificate&lt;/td&gt;
&lt;td&gt;The Secret is missing, in another namespace, or &lt;code&gt;tls.hosts&lt;/code&gt; does not match the host. ingress-nginx then serves a self-signed certificate&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl get secret&lt;/code&gt; in the namespace of the Ingress&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A new Ingress is rejected&lt;/td&gt;
&lt;td&gt;2 IngressClasses are marked default and the Ingress names none&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl get ingressclass&lt;/code&gt;, and set &lt;code&gt;ingressClassName&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Works on one controller, breaks on the next&lt;/td&gt;
&lt;td&gt;An annotation, or &lt;code&gt;ImplementationSpecific&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The annotation list from step 2 of the migration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The 503 row has a Gateway API twin, written into the spec: a route to a Service with no ready endpoints should return 503, and an invalid backend reference returns 500.&lt;/p&gt;

&lt;p&gt;(The commands for the next level down, endpoints, logs and events, are in the &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet" rel="noopener noreferrer"&gt;kubectl cheat sheet&lt;/a&gt;. Readiness itself is in the &lt;a href="https://meteorops.com/blog/how-to-configure-kubernetes-liveness-probes-without-causing-restart-loops" rel="noopener noreferrer"&gt;liveness probes guide&lt;/a&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  The Ingress checklist
&lt;/h2&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Know which controller serves every Ingress, and that it still gets releases&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;ingressClassName&lt;/code&gt; on every Ingress&lt;/li&gt;
&lt;li&gt;Have exactly 1 default IngressClass, or none&lt;/li&gt;
&lt;li&gt;Write &lt;code&gt;pathType: Prefix&lt;/code&gt; or &lt;code&gt;Exact&lt;/code&gt;, never &lt;code&gt;ImplementationSpecific&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Give every rule a &lt;code&gt;host&lt;/code&gt;, and match it in &lt;code&gt;tls.hosts&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Keep the TLS Secret in the namespace of the Ingress, renewed by cert-manager&lt;/li&gt;
&lt;li&gt;Keep a list of the annotations you depend on, per controller&lt;/li&gt;
&lt;li&gt;Write new routes as HTTPRoutes when your controller supports both APIs&lt;/li&gt;
&lt;li&gt;Run 0 retired controllers on a public IP&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Kubernetes Ingress FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is Kubernetes Ingress deprecated?
&lt;/h3&gt;

&lt;p&gt;No. The Ingress API is frozen: it gets no new features, it is still generally available, and the Kubernetes project says it has "no plans to remove Ingress from Kubernetes". What was retired in March 2026 is ingress-nginx, one controller for that API.&lt;/p&gt;

&lt;h3&gt;
  
  
  What replaces ingress-nginx?
&lt;/h3&gt;

&lt;p&gt;Nothing replaces it one for one. The official recommendation is Gateway API or another Ingress controller: on a managed cloud that is the cloud's own controller, and in the cluster the maintained options include Traefik, F5 NGINX Ingress Controller, HAProxy, Cilium, Istio, Envoy Gateway and NGINX Gateway Fabric.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between an Ingress and a LoadBalancer Service?
&lt;/h3&gt;

&lt;p&gt;A LoadBalancer Service exposes 1 Service through 1 external load balancer, on any TCP or UDP port. An Ingress puts many HTTP and HTTPS Services behind 1 entry point and routes by host and path.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between Ingress and Gateway API?
&lt;/h3&gt;

&lt;p&gt;Ingress is 1 object with host and path routing, and annotations for everything else. Gateway API splits the job into GatewayClass, Gateway and HTTPRoute, and puts header matching, traffic weights, redirects, retries, gRPC, TCP and UDP into the API itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is NGINX Ingress Controller the same as ingress-nginx?
&lt;/h3&gt;

&lt;p&gt;No. ingress-nginx was the Kubernetes community project and is retired. NGINX Ingress Controller is F5's product, lives in the nginx/kubernetes-ingress repository, uses &lt;code&gt;nginx.org/&lt;/code&gt; annotations and is still released.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can an Ingress route TCP or UDP traffic?
&lt;/h3&gt;

&lt;p&gt;No. The docs: "An Ingress does not expose arbitrary ports or protocols." Use a Service of type LoadBalancer, or a TCPRoute or UDPRoute in Gateway API, both stable since v1.6.0.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need an Ingress controller on EKS, GKE or AKS?
&lt;/h3&gt;

&lt;p&gt;Yes, but the cloud usually provides it. EKS has the AWS Load Balancer Controller (built into EKS Auto Mode), GKE has GKE Ingress and GKE Gateway, and AKS has the application routing add-on and Application Gateway for Containers.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between ingress and egress in Kubernetes?
&lt;/h3&gt;

&lt;p&gt;Ingress is traffic coming into the cluster or into a Pod, egress is traffic leaving it. The Ingress object only covers inbound HTTP and HTTPS. Which Pods may send or receive what is a NetworkPolicy, which has both ingress and egress rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Recap!
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing from this guide, let it be this:&lt;/p&gt;

&lt;p&gt;Your Ingress objects are fine. Check what is running them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ingress = rules. The controller = the thing that can be out of date&lt;/li&gt;
&lt;li&gt;The API is frozen and stays. ingress-nginx is retired and stays retired&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pathType&lt;/code&gt;, &lt;code&gt;ingressClassName&lt;/code&gt; and the TLS Secret's namespace explain most broken Ingresses&lt;/li&gt;
&lt;li&gt;New routes go to Gateway API. Old ones move with ingress2gateway and a second IP&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You don't NEED anyone for this. The 8 steps above are the whole job: an afternoon for a cluster with a handful of plain Ingresses, weeks for one with snippets and regex paths.&lt;/p&gt;

&lt;p&gt;If you would rather have someone who has done it look at your setup first (yes, I sell DevOps engineers), start with the &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;free assessment&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Cloud Migration Strategy: The 7 Rs, Waves, Cutover and Exit</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Wed, 25 Nov 2026 15:30:53 +0000</pubDate>
      <link>https://dev.to/meteorops/cloud-migration-strategy-the-7-rs-waves-cutover-and-exit-82m</link>
      <guid>https://dev.to/meteorops/cloud-migration-strategy-the-7-rs-waves-cutover-and-exit-82m</guid>
      <description>&lt;p&gt;A cloud migration strategy is 4 decisions, and most guides stop after the first one:&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A strategy per workload:&lt;/strong&gt; which "R" each one gets (retire, retain, rehost, relocate, repurchase, replatform, refactor)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An order:&lt;/strong&gt; which workloads move first, and how many at a time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A cutover and a way back:&lt;/strong&gt; written per workload, before the move&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An exit:&lt;/strong&gt; what it costs and how long it takes to leave the cloud you are moving to&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The short version of each, with the numbers the cloud vendors publish:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Decision&lt;/th&gt;
&lt;th&gt;My default&lt;/th&gt;
&lt;th&gt;The number to remember&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Strategy per workload&lt;/td&gt;
&lt;td&gt;Retire what nobody uses, rehost what works, replatform the database&lt;/td&gt;
&lt;td&gt;Under 5% average CPU and memory = a candidate to switch off (AWS)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rewrite during the move&lt;/td&gt;
&lt;td&gt;No. Move first, change later&lt;/td&gt;
&lt;td&gt;Rehost only what stays as it is for 2 years (Microsoft)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First workload&lt;/td&gt;
&lt;td&gt;Boring, used every day, 0 to 3 dependencies&lt;/td&gt;
&lt;td&gt;Fewer than 10 servers in each of the first 5 waves (AWS)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cutover&lt;/td&gt;
&lt;td&gt;Freeze, replicate, pause writes, switch DNS, watch&lt;/td&gt;
&lt;td&gt;24 to 48 hours of close watching after the switch (Microsoft)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rollback&lt;/td&gt;
&lt;td&gt;Triggers and a time limit written before the cutover&lt;/td&gt;
&lt;td&gt;1 maximum execution time per step, then roll back (Google)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exit&lt;/td&gt;
&lt;td&gt;Read the contract end dates before you sign&lt;/td&gt;
&lt;td&gt;2 months of notice for free egress out of AWS&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every vendor number and quote in this article comes from the AWS, Microsoft and Google Cloud documentation and price lists, Gartner's 2011 press release (archived copy), the European Commission, or the companies' own posts, as read on November 19, 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  A cloud migration strategy is one decision per workload
&lt;/h2&gt;

&lt;p&gt;You do not pick 1 strategy for the company.&lt;/p&gt;

&lt;p&gt;You pick 1 per workload, and the list of picks is the strategy.&lt;/p&gt;

&lt;p&gt;Workload = an application plus everything it needs to run: servers, database, queues, cron jobs, DNS records.&lt;/p&gt;

&lt;p&gt;Microsoft says it in 1 line: "Each workload can be Retired, Retained, Rehosted, Replatformed, Refactored, Rearchitected, Rebuilt, or Replaced."&lt;/p&gt;

&lt;p&gt;So the first deliverable of a migration is a spreadsheet: 1 row per workload, 1 column for the R, 1 for the owner, 1 for what it depends on.&lt;/p&gt;

&lt;p&gt;The rest of this guide fills that spreadsheet in, then puts the rows in order.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 7 Rs are 5 different lists
&lt;/h2&gt;

&lt;p&gt;"The 7 Rs" sounds like a standard. It is the AWS version of a list that every vendor wrote differently.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you do&lt;/th&gt;
&lt;th&gt;Gartner, 2011 (5)&lt;/th&gt;
&lt;th&gt;AWS, 2016 (6)&lt;/th&gt;
&lt;th&gt;AWS today (7)&lt;/th&gt;
&lt;th&gt;Microsoft today (8)&lt;/th&gt;
&lt;th&gt;Google Cloud today (6)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Move it as it is&lt;/td&gt;
&lt;td&gt;Rehost&lt;/td&gt;
&lt;td&gt;Rehost&lt;/td&gt;
&lt;td&gt;Rehost&lt;/td&gt;
&lt;td&gt;Rehost&lt;/td&gt;
&lt;td&gt;Rehost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Move a whole platform as it is&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Relocate&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Small changes, same architecture&lt;/td&gt;
&lt;td&gt;Refactor (run it on a platform service)&lt;/td&gt;
&lt;td&gt;Replatform&lt;/td&gt;
&lt;td&gt;Replatform&lt;/td&gt;
&lt;td&gt;Replatform&lt;/td&gt;
&lt;td&gt;Replatform&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change the code&lt;/td&gt;
&lt;td&gt;Revise&lt;/td&gt;
&lt;td&gt;Refactor / re-architect&lt;/td&gt;
&lt;td&gt;Refactor or re-architect&lt;/td&gt;
&lt;td&gt;Refactor&lt;/td&gt;
&lt;td&gt;Refactor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change the architecture&lt;/td&gt;
&lt;td&gt;Rebuild&lt;/td&gt;
&lt;td&gt;(same R)&lt;/td&gt;
&lt;td&gt;(same R)&lt;/td&gt;
&lt;td&gt;Rearchitect&lt;/td&gt;
&lt;td&gt;Re-architect&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rewrite it&lt;/td&gt;
&lt;td&gt;Rebuild&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Rebuild&lt;/td&gt;
&lt;td&gt;Rebuild&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buy SaaS (software as a service)&lt;/td&gt;
&lt;td&gt;Replace&lt;/td&gt;
&lt;td&gt;Repurchase&lt;/td&gt;
&lt;td&gt;Repurchase&lt;/td&gt;
&lt;td&gt;Replace&lt;/td&gt;
&lt;td&gt;Repurchase&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Switch it off&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Retire&lt;/td&gt;
&lt;td&gt;Retire&lt;/td&gt;
&lt;td&gt;Retire&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Leave it where it is&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Retain&lt;/td&gt;
&lt;td&gt;Retain&lt;/td&gt;
&lt;td&gt;Retain&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdkv6mf15sr7ezx9gmair.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdkv6mf15sr7ezx9gmair.webp" alt="The number of cloud migration strategies in each list: Gartner 2011 has 5, AWS 2016 has 6, AWS today has 7, Microsoft today has 8, Google Cloud today has 6" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;5 lists, 5 different counts.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;3 things to take from the table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;"Refactor" has 3 meanings.&lt;/strong&gt; Gartner in 2011: run the application on a provider's platform service. AWS: "modify its architecture by taking full advantage of cloud-native features". Microsoft: improve "the internal structure of code without adding new features"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google has no retire and no retain.&lt;/strong&gt; Its 6 types only describe workloads that move&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relocate exists only at AWS.&lt;/strong&gt; It means moving many servers at once to "a cloud version of the platform", or between accounts and Regions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rule I use: when somebody in the room says "refactor", ask which one they mean before you estimate anything.&lt;/p&gt;

&lt;p&gt;The history is also told wrong on pages that rank for this search today.&lt;/p&gt;

&lt;p&gt;One says AWS added Retire in 2016 and Retain in 2017. The AWS post from November 1, 2016 already lists both: "5. Retire" and "6. Retain". The R that came later is Relocate.&lt;/p&gt;

&lt;p&gt;Another says the "original four Rs" came from Gartner. Gartner's press release from May 16, 2011 lists 5 options: "rehost", "refactor", "revise", "rebuild" and "replace".&lt;/p&gt;

&lt;p&gt;(Even an AWS documentation page credits Gartner with "the 7 Rs" in 2019. Nobody remembers who wrote the list, which tells you how much to worry about the list.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Pick the R for each workload with 5 questions
&lt;/h2&gt;

&lt;p&gt;Ask them in this order. Stop at the first yes, with 1 exception: a yes to question 4 covers only that part, so ask question 5 for the rest.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Is nobody using it?&lt;/strong&gt; Retire it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Does something tie it to where it is?&lt;/strong&gt; Retain it, and write down the date you look again&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Does a SaaS product do the same job with little customization?&lt;/strong&gt; Repurchase it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Can a managed service take over a part of it with no code change?&lt;/strong&gt; Replatform that part (the database is the usual one)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Will the rest stay as it is for the next 2 years?&lt;/strong&gt; Rehost it&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;5 times no = refactor, and only when the business asks for something the current architecture cannot give.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc2kxcm8ah71l9agjiiuk.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc2kxcm8ah71l9agjiiuk.webp" alt="Five questions to pick a cloud migration strategy per workload: nobody using it, retire. Something ties it to where it is, retain. A SaaS product does the same job, repurchase. A managed service can take over a part, replatform. The rest will stay as it is for 2 years, rehost. 5 times no, refactor" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The 5 questions, in order.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;(Relocate is rehost for a whole platform, such as a VMware estate, moved at once.)&lt;/p&gt;

&lt;p&gt;Each question has a vendor test behind it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;R&lt;/th&gt;
&lt;th&gt;What changes&lt;/th&gt;
&lt;th&gt;The test&lt;/th&gt;
&lt;th&gt;The warning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Retire&lt;/td&gt;
&lt;td&gt;Nothing moves. You switch it off&lt;/td&gt;
&lt;td&gt;AWS: average CPU and memory below 5% ("zombie"), or 5% to 20% over 90 days ("idle"), or no inbound connection for 90 days&lt;/td&gt;
&lt;td&gt;Check for month-end and year-end jobs before you believe 90 days of silence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retain&lt;/td&gt;
&lt;td&gt;Nothing, for now&lt;/td&gt;
&lt;td&gt;AWS: data residency, a recent upgrade, hardware with no cloud equivalent. A license that does not allow running in a cloud is another reason&lt;/td&gt;
&lt;td&gt;Retained workloads keep the old data center bill alive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Repurchase&lt;/td&gt;
&lt;td&gt;The product. Your data moves into it&lt;/td&gt;
&lt;td&gt;Microsoft: a mature SaaS alternative exists and you need little customization&lt;/td&gt;
&lt;td&gt;Google: it "might be a lot more expensive" and you control less&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rehost&lt;/td&gt;
&lt;td&gt;The address&lt;/td&gt;
&lt;td&gt;Microsoft: "the workload remains in its current state for at least two years"&lt;/td&gt;
&lt;td&gt;Microsoft: "Rehosting doesn't resolve existing performance, reliability, or architectural issues"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relocate&lt;/td&gt;
&lt;td&gt;The address of a whole platform&lt;/td&gt;
&lt;td&gt;AWS: you run a platform that has a cloud version, and you move many servers at once&lt;/td&gt;
&lt;td&gt;Only AWS has this R&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Replatform&lt;/td&gt;
&lt;td&gt;1 layer under the application&lt;/td&gt;
&lt;td&gt;AWS examples: SQL Server to Amazon RDS, or virtual machines into containers "without making any code changes"&lt;/td&gt;
&lt;td&gt;Google: "several rounds of testing"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Refactor&lt;/td&gt;
&lt;td&gt;The architecture&lt;/td&gt;
&lt;td&gt;AWS: "strong business demand to scale, accelerate product and feature releases, and to reduce costs"&lt;/td&gt;
&lt;td&gt;AWS: "the most complex and costly of the migration strategies"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A workload you retire is the cheapest migration you will ever run.&lt;/p&gt;

&lt;p&gt;Stephen Orban wrote in that 2016 AWS post that "as much as 10% (I've seen 20%) of an enterprise IT portfolio is no longer useful, and can simply be turned off".&lt;/p&gt;

&lt;p&gt;So question 1 comes first. Every workload you switch off leaves every later list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Move first, modernize later (the vendors disagree)
&lt;/h2&gt;

&lt;p&gt;This is the argument inside every migration: lift and shift now and improve later, or improve on the way?&lt;/p&gt;

&lt;p&gt;The 3 vendors give 3 answers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS&lt;/strong&gt; (in its guide for large migrations): "We recommend that you first migrate to the AWS Cloud and then modernize the workload." Refactor "only when the other migration strategies are not an acceptable option"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft:&lt;/strong&gt; rehost only when the workload needs no modernization for 2 years. "If modernization is likely, consider refactoring or rearchitecting instead to avoid duplicate effort". It adds a condition: only when your team has the skills and the time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google:&lt;/strong&gt; "Successful migrations change the workload to migrate as little as possible during the migration operations"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I side with AWS and Google.&lt;/p&gt;

&lt;p&gt;Why? Because a move and a rewrite at the same time is 2 changes in 1 release, and when it breaks you do not know which one did it.&lt;/p&gt;

&lt;p&gt;Move = new network, new identity system, new disks, new DNS. That is enough change for 1 cutover.&lt;/p&gt;

&lt;p&gt;There are 2 exceptions I accept:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The database.&lt;/strong&gt; Moving a self-managed database to a managed one is a replatform with a well-known path, and it removes the part of operations that hurts most&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The broken workload.&lt;/strong&gt; If it falls over every week in the data center, it will fall over every week in the cloud. Fix it or leave it for the last wave&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Microsoft's page makes one honest point for the other side: a migration project is often what gets the funding and the support of the people who decide.&lt;/p&gt;

&lt;p&gt;That is true, and "we will modernize after" is the first line cut when the migration ends.&lt;/p&gt;

&lt;p&gt;My answer: put the modernization of the 2 or 3 workloads that need it in the same plan, with dates, as the waves after the move.&lt;/p&gt;

&lt;p&gt;Netflix shows what the other choice costs in time. Its move began in August 2008 and finished in January 2016, with most systems in the cloud before 2015. Its own explanation: "we chose the cloud-native approach, rebuilding virtually all of our technology". 7 years.&lt;/p&gt;

&lt;p&gt;Netflix had a reason. Most companies moving 40 servers do not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with a boring workload that people use
&lt;/h2&gt;

&lt;p&gt;The first workload teaches your team the path: accounts, network, deploy, monitoring, cutover.&lt;/p&gt;

&lt;p&gt;So pick it for what it teaches. The 3 vendors overlap on most of it, and they differ on 1 point, how much the workload should be used:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Vendor&lt;/th&gt;
&lt;th&gt;First workloads&lt;/th&gt;
&lt;th&gt;What they add&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS&lt;/td&gt;
&lt;td&gt;0 to 3 dependencies, ready to rehost as it is, in a development or test environment&lt;/td&gt;
&lt;td&gt;Business-critical applications "are typically low priority for the migration" because they carry more risk&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Microsoft&lt;/td&gt;
&lt;td&gt;"internal tools, development environments, or low-usage applications with standalone architectures"&lt;/td&gt;
&lt;td&gt;"Add one or two complex workloads to each early wave" to find the hard problems early&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google&lt;/td&gt;
&lt;td&gt;Not business critical, few dependencies, little refactoring, can afford a cutover window&lt;/td&gt;
&lt;td&gt;"You should avoid rarely used workloads". A workload used a few times a year teaches nothing and hides its problems&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;AWS and Microsoft point at applications with few users. Google warns about the extreme of that, and its line is the one teams miss.&lt;/p&gt;

&lt;p&gt;The safest first candidate is the internal tool nobody opens. It is also useless as a test: nobody notices when it breaks.&lt;/p&gt;

&lt;p&gt;First workload = low risk + used every day + looks like the others.&lt;/p&gt;

&lt;p&gt;Google adds a people rule that I like: the team that owns the first workload "should be highly motivated". A team that did not want the migration will prove it does not work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Size the waves with AWS's numbers
&lt;/h2&gt;

&lt;p&gt;A wave = a group of workloads that move in the same window.&lt;/p&gt;

&lt;p&gt;AWS is the only vendor of the 3 that publishes numbers for the size of a wave. They come from its guides for large migrations, and they work as upper limits for small ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Waves 1 to 5:&lt;/strong&gt; "fewer servers (less than 10), low-complexity applications", in development or test environments&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Later waves:&lt;/strong&gt; an example cap of 50 servers per wave&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team capacity:&lt;/strong&gt; "a migration team of four architects can migrate up to 50 servers in a week for rehost patterns"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Planning horizon:&lt;/strong&gt; at least 4 to 5 waves in advance, and never all waves at once&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Order inside the plan:&lt;/strong&gt; 3 servers before 20, 100 GB before 2 TB, 10 users before 10,000&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpshnj6kpi9b6axxcp14y.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpshnj6kpi9b6axxcp14y.webp" alt="Migration wave sizing from the AWS guidance: waves 1 to 5 have fewer than 10 servers each, later waves up to 50 servers, plan 4 to 5 waves ahead, a team of 4 moves up to 50 servers a week" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Wave sizes from the AWS guides for large migrations.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What goes into the same wave is decided by dependencies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Applications with a shared database must migrate together"&lt;/li&gt;
&lt;li&gt;A dependency that everything shares (AWS uses Active Directory as the example) does not count. Build it in the cloud first, before any application moves&lt;/li&gt;
&lt;li&gt;Microsoft's tie-breaker: "When uncertainty exists about dependency criticality, group the components together"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Plan the calendar with the vendor's durations too, since nobody budgets for them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Discovery tooling:&lt;/strong&gt; 4 to 8 weeks to install, then 4 to 12 weeks of collecting data before its scores mean anything&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Preparation:&lt;/strong&gt; AWS calls this phase mobilize, builds the landing zone in it, and runs it as 8 sprints of 2 weeks&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runbooks and automation for a large migration:&lt;/strong&gt; 1 to 3 months before the first wave at scale&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(A landing zone is the base you build once: accounts, network, identity, logging, guardrails. Workloads land in it.)&lt;/p&gt;

&lt;p&gt;Write that base as code. And when a migration tool creates resources for you, bring them under code afterwards: &lt;a href="https://meteorops.com/blog/terraform-import" rel="noopener noreferrer"&gt;Terraform import&lt;/a&gt; does that.&lt;/p&gt;

&lt;p&gt;With 30 servers you will not need 16 weeks of preparation. You will still need the 3 steps: know what you have, build the base, write the runbook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Move the data by the downtime you can afford
&lt;/h2&gt;

&lt;p&gt;Servers are the easy part. Data decides how long the cutover takes.&lt;/p&gt;

&lt;p&gt;Google's guide asks 4 questions: how much data, how often it changes, whether you can afford a cutover window, and what consistency model you run today.&lt;/p&gt;

&lt;p&gt;Google lists 4 approaches. 3 of them cover almost every migration (the fourth, a data-access microservice, is for teams already on microservices):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Downtime&lt;/th&gt;
&lt;th&gt;How it works&lt;/th&gt;
&lt;th&gt;Pick it when&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Scheduled maintenance (big bang)&lt;/td&gt;
&lt;td&gt;The final sync, or the whole copy if you stop writes first&lt;/td&gt;
&lt;td&gt;Copy while live, stop writes, copy what changed, switch. The simpler version: stop writes, copy everything, switch&lt;/td&gt;
&lt;td&gt;The workload can afford a window: internal tools, test environments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Continuous replication&lt;/td&gt;
&lt;td&gt;Short. AWS quotes "cutover windows of minutes" for its server tool&lt;/td&gt;
&lt;td&gt;Copy everything once, then replicate changes until the switch&lt;/td&gt;
&lt;td&gt;Production databases and servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dual write ("Y")&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;The application writes and reads in both places during the move&lt;/td&gt;
&lt;td&gt;You cannot afford any window, and you can afford changing the application&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Microsoft says a migration with downtime is "simpler and faster because it doesn't require real-time synchronization". Use it wherever a window is acceptable.&lt;/p&gt;

&lt;p&gt;The tools for the second approach, with the names they carry today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS servers:&lt;/strong&gt; AWS Transform MGN (the service known as AWS Application Migration Service). It does "continuous block-level replication" of the source servers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS databases:&lt;/strong&gt; AWS Database Migration Service. A full load, a full load plus change data capture (CDC) that keeps replicating changes until the cutover, or CDC only&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Azure:&lt;/strong&gt; Azure Catalyst, which the documentation describes as "formerly Azure Migrate", and Azure Database Migration Service&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Cloud:&lt;/strong&gt; Migration Center, Migrate to Virtual Machines and Database Migration Service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then do the transfer arithmetic before you promise a date.&lt;/p&gt;

&lt;p&gt;Google's numbers: 1 GB takes 8 seconds on a 1 Gbps line in the ideal case, and 100 TB takes 12 days. On 100 Mbps, 300 TB takes about 9 months.&lt;/p&gt;

&lt;p&gt;If the line is too slow, the old answer was a storage device shipped by truck. Check it still exists:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS Snowball:&lt;/strong&gt; closed to new customers since November 7, 2025. Support ends on December 31, 2026&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Azure Data Box:&lt;/strong&gt; available in 120 TB and 525 TB (an older 80 TB device is being retired region by region). Microsoft suggests it above 40 TB with limited connectivity. Data Box Heavy is retired&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Transfer Appliance:&lt;/strong&gt; still documented. 300 TB captured "in under 25 days", plus about 10 business days until the data is in Cloud Storage&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Script the cutover and the way back
&lt;/h2&gt;

&lt;p&gt;A cutover is a script, written and rehearsed before the night it runs.&lt;/p&gt;

&lt;p&gt;Microsoft's migration guide gives the steps for a near-zero downtime cutover. This is the order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Freeze changes.&lt;/strong&gt; Block releases to the source in the CI/CD (continuous integration and delivery) pipeline for the migration window&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replicate.&lt;/strong&gt; "Don't proceed to the next step until replication lag is zero" (it stays at zero only once writes are paused, in step 3)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pause writes.&lt;/strong&gt; Read-only mode on the source for the final sync. "If you don't pause write operations, you increase the risk of data loss"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validate the data.&lt;/strong&gt; Row counts are a quick check, and "checksums and hash functions are preferred"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switch traffic.&lt;/strong&gt; "Update DNS records and load balancer configurations"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch.&lt;/strong&gt; Performance, error rates and user access "for the first 24-48 hours after cutover"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the source.&lt;/strong&gt; "Retain the source environment as a fallback option", with the ability to revert DNS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Announce.&lt;/strong&gt; "Announce migration success only after thorough validation"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fokxoa4xcj7gy1cb5mofg.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fokxoa4xcj7gy1cb5mofg.webp" alt="The cutover in 8 steps: freeze changes, replicate until lag is zero, pause writes, validate with checksums, switch DNS and load balancer, watch for 24 to 48 hours, keep the source as fallback, announce. Rollback triggers and a time limit are written before step 1" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The cutover in order, with the way back written first.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The way back is written before step 1:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Triggers:&lt;/strong&gt; Microsoft asks for "specific conditions that trigger a rollback", such as CPU usage, response time or error rate. A number, decided in daylight. If the workload has a service level objective, start from it: &lt;a href="https://meteorops.com/blog/slo-vs-sla" rel="noopener noreferrer"&gt;SLO vs SLA vs SLI&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A time limit:&lt;/strong&gt; Google's rule is my favorite line in all 3 guides. "Set a maximum-allowed execution time for each migration step. After this allowed execution time expires, your teams start rolling back the migration step"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A rehearsal:&lt;/strong&gt; both tell you to test the rollback before you need it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The steps with no way back:&lt;/strong&gt; Google warns that some steps lose data even when rolled back. Mark them in the script&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rollback = a decision you made last week, executed by whoever is on call tonight.&lt;/p&gt;

&lt;p&gt;Know where the point of no return is. The first one is the first write that lands only on the new side: from then on, going back means copying data back. Your tool has a second one. In AWS Transform MGN it is the action called "Finalize cutover": it "stops data replication, discards all replicated data" and removes the agent from the source.&lt;/p&gt;

&lt;p&gt;About DNS: none of the 3 migration guides gives a number for the TTL (time to live). Google's comes closest: it asks whether you can set the TTL "to its minimum value in seconds before you perform the migration", and whether your clients respect it at all (some applications cache DNS and ignore the TTL).&lt;/p&gt;

&lt;p&gt;The closest number is in the Amazon Route 53 best practices, which call 60 or 120 seconds a common choice for records changed during a fast failover. Lower the TTL at least 1 full old TTL before the cutover: resolvers keep the old value until the old TTL runs out.&lt;/p&gt;

&lt;p&gt;If the workload has recovery targets, the cutover has to fit inside them. I wrote about setting those in &lt;a href="https://meteorops.com/blog/rto-vs-rpo" rel="noopener noreferrer"&gt;RTO vs RPO&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And if you can send a small share of traffic to the new environment first, do that. The patterns are in &lt;a href="https://meteorops.com/blog/deployment-strategies" rel="noopener noreferrer"&gt;deployment strategies&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decide when the old environment dies
&lt;/h2&gt;

&lt;p&gt;For a while after each cutover you pay for 2 environments.&lt;/p&gt;

&lt;p&gt;No vendor publishes what that costs. Google names the risk: "the cost of running two environments indefinitely".&lt;/p&gt;

&lt;p&gt;So write the conditions for switching the source off before the first wave:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No traffic:&lt;/strong&gt; monitoring shows nothing still reaching the old environment that should reach the new one&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A soak period you chose:&lt;/strong&gt; Microsoft's example is "all performance benchmarks met for 30 days"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A named approver:&lt;/strong&gt; somebody signs the decommission&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data under retention rules:&lt;/strong&gt; an inventory of what did not move and has to be kept by law&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Licenses:&lt;/strong&gt; what you can reuse in the cloud and what you can stop paying for&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then compare the first cloud invoices to what the workload cost before. Microsoft puts it in its checklist: "Compare current costs to premigration baselines."&lt;/p&gt;

&lt;p&gt;A migration without a decommission date is a second data center.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put the exit in the plan on day 1
&lt;/h2&gt;

&lt;p&gt;You are choosing a provider you may leave. Plan it while you have negotiating power, which is before you sign.&lt;/p&gt;

&lt;h3&gt;
  
  
  What data transfer out costs today
&lt;/h3&gt;

&lt;p&gt;List prices for data transfer out to the internet, first paid tier, read on November 19, 2026:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;Free each month&lt;/th&gt;
&lt;th&gt;First paid tier&lt;/th&gt;
&lt;th&gt;Applies to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS&lt;/td&gt;
&lt;td&gt;100 GB&lt;/td&gt;
&lt;td&gt;$0.09 per GB, up to 10 TB&lt;/td&gt;
&lt;td&gt;US East (N. Virginia)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure&lt;/td&gt;
&lt;td&gt;100 GB&lt;/td&gt;
&lt;td&gt;$0.087 per GB, next 10 TB&lt;/td&gt;
&lt;td&gt;From North America or Europe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Cloud, Premium Tier&lt;/td&gt;
&lt;td&gt;1 GiB&lt;/td&gt;
&lt;td&gt;$0.12 per GiB, up to 1 TiB&lt;/td&gt;
&lt;td&gt;From Iowa to North America&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Cloud, Standard Tier&lt;/td&gt;
&lt;td&gt;200 GiB&lt;/td&gt;
&lt;td&gt;$0.085 per GiB, up to 10,240 GiB&lt;/td&gt;
&lt;td&gt;From Iowa&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A worked example at AWS list prices, for 100 TB (102,400 GB) leaving US East in 1 month, ignoring the 100 GB free tier:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First 10,240 GB at $0.09 = $921.60&lt;/li&gt;
&lt;li&gt;Next 40,960 GB at $0.085 = $3,481.60&lt;/li&gt;
&lt;li&gt;Last 51,200 GB at $0.07 = $3,584.00&lt;/li&gt;
&lt;li&gt;Total = $7,987.20&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;About $8,000 for 100 TB. It is a real cost and a small one next to the engineering time of the move.&lt;/p&gt;

&lt;h3&gt;
  
  
  Leaving for free has rules and dates
&lt;/h3&gt;

&lt;p&gt;All 3 providers now waive egress charges for customers who leave. Each has conditions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;What you must do&lt;/th&gt;
&lt;th&gt;Timeline&lt;/th&gt;
&lt;th&gt;The catch&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS&lt;/td&gt;
&lt;td&gt;Ask support, and wait for approval before you start&lt;/td&gt;
&lt;td&gt;Request "at least two months prior" to the start. 180 days to finish for customers outside the EU&lt;/td&gt;
&lt;td&gt;You must move all your data off AWS, or all of it off 1 service. CloudFront and Direct Connect transfer is excluded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Cloud&lt;/td&gt;
&lt;td&gt;Send an Exit Notice before any transfer you want credited&lt;/td&gt;
&lt;td&gt;14 days, then 30 days to start, then 30 days or more to finish&lt;/td&gt;
&lt;td&gt;You must end all use of the service you leave. Internet transfers only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure&lt;/td&gt;
&lt;td&gt;Claim a credit for egress above the free 100 GB a month&lt;/td&gt;
&lt;td&gt;See the claim steps on the Azure bandwidth pricing page&lt;/td&gt;
&lt;td&gt;For moving all your data off Azure, over the internet&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In the European Union the Data Act has applied since September 12, 2025. The European Commission's summary: it "will also entirely remove switching charges, including charges for data egress", from January 12, 2027.&lt;/p&gt;

&lt;h3&gt;
  
  
  Contracts hold you longer than egress does
&lt;/h3&gt;

&lt;p&gt;37signals moved 7 applications out of AWS in the summer of 2023 and wrote about every step.&lt;/p&gt;

&lt;p&gt;3 details from their posts belong in any migration plan:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The savings came late: "it took until the end of that year for all the long-term contract commitments to end, so 2024 has been the first clean year of savings"&lt;/li&gt;
&lt;li&gt;Their file storage was "locked into a four(!!)-year contract" signed in 2021&lt;/li&gt;
&lt;li&gt;Missing that contract's end date would have had a price: "a cool five thousand dollars a day". And the move needed a calendar: for almost 6 petabytes they planned "at least three weeks" on a 40 Gbit line&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exit date = the end of your longest commitment. The egress price list has little to do with it.&lt;/p&gt;

&lt;p&gt;So before you sign a multi-year commitment to get a discount, write its end date next to the row of every workload it covers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Migration funding exists, ask for it
&lt;/h3&gt;

&lt;p&gt;All 3 vendors pay part of a migration: AWS through the Migration Acceleration Program, Microsoft through the page now titled Frontier Accelerate for Azure, Google through the Rapid Migration and Modernization Program (RaMP).&lt;/p&gt;

&lt;p&gt;Google publishes a baseline for general workloads: "20% of the projected Annual Recurring Revenue (ARR), capped at $2M per workload". Microsoft publishes one for databases: delivery funding and Azure credits "at 50% of year-one usage". AWS publishes no amount.&lt;/p&gt;

&lt;p&gt;In all 3 cases your number comes from your account manager or a partner. Ask before the first wave.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cloud migration checklist
&lt;/h2&gt;

&lt;p&gt;Always:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;List every workload with an owner, its dependencies and its R&lt;/li&gt;
&lt;li&gt;Switch off what nobody uses before you plan anything else&lt;/li&gt;
&lt;li&gt;Write the reason and the review date next to every retained workload&lt;/li&gt;
&lt;li&gt;Build the landing zone and the shared services before the first application moves&lt;/li&gt;
&lt;li&gt;Pick a first workload that is low risk, used every day and typical&lt;/li&gt;
&lt;li&gt;Keep the first 5 waves under 10 servers each&lt;/li&gt;
&lt;li&gt;Move applications that share a database in the same wave&lt;/li&gt;
&lt;li&gt;Plan 4 to 5 waves ahead, and replan after each one&lt;/li&gt;
&lt;li&gt;Calculate the data transfer time on your real line&lt;/li&gt;
&lt;li&gt;Write the cutover script and rehearse it&lt;/li&gt;
&lt;li&gt;Write the rollback triggers and the time limit of each step&lt;/li&gt;
&lt;li&gt;Lower DNS TTLs at least 1 full old TTL before the cutover&lt;/li&gt;
&lt;li&gt;Validate data with checksums&lt;/li&gt;
&lt;li&gt;Watch closely for 24 to 48 hours&lt;/li&gt;
&lt;li&gt;Write the conditions for switching the source off, and the date&lt;/li&gt;
&lt;li&gt;Compare the new bill to the old one&lt;/li&gt;
&lt;li&gt;Know the end date of every commitment you sign&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What are the 7 Rs of cloud migration?
&lt;/h3&gt;

&lt;p&gt;They are AWS's 7 migration strategies: retire, retain, rehost, relocate, repurchase, replatform, and refactor or re-architect. Microsoft lists 8 and Google Cloud lists 6, with different names for some of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the 6 Rs and the 5 Rs?
&lt;/h3&gt;

&lt;p&gt;The 6 Rs are the AWS list from 2016: rehost, replatform, repurchase, refactor, retire and retain. The 5 Rs are Gartner's options from 2011: rehost, refactor, revise, rebuild and replace.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which cloud migration strategy is the fastest?
&lt;/h3&gt;

&lt;p&gt;Rehost, for a single workload. Google calls it "the type that requires the least amount of time". AWS calls relocate "the quickest way to migrate" when you move a whole platform at once.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is lift and shift a bad strategy?
&lt;/h3&gt;

&lt;p&gt;No. It is the right one for a workload that works and will not change soon. It is the wrong one for a workload with problems, since the problems move with it.&lt;/p&gt;

&lt;h3&gt;
  
  
  How long does a cloud migration take?
&lt;/h3&gt;

&lt;p&gt;No vendor publishes a total. AWS gives 1 to 3 months to prepare a large migration and a pace of up to 50 servers a week for a team of 4 doing rehosts. Netflix took 7 years because it rebuilt everything.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does a cloud migration need downtime?
&lt;/h3&gt;

&lt;p&gt;Per workload, you choose. A migration with a maintenance window is simpler. Continuous replication brings the window down to minutes, and it costs more preparation.&lt;/p&gt;

&lt;h3&gt;
  
  
  How much does it cost to move data out of a cloud?
&lt;/h3&gt;

&lt;p&gt;About $0.09 per GB at list price for the first 10 TB a month out of AWS US East, and about $8,000 for 100 TB. All 3 big providers waive it when you leave and follow their process.&lt;/p&gt;

&lt;h2&gt;
  
  
  A recap
&lt;/h2&gt;

&lt;p&gt;If you take away 1 thing from this guide, let it be this:&lt;/p&gt;

&lt;p&gt;A cloud migration strategy is a list of small decisions made BEFORE the move, so that nobody has to make them at 2 AM.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 R per workload, starting with what you can switch off&lt;/li&gt;
&lt;li&gt;Move first, modernize later, except the database&lt;/li&gt;
&lt;li&gt;A first workload that is boring and used every day&lt;/li&gt;
&lt;li&gt;Small waves, planned 4 to 5 ahead&lt;/li&gt;
&lt;li&gt;A cutover script with a way back and a time limit&lt;/li&gt;
&lt;li&gt;A date on which the old environment dies&lt;/li&gt;
&lt;li&gt;The end date of every contract you sign&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't need a consultant to run this. The vendor guides are free and the checklist above is the short version.&lt;/p&gt;

&lt;p&gt;If you would like a senior engineer to go over your plan with you before the first wave (yes, that is what we sell), &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;claim a free assessment&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://meteorops.com/blog/cloud-migration-strategy" rel="noopener noreferrer"&gt;MeteorOps blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>devops</category>
      <category>aws</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>kubectl Cheat Sheet: Commands by Task, Checked on v1.37</title>
      <dc:creator>Michael Zion</dc:creator>
      <pubDate>Tue, 24 Nov 2026 15:30:07 +0000</pubDate>
      <link>https://dev.to/meteorops/kubectl-cheat-sheet-commands-by-task-checked-on-v137-4a39</link>
      <guid>https://dev.to/meteorops/kubectl-cheat-sheet-commands-by-task-checked-on-v137-4a39</guid>
      <description>&lt;p&gt;Most kubectl cheat sheets list commands by resource type. This one lists them by what you are trying to do, and every flag in it was checked against the Kubernetes v1.37 reference on November 18, 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;p&gt;12 commands cover most days:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You want to&lt;/th&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Know which cluster you are about to change&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl config current-context&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List the pods that are not running&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -A --field-selector=status.phase!=Running&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Know why a pod is unhealthy&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pod POD&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read the logs of the container that just crashed&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs POD --previous&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;See only the warnings&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl events --types=Warning&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Get a shell in a container&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl exec -it POD -- sh&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Get a shell when the image has no shell&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl debug -it POD --image=busybox:1.28 --target=CONTAINER&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reach a service from your laptop&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl port-forward svc/SERVICE 8080:80&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;See a change before you make it&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl diff -f FILE.yaml&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Restart every pod of a Deployment, gradually&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout restart deployment/NAME&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go back to the previous version&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout undo deployment/NAME&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check your permissions before you try&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl auth can-i delete pods -n NAMESPACE&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Words in capitals are placeholders. Replace them with your own names.&lt;/p&gt;

&lt;p&gt;The second command filters on the pod phase. A pod in CrashLoopBackOff, or one that runs with 0/1 containers ready, still has the phase Running and stays out of that list, and finished Job pods show up in it. For those, read the READY and STATUS columns of &lt;code&gt;kubectl get pods -A&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Do you open this page during incidents?&lt;/strong&gt; A senior engineer spends an hour on your CI/CD, infra, Kubernetes, cloud cost and on-call setup. You leave with your top 3 risks, quick wins and a rough roadmap. &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;Claim your free assessment&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find your task:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A pod is broken: &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet#debug-a-pod-by-its-status" rel="noopener noreferrer"&gt;debug a pod by its status&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The image has no shell: &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet#kubectl-debug-when-exec-is-not-enough" rel="noopener noreferrer"&gt;kubectl debug&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are about to change production: &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet#change-things-safely" rel="noopener noreferrer"&gt;change things safely&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A release went wrong: &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet#rollouts-restart-watch-and-undo" rel="noopener noreferrer"&gt;rollouts&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A node has to go: &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet#nodes-cordon-drain-and-uncordon" rel="noopener noreferrer"&gt;cordon, drain and uncordon&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You are about to delete something: &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet#delete-commands-that-hurt" rel="noopener noreferrer"&gt;delete commands that hurt&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A command from an old cheat sheet fails: &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet#old-commands-that-no-longer-work" rel="noopener noreferrer"&gt;old commands that no longer work&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup: completion, an alias and the right cluster
&lt;/h2&gt;

&lt;p&gt;Tab completion and a 1-letter alias, for bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source &amp;amp;lt;(kubectl completion bash)
alias k=kubectl
complete -o default -F __start_kubectl k
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For zsh, add this to &lt;code&gt;~/.zshrc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source &amp;amp;lt;(kubectl completion zsh)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the commands that tell you where you are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;List the clusters in your &lt;a href="https://meteorops.com/glossary/kubeconfig" rel="noopener noreferrer"&gt;kubeconfig&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl config get-contexts&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show the active one&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl config current-context&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Switch cluster&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl config use-context CONTEXT&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set the default namespace for the active context&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl config set-context --current --namespace=NAMESPACE&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run 1 command against another cluster without switching&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl --context=CONTEXT get pods&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Show client and server versions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl version&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List every resource type the cluster knows&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl api-resources&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read the documentation of a field&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl explain pod.spec.containers.resources&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The classic kubectl accident is a correct command sent to the wrong cluster. In scripts and runbooks, write &lt;code&gt;--context&lt;/code&gt; and &lt;code&gt;-n&lt;/code&gt; on every command. A script that depends on whatever context your terminal had last is a script that will delete staging in production one day.&lt;/p&gt;

&lt;p&gt;Keep kubectl within 1 minor version of the cluster. The version skew policy says: "kubectl is supported within one minor version (older or newer) of kube-apiserver." The latest stable release today is v1.37.2, and the supported minors are 1.37, 1.36 and 1.35.&lt;/p&gt;

&lt;h2&gt;
  
  
  Look at things: get, describe and output formats
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pods in every namespace&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -A&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods with their node and IP&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -o wide&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods by label&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -l app=web&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods on 1 node&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -A --field-selector=spec.nodeName=NODE&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods sorted by restarts&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods --sort-by='.status.containerStatuses[0].restartCount'&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Newest objects last&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods --sort-by=.metadata.creationTimestamp&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Watch changes live&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -w&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A label as a column&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -L app&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The full object&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get deployment NAME -o yaml&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Names only, for piping&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pods -o name&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Only the status part&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pod POD -o jsonpath='{.status}'&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The human summary with events&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl describe pod POD&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Label selectors (&lt;code&gt;-l&lt;/code&gt;) support &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt;, &lt;code&gt;in&lt;/code&gt; and &lt;code&gt;notin&lt;/code&gt;. Field selectors support only &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;!=&lt;/code&gt;, and the reference adds: "The server only supports a limited number of field queries per type."&lt;/p&gt;

&lt;h3&gt;
  
  
  Pull out 1 field with JSONPath
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Every image running in the cluster
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}'

# One key of a Secret, decoded
kubectl get secret NAME -o jsonpath='{.data.password}' | base64 -d

# A key with a dot in its name
kubectl get secret NAME -o jsonpath='{.data.ca\.crt}' | base64 -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JSONPath in kubectl has no regular expressions. The docs say to use jq for that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build your own table with custom-columns
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods -o custom-columns='NAME:.metadata.name,NODE:.spec.nodeName,IMAGE:.spec.containers[*].image'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why "get all" misses things
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;kubectl get all&lt;/code&gt; does not return all. &lt;code&gt;all&lt;/code&gt; is a category that resource types opt into. In the Kubernetes source today it covers pods, services, deployments, replicasets, statefulsets, daemonsets, jobs, cronjobs, replicationcontrollers and horizontalpodautoscalers. ConfigMaps, Secrets, Ingresses, PersistentVolumeClaims, ServiceAccounts, Roles and NetworkPolicies are missing, and so are most custom resources.&lt;/p&gt;

&lt;p&gt;To list everything in a namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl api-resources --verbs=list --namespaced -o name \
  | xargs -n 1 kubectl get --show-kind --ignore-not-found -n NAMESPACE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it before you delete a namespace you did not create.&lt;/p&gt;

&lt;h2&gt;
  
  
  Debug a pod by its status
&lt;/h2&gt;

&lt;p&gt;Start from the STATUS column of &lt;code&gt;kubectl get pods&lt;/code&gt;. Each status has a first command.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;What it means&lt;/th&gt;
&lt;th&gt;First command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Pending&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No node accepted the pod, or its volume is not ready&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe pod POD&lt;/code&gt;, then read the Events at the bottom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;ImagePullBackOff&lt;/code&gt;, &lt;code&gt;ErrImagePull&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The node cannot pull the image: wrong tag, private registry, missing pull secret&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl events --for pod/POD&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CrashLoopBackOff&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The container starts, exits and gets restarted with a growing delay&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs POD --previous&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;OOMKilled&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The container went over its memory limit and the kernel killed it&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe pod POD&lt;/code&gt;, then read Last State&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Running&lt;/code&gt; with 0/1 ready&lt;/td&gt;
&lt;td&gt;The readiness probe fails&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl describe pod POD&lt;/code&gt;, then &lt;code&gt;kubectl logs POD&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Terminating&lt;/code&gt; for minutes&lt;/td&gt;
&lt;td&gt;A finalizer or an unreachable node holds the pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl get pod POD -o jsonpath='{.metadata.finalizers}'&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The glossary has a page for each of the 3 most common ones: &lt;a href="https://meteorops.com/glossary/crashloopbackoff" rel="noopener noreferrer"&gt;CrashLoopBackOff&lt;/a&gt;, &lt;a href="https://meteorops.com/glossary/imagepullbackoff" rel="noopener noreferrer"&gt;ImagePullBackOff&lt;/a&gt; and &lt;a href="https://meteorops.com/glossary/oomkilled" rel="noopener noreferrer"&gt;OOMKilled&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq6ih18yn1hmgw5e76za4.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq6ih18yn1hmgw5e76za4.webp" alt="Four pod statuses and the first command for each: Pending, kubectl describe pod. ImagePullBackOff, kubectl events --for pod. CrashLoopBackOff, kubectl logs --previous. OOMKilled, kubectl top pod --containers" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The first command for the 4 statuses you will meet most.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The reason the last container died, without scrolling through &lt;code&gt;describe&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pod POD -o jsonpath='{.status.containerStatuses[*].lastState.terminated.reason}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the answer is &lt;code&gt;OOMKilled&lt;/code&gt;, compare real usage with the limit before you raise it (&lt;a href="https://meteorops.com/blog/how-to-set-kubernetes-resource-requests-and-limits-without-throttling-apps" rel="noopener noreferrer"&gt;how to set requests and limits&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl top pod POD --containers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;kubectl top&lt;/code&gt; needs Metrics Server in the cluster. It reports CPU and memory only, and a new pod has no numbers for the first minutes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Logs
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Follow the logs&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs -f POD&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The container that ran before the last restart&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs POD --previous&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1 container of a pod with several&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs POD -c CONTAINER&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Every container of the pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs POD --all-containers&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The last 15 minutes&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs POD --since=15m&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The last 100 lines, with timestamps&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs POD --tail=100 --timestamps&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Every pod of a Deployment&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs deployment/NAME --all-pods&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Every pod with a label, each line marked with its pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl logs -l app=web --prefix --tail=50&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;3 details that cost people time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;kubectl logs deployment/NAME&lt;/code&gt; without &lt;code&gt;--all-pods&lt;/code&gt; reads 1 pod. The flag arrived in kubectl 1.31.&lt;/li&gt;
&lt;li&gt;With a label selector, &lt;code&gt;--tail&lt;/code&gt; defaults to 10 lines per pod, and &lt;code&gt;-f&lt;/code&gt; stops with an error when the selector matches more than 5 pods. Raise that limit with &lt;code&gt;--max-log-requests&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--previous&lt;/code&gt; reads the previous container of the same pod. Once the pod is deleted, those logs are gone from kubectl. A log pipeline is the only thing that keeps them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Events
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl events --for pod/POD
kubectl events --types=Warning
kubectl events -A --types=Warning --watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;kubectl events&lt;/code&gt; has been a top-level command since 1.26. It sorts by time on its own, which &lt;code&gt;kubectl get events&lt;/code&gt; does not. If you are on muscle memory, &lt;code&gt;kubectl get events --sort-by=.metadata.creationTimestamp&lt;/code&gt; still works.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shell, files and ports
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A shell in the pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl exec -it POD -- sh&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1 command in 1 container&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl exec POD -c CONTAINER -- env&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A command in the first pod of a Deployment&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl exec deployment/NAME -- date&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy a file out of a pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl cp NAMESPACE/POD:/tmp/dump.hprof ./dump.hprof&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local port 8080 to port 80 of a Service&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl port-forward svc/SERVICE 8080:80&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local port 5432 to a pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl port-forward pod/POD 5432:5432&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;--&lt;/code&gt; before the command is required. The form without it was removed in kubectl 1.31, and some cheat sheets that rank today still print it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl cp&lt;/code&gt; needs the &lt;code&gt;tar&lt;/code&gt; binary inside the container. On a distroless image it fails, which brings us to the next command.&lt;/p&gt;

&lt;h2&gt;
  
  
  kubectl debug: when exec is not enough
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;kubectl exec&lt;/code&gt; can only run a binary that exists in the image. A distroless image has no shell and no tools, and a crashing container does not stay up long enough to exec into. &lt;code&gt;kubectl debug&lt;/code&gt; covers both, in 3 modes.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Use it when&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ephemeral container in the running pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl debug -it POD --image=busybox:1.28 --target=CONTAINER&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The pod runs and the image has no tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy of the pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl debug POD -it --copy-to=POD-debug --container=CONTAINER -- sh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The container crashes at start and you want it with another command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pod on the node&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl debug node/NODE -it --image=busybox:1.28&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The problem is the node and you have no SSH&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8o2m790doxu76hwxggxp.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8o2m790doxu76hwxggxp.webp" alt="The 3 modes of kubectl debug: an ephemeral container inside the running pod, a copy of the pod, and a debug pod on the node with the host filesystem at /host" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The 3 modes of kubectl debug.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--target&lt;/code&gt; puts the debug container in the process namespace of the named container, so &lt;code&gt;ps&lt;/code&gt; shows its processes. The container runtime has to support it.&lt;/li&gt;
&lt;li&gt;An ephemeral container stays in the pod spec until the pod is replaced. It never restarts, and you cannot add one with &lt;code&gt;kubectl edit&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In node mode the node's filesystem is mounted at &lt;code&gt;/host&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Delete the copy and the node pod when you are done. Nothing cleans them up for you.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;--profile&lt;/code&gt; sets how much power the debug container gets: &lt;code&gt;general&lt;/code&gt;, &lt;code&gt;baseline&lt;/code&gt;, &lt;code&gt;restricted&lt;/code&gt;, &lt;code&gt;netadmin&lt;/code&gt; or &lt;code&gt;sysadmin&lt;/code&gt;. The default changed from &lt;code&gt;legacy&lt;/code&gt; to &lt;code&gt;general&lt;/code&gt; in kubectl 1.36, and &lt;code&gt;legacy&lt;/code&gt; is planned for removal in 1.39. Use &lt;code&gt;--profile=sysadmin&lt;/code&gt; when you need root on a node, and &lt;code&gt;--profile=restricted&lt;/code&gt; in namespaces that enforce the restricted Pod Security Standard.&lt;/p&gt;

&lt;p&gt;(One official page still says the default is &lt;code&gt;legacy&lt;/code&gt;. The v1.37 command reference and the 1.36 changelog say &lt;code&gt;general&lt;/code&gt;.)&lt;/p&gt;
&lt;h2&gt;
  
  
  Change things safely
&lt;/h2&gt;

&lt;p&gt;The order I use for any change to a cluster that matters: diff, server dry run, apply.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl diff -f deploy.yaml
kubectl apply -f deploy.yaml --dry-run=server
kubectl apply -f deploy.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;kubectl diff&lt;/code&gt; exits with 0 when nothing would change, 1 when something would, and more than 1 on an error. That makes it a 1-line drift check in CI.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--dry-run=server&lt;/code&gt; sends the request through admission and validation without saving it. &lt;code&gt;--dry-run=client&lt;/code&gt; only prints the object. Always write the value: the bare &lt;code&gt;--dry-run&lt;/code&gt; has been deprecated since 1.18.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl apply -k DIRECTORY&lt;/code&gt; applies a kustomization the same way.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Let kubectl write the YAML
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create deployment web --image=nginx:1.27 --dry-run=client -o yaml &amp;gt; deploy.yaml
kubectl create secret generic db --from-literal=password=CHANGE_ME --dry-run=client -o yaml
kubectl create configmap app-config --from-file=config.yaml --dry-run=client -o yaml
kubectl create job manual-run --from=cronjob/NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last line runs a CronJob once, now. It is the fastest way to test one without waiting for the schedule.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick edits
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Change the image&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl set image deployment/NAME CONTAINER=IMAGE:TAG&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change an environment variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl set env deployment/NAME KEY=value&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Change a memory limit&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl set resources deployment/NAME -c CONTAINER --limits=memory=512Mi&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scale&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl scale deployment/NAME --replicas=3&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Patch 1 field&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl patch deployment NAME -p '{"spec":{"replicas":3}}'&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add or change a label&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl label pods POD team=payments --overwrite&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remove a label&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl label pods POD team-&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Open the live object in your editor&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl edit deployment/NAME&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If Argo CD or Flux owns the object, these edits last until the next sync. If Helm owns it, they last until the next &lt;code&gt;helm upgrade&lt;/code&gt;. Use them to stop an incident, then put the same change in Git.&lt;/p&gt;

&lt;h3&gt;
  
  
  apply, create or replace
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;apply&lt;/code&gt; sends only the differences and keeps fields that other writers set. Use it for everything that lives in a file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;create&lt;/code&gt; fails when the object exists. Use it for one-off objects and for generating YAML.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;replace&lt;/code&gt; swaps the whole spec and drops whatever is missing from your file. &lt;code&gt;replace --force&lt;/code&gt; deletes and recreates the object, and the official quick reference marks it: "Will cause a service outage."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pick 1 per object. The docs are blunt about it: "Mixing and matching techniques for the same object results in undefined behavior."&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl apply --server-side&lt;/code&gt; moves the merge to the API server and records which tool owns each field. When another tool owns a field you are changing, the request is rejected until you pass &lt;code&gt;--force-conflicts&lt;/code&gt;. Read the conflict before you force it: it is usually your autoscaler or your GitOps controller telling you the field is taken.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rollouts: restart, watch and undo
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Wait for a rollout to finish&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout status deployment/NAME --timeout=120s&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Restart every pod, one batch at a time&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout restart deployment/NAME&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Restart every Deployment with a label&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout restart deployment --selector=app=web&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List the revisions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout history deployment/NAME&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go back 1 revision&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout undo deployment/NAME&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go back to a specific revision&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout undo deployment/NAME --to-revision=2&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Freeze a rollout halfway&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout pause deployment/NAME&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Continue it&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl rollout resume deployment/NAME&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;rollout restart&lt;/code&gt; is the answer to "the app did not pick up the new ConfigMap". It follows the Deployment's update strategy. With the default RollingUpdate strategy, 2 or more replicas and a readiness probe, nobody notices. With the Recreate strategy every pod stops first.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rollout undo&lt;/code&gt; has the same catch as the quick edits: a GitOps controller will roll you forward again on its next sync. Revert the commit too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wait for something in a script
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl wait --for=condition=Available deployment/NAME --timeout=120s
kubectl wait --for=condition=Ready pod -l app=web --timeout=60s
kubectl wait --for=condition=Complete job/NAME --timeout=10m
kubectl wait --for=delete pod/POD --timeout=60s
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/POD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The default timeout is 30 seconds, so set it. &lt;code&gt;kubectl wait&lt;/code&gt; replaces every &lt;code&gt;sleep 30&lt;/code&gt; in a pipeline, and it fails the step when the thing never becomes ready. One catch: waiting for &lt;code&gt;condition=Complete&lt;/code&gt; on a Job that failed runs until the timeout, because a failed Job never gets that condition.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nodes: cordon, drain and uncordon
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl cordon NODE
kubectl drain NODE --ignore-daemonsets --delete-emptydir-data --timeout=300s
# patch, reboot or replace the node
kubectl uncordon NODE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;cordon&lt;/code&gt; stops new pods from landing on the node. &lt;code&gt;drain&lt;/code&gt; cordons first and then evicts what runs there. A plain &lt;code&gt;kubectl drain NODE&lt;/code&gt; stops on most real nodes, because of what drain refuses to touch by default:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;On the node&lt;/th&gt;
&lt;th&gt;What drain does&lt;/th&gt;
&lt;th&gt;Flag&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DaemonSet pods&lt;/td&gt;
&lt;td&gt;Refuses to proceed. With the flag it skips them, since the DaemonSet would recreate them at once&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--ignore-daemonsets&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods with an emptyDir volume&lt;/td&gt;
&lt;td&gt;Refuses, because the data dies with the pod&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--delete-emptydir-data&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods with no controller&lt;/td&gt;
&lt;td&gt;Refuses, because nothing would recreate them&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--force&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pods under a PodDisruptionBudget with no room left&lt;/td&gt;
&lt;td&gt;Waits and retries until the budget allows the eviction&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;--timeout&lt;/code&gt; to give up&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flnat7o6ju3evdn061ifo.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flnat7o6ju3evdn061ifo.webp" alt="What kubectl drain refuses by default and the flag for each: DaemonSet pods need --ignore-daemonsets, pods with emptyDir need --delete-emptydir-data, pods with no controller need --force, and a full PodDisruptionBudget makes drain wait" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;What drain refuses by default, and the flag for each case.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There is a flag that skips &lt;a href="https://meteorops.com/glossary/kubernetes-poddisruptionbudget-pdb" rel="noopener noreferrer"&gt;PodDisruptionBudgets&lt;/a&gt;, &lt;code&gt;--disable-eviction&lt;/code&gt;, and its own help text says "use with caution". A drain that hangs on a budget is doing its job. Fix the budget or add a replica. The longer version is in &lt;a href="https://meteorops.com/blog/how-to-drain-kubernetes-nodes-without-evicting-critical-workloads" rel="noopener noreferrer"&gt;how to drain Kubernetes nodes without evicting critical workloads&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Other node commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl top node
kubectl describe node NODE
kubectl taint nodes NODE dedicated=batch:NoSchedule
kubectl taint nodes NODE dedicated=batch:NoSchedule-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The trailing &lt;code&gt;-&lt;/code&gt; on the last line removes the taint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check access: can-i and whoami
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl auth whoami
kubectl auth can-i create deployments -n NAMESPACE
kubectl auth can-i --list -n NAMESPACE
kubectl auth can-i list secrets -n NAMESPACE --as=system:serviceaccount:NAMESPACE:SERVICEACCOUNT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last one answers "can this workload read Secrets?" without deploying anything. &lt;code&gt;-q&lt;/code&gt; prints nothing and only sets the exit code, for scripts.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;kubectl exec&lt;/code&gt; or &lt;code&gt;port-forward&lt;/code&gt; returns a permission error after an upgrade to 1.35: since that release the API server requires &lt;code&gt;create&lt;/code&gt; on &lt;code&gt;pods/exec&lt;/code&gt;, &lt;code&gt;pods/attach&lt;/code&gt; and &lt;code&gt;pods/portforward&lt;/code&gt; for every request. Roles that only granted &lt;code&gt;get&lt;/code&gt; on them no longer work.&lt;/p&gt;

&lt;p&gt;When a command behaves in a way you cannot explain, add &lt;code&gt;--v=6&lt;/code&gt; to see every API request kubectl makes, and &lt;code&gt;--v=8&lt;/code&gt; to see the request bodies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Delete commands that hurt
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;What it really does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl delete pod POD&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Asks the pod to stop and gives it its grace period, 30 seconds by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl delete pod POD --now&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Same as &lt;code&gt;--grace-period=1&lt;/code&gt;. The pod still gets a signal and 1 second&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl delete pod POD --grace-period=0 --force&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes the pod from the API at once and does not wait for the node to confirm that the processes stopped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl delete pods --all&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deletes every pod in the current namespace. Whichever namespace that is&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl delete namespace NAMESPACE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deletes everything in the namespace. The docs put an exclamation mark on that sentence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl delete -f DIRECTORY/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deletes every object defined in every manifest of the directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl replace --force -f FILE.yaml&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deletes and recreates. An outage for a Deployment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl delete deployment NAME --cascade=orphan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deletes the Deployment and leaves its pods running&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0zzmruyucakjc0okgrym.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0zzmruyucakjc0okgrym.webp" alt="How long a pod gets to stop: 30 seconds by default with kubectl delete pod, 1 second with --now, and no wait and no confirmation with --grace-period=0 --force" width="800" height="452"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;How long a pod gets to stop, by flag.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Force delete deserves a paragraph. The reference warns that it "does not wait for confirmation that the pod's processes have been terminated, which can leave those processes running". For a stateless web pod that is harmless. For a StatefulSet pod it can mean 2 copies of the same database member writing at once, and the StatefulSet docs name the result: data loss. If a pod is stuck in &lt;code&gt;Terminating&lt;/code&gt;, find out what holds it (a finalizer, or a node that is gone) before you reach for &lt;code&gt;--force&lt;/code&gt;. When the node is dead for good, the documented fix is to delete the Node object.&lt;/p&gt;

&lt;p&gt;Also worth knowing: deleting a pod or a Deployment bypasses PodDisruptionBudgets. Only evictions, like the ones &lt;code&gt;drain&lt;/code&gt; sends, respect them.&lt;/p&gt;

&lt;p&gt;2 habits that prevent most of the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete pods --all -n NAMESPACE --dry-run=server
kubectl delete pods --all -n NAMESPACE --interactive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first prints what would be deleted. The second lists the objects and asks for a yes. &lt;code&gt;--interactive&lt;/code&gt; (short: &lt;code&gt;-i&lt;/code&gt;) has been on by default since kubectl 1.29 and stable since 1.30.&lt;/p&gt;

&lt;h2&gt;
  
  
  kuberc: make the safe flags your default
&lt;/h2&gt;

&lt;p&gt;kuberc is a preferences file for kubectl, separate from your kubeconfig. It holds aliases and default flags and no credentials. It has been beta and on by default since kubectl 1.34, and the changelog of the upcoming 1.38 graduates it to stable, with &lt;code&gt;kubectl.config.k8s.io/v1&lt;/code&gt; as the API version.&lt;/p&gt;

&lt;p&gt;The file lives at &lt;code&gt;~/.kube/kuberc&lt;/code&gt;. This version makes every delete ask for confirmation and adds an alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: kubectl.config.k8s.io/v1beta1
kind: Preference
defaults:
  - command: delete
    options:
      - name: interactive
        default: "true"
aliases:
  - name: getn
    command: get
    options:
      - name: output
        default: json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A flag you type always wins over the default, so &lt;code&gt;kubectl delete pod POD --interactive=false&lt;/code&gt; still skips the prompt. To switch the file off for 1 shell, set &lt;code&gt;KUBERC=off&lt;/code&gt;. CI runners have no kuberc unless you put one there, so your pipelines are not affected. A script you run on your own laptop is: give its delete commands &lt;code&gt;--interactive=false&lt;/code&gt;, or it will stop and wait for an answer.&lt;/p&gt;

&lt;p&gt;The kubectl maintainers suggest 2 more settings: server-side apply as the default for &lt;code&gt;kubectl apply&lt;/code&gt;, and a policy for credential plugins. I would add server-side apply per team, after you check which tools already own fields in your cluster. Their example sets the credential plugin policy to DenyAll, and the same page tells users of managed Kubernetes to use an allowlist, since those clusters log you in through such a plugin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Old commands that no longer work
&lt;/h2&gt;

&lt;p&gt;If a command from an older cheat sheet or a Stack Overflow answer fails, it is probably in this table.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Old form&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;Use now&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl exec POD ls&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removed in 1.31&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl exec POD -- ls&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl run NAME --replicas=3&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;run&lt;/code&gt; only creates pods since 1.18, flag removed in 1.21&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl create deployment NAME --image=IMAGE --replicas=3&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl rolling-update&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removed in 1.18&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl set image&lt;/code&gt; and &lt;code&gt;kubectl rollout&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl get TYPE NAME -o yaml --export&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deprecated in 1.14 and removed&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl get TYPE NAME -o yaml&lt;/code&gt;, then clean the status and metadata by hand&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl get componentstatuses&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;API deprecated in 1.19&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl get --raw='/readyz?verbose'&lt;/code&gt; (API server and etcd checks only)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;kubectl alpha events&lt;/code&gt;, &lt;code&gt;kubectl alpha debug&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Promoted in 1.26 and 1.20&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl events&lt;/code&gt;, &lt;code&gt;kubectl debug&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl apply --server-dry-run&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Replaced in 1.18&lt;/td&gt;
&lt;td&gt;&lt;code&gt;kubectl apply --dry-run=server&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kubectl delete --cascade=false&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The documented values are background, orphan and foreground&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--cascade=orphan&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;kubectl top namespace&lt;/code&gt;, &lt;code&gt;kubectl create pod&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Do not exist, and a cheat sheet that ranks today still prints them&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;kubectl top pod -n NAMESPACE --sum&lt;/code&gt;, &lt;code&gt;kubectl run&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;1 more thing that looks deprecated and is not: &lt;code&gt;kubectl apply --prune&lt;/code&gt;. It has carried an alpha warning since kubectl 1.5, and its replacement, ApplySets, has been alpha since 1.27. If you want deleted manifests to delete objects, that is a job for Argo CD, Flux or Helm today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plugins
&lt;/h2&gt;

&lt;p&gt;A kubectl plugin is any executable on your PATH whose name starts with &lt;code&gt;kubectl-&lt;/code&gt;. A file named &lt;code&gt;kubectl-foo&lt;/code&gt; gives you &lt;code&gt;kubectl foo&lt;/code&gt;. Plugins cannot replace built-in commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl plugin list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Krew is the plugin manager maintained by the Kubernetes CLI group. Before you install from it on a laptop that holds production credentials, read this line from the docs: "Kubectl plugins available via the Krew plugin index are not audited for security." A plugin runs with your kubeconfig.&lt;/p&gt;

&lt;h2&gt;
  
  
  The checklist before a command in production
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;kubectl config current-context&lt;/code&gt; says the cluster you mean&lt;/li&gt;
&lt;li&gt;The command has &lt;code&gt;-n NAMESPACE&lt;/code&gt; written out&lt;/li&gt;
&lt;li&gt;For a change: &lt;code&gt;kubectl diff&lt;/code&gt; shows only what you expect&lt;/li&gt;
&lt;li&gt;For a delete: you ran it once with &lt;code&gt;--dry-run=server&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;For a drain: no &lt;code&gt;--disable-eviction&lt;/code&gt;, and a &lt;code&gt;--timeout&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;For a quick edit on a GitOps-managed object: the same change is on its way to Git&lt;/li&gt;
&lt;li&gt;No &lt;code&gt;--force&lt;/code&gt; on a StatefulSet pod&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is kubectl?
&lt;/h3&gt;

&lt;p&gt;kubectl is the command-line client for the Kubernetes API. Almost every command in this cheat sheet is an HTTP request to the API server of the cluster your current context points to. The &lt;code&gt;kubectl config&lt;/code&gt; commands only read and edit your local kubeconfig.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I see why a pod is not starting?
&lt;/h3&gt;

&lt;p&gt;Run &lt;code&gt;kubectl describe pod POD&lt;/code&gt; and read the Events section at the bottom, or run &lt;code&gt;kubectl events --for pod/POD&lt;/code&gt;. For a pod that starts and crashes, run &lt;code&gt;kubectl logs POD --previous&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I restart a pod with kubectl?
&lt;/h3&gt;

&lt;p&gt;There is no restart command for a single pod. For a pod that belongs to a Deployment, run &lt;code&gt;kubectl rollout restart deployment/NAME&lt;/code&gt;, which replaces every pod gradually. Deleting 1 pod also works, since the Deployment creates a new one.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I switch namespace in kubectl?
&lt;/h3&gt;

&lt;p&gt;Add &lt;code&gt;-n NAMESPACE&lt;/code&gt; to a command, or change the default of the current context with &lt;code&gt;kubectl config set-context --current --namespace=NAMESPACE&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between kubectl apply and kubectl create?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;create&lt;/code&gt; makes a new object and fails if it exists. &lt;code&gt;apply&lt;/code&gt; creates the object or updates it to match the file, and can be run again and again. Use &lt;code&gt;apply&lt;/code&gt; for files you keep in Git.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does kubectl get all not show my ConfigMaps and Secrets?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;all&lt;/code&gt; is a category that covers a short list of workload types. ConfigMaps, Secrets, Ingresses and PersistentVolumeClaims are not in it. Use the &lt;code&gt;api-resources&lt;/code&gt; one-liner from the section on &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet#look-at-things-get-describe-and-output-formats" rel="noopener noreferrer"&gt;looking at things&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which kubectl version should I install?
&lt;/h3&gt;

&lt;p&gt;A version within 1 minor of your cluster's API server. With a 1.36 cluster, kubectl 1.35, 1.36 and 1.37 are supported.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Know your context before every command, and write &lt;code&gt;--context&lt;/code&gt; and &lt;code&gt;-n&lt;/code&gt; in scripts&lt;/li&gt;
&lt;li&gt;Debug from the STATUS column: &lt;code&gt;describe&lt;/code&gt; for Pending, &lt;code&gt;events&lt;/code&gt; for image pulls, &lt;code&gt;logs --previous&lt;/code&gt; for crashes&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl debug&lt;/code&gt; replaces &lt;code&gt;exec&lt;/code&gt; on images with no shell&lt;/li&gt;
&lt;li&gt;diff, &lt;code&gt;--dry-run=server&lt;/code&gt;, then apply&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rollout restart&lt;/code&gt; to restart, &lt;code&gt;rollout undo&lt;/code&gt; to go back, and revert the commit too&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;drain&lt;/code&gt; needs &lt;code&gt;--ignore-daemonsets&lt;/code&gt; and a timeout, and a PodDisruptionBudget that blocks it is a feature&lt;/li&gt;
&lt;li&gt;Put &lt;code&gt;--interactive&lt;/code&gt; for delete in your kuberc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you would like someone to look at the cluster behind these commands (yes, that is what we do), &lt;a href="https://meteorops.com/free-assessment" rel="noopener noreferrer"&gt;claim a free assessment&lt;/a&gt; and a senior engineer will review your setup with you.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://meteorops.com/blog/kubectl-cheat-sheet" rel="noopener noreferrer"&gt;MeteorOps blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
