Storage Classes in Kubernetes: Ordering the Right Disk Without Asking for It by Name
A beginner-friendly, ground-up guide to how Kubernetes turns "I need some storage" into a real disk, how storage classes describe the menu of disk types, and how to choose, protect and manage storage in a real cluster.
Imagine you are moving into a new office. You do not walk into a furniture factory and design every desk yourself. Instead, you open a catalogue: “standard desk”, “standing desk”, “executive desk”. You pick a type, and the supplier delivers a desk that matches. You never need to know which factory built it or which truck brought it.
Storage in Kubernetes works in the same spirit. Applications say how much space they need and roughly what kind. A storage class is the catalogue entry that tells Kubernetes what kind of disk to order, from whom, and how to look after it. This guide starts from the very beginning and builds up to the point where you can read, design and troubleshoot a storage setup with confidence.
1Why Storage Is a Problem in the First Place
Before we meet storage classes, we need to understand why containers and storage do not mix naturally.
Containers are forgetful
A container is a small, portable box that holds a running program. By design, a container is disposable. When it stops, everything it wrote inside its own private space is thrown away. This is wonderful for stateless programs, such as a web page server that keeps no records, because a fresh copy can start at any time and behave exactly the same.
The trouble begins with programs that must remember things, such as databases, message queues and file storage services. If a database container is restarted and forgets every customer order, the business is in serious trouble. These programs need a place to keep data that outlives any single container.
Think of a hotel room. Guests come and go, and when a guest leaves the room is cleaned and reset. That is a container. If a guest wants their belongings to be safe for months, the hotel offers a separate storage locker in the basement. That locker is persistent storage: it stays even when the room is emptied.
Containers also move around
In Kubernetes, a container may be restarted on a different computer at any time. If its data sits on the disk of the old computer, the new copy cannot see it. So persistent storage must be something that can be reached from wherever the container lands, or that Kubernetes can move along with it.
Kubernetes solves this with a small set of ideas: volumes, persistent volumes, persistent volume claims and storage classes. This guide explains each in turn, and by the end you will see how they fit together like puzzle pieces.
2Kubernetes in Five Minutes
A quick tour of the building blocks that storage depends on.
Cluster
The whole group of computers that Kubernetes manages together as one system.
Node
One computer in the cluster that runs containers. Nodes may sit in different data centre zones.
Pod
The smallest runnable unit. It holds one or more containers that share network and storage.
Namespace
A named section of the cluster used to separate teams, projects or environments.
API Server
The front desk of the cluster. Every request to create or change anything goes through it.
Controller
A background program that watches objects and works to make reality match what you asked for.
Two ideas here are especially important for storage. First, nodes can be in different zones, which are separate physical locations with their own power and network. Second, controllers do the actual work behind the scenes. Storage in Kubernetes is largely a story of controllers reacting to your requests.
A cluster is like a chain of shops across a country. Each shop is a node, and the shops sit in different cities, which are the zones. A storage locker in one city cannot be opened from a shop in another city, which is why location matters when we talk about disks.
3Volumes, Persistent Volumes and Claims
The three basic storage ideas that come before storage classes.
Volume
A volume is a folder made available to the containers of a pod. Some volumes are temporary and vanish when the pod is removed. Others point to storage that lives outside the pod. A volume solves the problem of sharing files between containers in the same pod, and, when backed by real storage, of keeping files alive.
Persistent Volume
A persistent volume, often shortened to PV, is a piece of real storage that has been made available to the cluster. It might be a cloud disk, a network file share or a disk attached to a server. The important point is that a persistent volume exists independently of any pod. It is a resource of the cluster, like a node.
Persistent Volume Claim
A persistent volume claim, shortened to PVC, is a request for storage made by a user or application. It says, in effect, “I need this much space, with this kind of access.” Kubernetes then finds or creates a matching persistent volume and attaches the claim to it. The application only ever talks about the claim, never about the underlying disk.
| Concept | Who creates it | What it represents | Real-life picture |
|---|---|---|---|
| Volume | Application author | A folder attached to a pod | A shelf inside a room |
| Persistent Volume | Administrator or automation | A real disk or share in the cluster | A storage locker that exists in the basement |
| Persistent Volume Claim | Developer or application | A request for storage | A form asking for a locker of a certain size |
| Storage Class | Administrator | A named type of storage and how to create it | The catalogue listing locker types |
A library has shelves of books (persistent volumes). A member fills in a request slip saying what they want to borrow (a claim). The librarian matches the slip to a book and hands it over. The member never walks the aisles; the librarian does the finding.
4What Is a Storage Class?
The missing piece that lets Kubernetes create disks automatically on demand.
The plain definition
A storage class is a cluster-wide object that describes a kind of storage available in the cluster, and how Kubernetes should create it. It has a name, such as “fast” or “standard”, and it records who provides the storage, which settings to use, and what to do with the disk when it is no longer needed.
When a claim names a storage class, Kubernetes uses the class as a recipe: it asks the provider to create a brand-new disk exactly as the class describes, and then connects the disk to the claim. No administrator has to prepare anything in advance.
Consider ordering a taxi through an app. You choose “economy” or “premium”. You do not pick a specific car or driver. The app knows how to find a suitable car for each category. A storage class is the category on the menu, and the app behind it is the provisioner.
Why it exists
Before storage classes, administrators had to create every persistent volume by hand and then wait for developers to claim them. This was slow and error-prone. It also wasted money, because pre-made disks sat unused. Storage classes let developers request storage themselves, while administrators keep control by deciding which types are on the menu.
A storage class does not itself contain any data or any disk. It is only instructions. The actual disk is created later, when a claim asks for it.
5Static Versus Dynamic Provisioning
There are two ways to get a persistent volume. Storage classes power the modern one.
Static Provisioning
An administrator creates persistent volumes in advance. Users then submit claims, and Kubernetes matches each claim to a suitable existing volume. This works, but it demands planning: if the administrator guesses wrong about sizes and counts, users wait or space is wasted.
Dynamic Provisioning
Administrators define storage classes once. When a claim names a class, Kubernetes automatically asks the provider to create a matching disk and a persistent volume for it. Nobody needs to prepare anything ahead of time, and disks appear exactly when needed.
Dynamic Provisioning Advantages
- Developers get storage in seconds without tickets
- No idle disks waiting for a claim
- Consistent settings, because every disk follows the class
- Scales naturally with the number of applications
- Administrators control the menu, not each order
Dynamic Provisioning Trade-offs
- Costs can grow silently if nobody watches claims
- Requires a working provider integration
- A wrong class choice creates the wrong kind of disk
- Deleting a claim may delete real data, depending on policy
flowchart LR
subgraph Static
A1["Administrator creates disk and persistent volume"] --> B1["User submits claim"]
B1 --> C1["Kubernetes matches claim to existing volume"]
end
subgraph Dynamic
A2["Administrator defines storage class once"] --> B2["User submits claim naming the class"]
B2 --> C2["Provisioner creates a new disk on demand"]
C2 --> D2["Volume is bound to the claim"]
end
6Anatomy of a Storage Class
Every storage class is built from a handful of fields. Learn them once and you can read any class.
Name
The label users write in their claims, such as “fast”, “standard” or “archive”. Good names describe purpose or performance.
Provisioner
The plug-in that knows how to create disks for a particular storage system, often a driver following the container storage interface.
Parameters
Provider-specific settings, such as the disk type, speed level, file system or encryption choice. Each provisioner defines its own list.
Reclaim Policy
What happens to the real disk when the claim is deleted: remove it, or keep it for safety.
Volume Binding Mode
When the disk is created: immediately when the claim appears, or later when a pod actually needs it.
Allow Volume Expansion
Whether users may enlarge an existing claim later, instead of creating a new bigger one and copying data.
Mount Options
Extra options passed when the disk is attached to a node, such as tuning switches for a file system.
Allowed Topologies
Limits which zones or regions may be used, so that disks are created only in permitted places.
Most of a storage class cannot be changed once created. The provisioner, the parameters and several other settings are fixed. If you need different behaviour, you create a new class and move new claims to it. Existing disks keep the settings they were created with.
A storage class is like a printed menu card in a restaurant. The dish name is the class name, the kitchen that cooks it is the provisioner, and the notes about spice level and portion are the parameters. Once printed, changing the card is a hassle, so restaurants print a new card when the recipe changes.
7Internal Working: From Claim to Disk
Let us follow one storage request all the way from a developer’s keyboard to a mounted folder.
Step one: the claim is created
A developer creates a persistent volume claim. It states the size needed, the type of access and the name of the storage class. The API server checks permissions and stores the claim. At this moment, the claim is in a waiting state, because nothing has been provided yet.
Step two: the provisioner notices
A helper program, usually installed with the storage driver, watches for new claims that name a class it is responsible for. When it sees one, it reads the class to learn the settings, and then calls the storage provider to create a real disk of the requested size.
Step three: the persistent volume appears
Once the provider confirms the disk exists, the helper creates a persistent volume object that describes it. Kubernetes then binds the volume and the claim together. From this moment they belong to each other exclusively, and the claim reports that it is bound.
Step four: the pod uses the claim
When a pod referring to the claim is placed on a node, the storage driver attaches the disk to that node and prepares it, for example by formatting it if it is new. The node then makes the disk appear as a folder inside the containers. The application simply reads and writes files there.
sequenceDiagram
participant Dev as Developer
participant API as API Server
participant Prov as Provisioner
participant Cloud as Storage Provider
participant Node as Node and Kubelet
Dev->>API: Create claim naming a storage class
API-->>Prov: Notify about new claim
Prov->>API: Read storage class settings
Prov->>Cloud: Create disk with those settings
Cloud-->>Prov: Disk ready
Prov->>API: Create persistent volume and bind to claim
Dev->>API: Create pod that uses the claim
API-->>Node: Schedule pod
Node->>Cloud: Attach disk to node
Node->>Node: Prepare and mount disk into containers
Notice that the developer never mentions a cloud, a disk type or a serial number. The storage class hides all of that. Change the class, and the same application can use a different kind of disk without any changes to the application.
8Volume Binding Modes: When Is the Disk Created?
A surprisingly important setting that decides whether pods get stuck.
Immediate binding
With immediate binding, the disk is created as soon as the claim appears, before any pod exists. This is simple, but it has a hidden risk. Many disks are tied to a single zone. If the disk is created in one zone and the pod later lands on a node in another zone, the pod cannot use the disk and stays stuck in a waiting state.
Wait for first consumer
With this mode, Kubernetes waits until a pod that uses the claim is being placed on a node. It then creates the disk in the same zone as that node. This ensures the disk and the pod are compatible from the start. It is the recommended choice for storage that is tied to a zone or to a specific node.
flowchart TD
C["Claim created"] --> M{"Binding mode?"}
M -- "Immediate" --> I["Disk created at once in some zone"]
I --> P1["Pod scheduled later"]
P1 --> R{"Same zone as disk?"}
R -- "No" --> S["Pod stuck waiting"]
R -- "Yes" --> OK1["Pod runs"]
M -- "Wait for first consumer" --> W["Wait for a pod to be scheduled"]
W --> Z["Disk created in the pod's zone"]
Z --> OK2["Pod runs"]
Imagine booking a cinema ticket. Immediate binding is like buying a ticket for a random screen before knowing which film you will watch. Wait for first consumer is like choosing your film first, then buying a ticket for the right screen. The second way avoids arriving at the wrong door.
A claim using the wait-for-first-consumer mode will show a pending status until a pod uses it. Beginners often think this means something is broken. It is normal behaviour: the system is waiting for a pod before it picks the location.
9Reclaim Policy: What Happens to the Data Afterwards
The setting that decides whether deleting a claim also destroys your data.
When a claim is deleted, Kubernetes must decide what to do with the disk that was bound to it. This choice is called the reclaim policy, and it is set in the storage class. Understanding it can save a company from a very painful surprise.
Delete
When the claim is deleted, Kubernetes also deletes the persistent volume and asks the provider to destroy the real disk. This keeps the account tidy and avoids paying for forgotten disks, but the data is gone, usually for good. It is the common default for dynamically created storage.
Retain
When the claim is deleted, the persistent volume and the real disk are kept. The volume moves to a released state and is not automatically reused. An administrator must decide whether to recover the data, clean the disk or remove it. This is safer for valuable data, at the cost of manual work.
Deleting a namespace deletes every claim inside it. If those claims use a class with the delete policy, the disks and their data vanish with them. For production databases, many teams choose the retain policy or take regular backups.
Think of a hotel storage locker again. Under the delete policy, when a guest checks out, the hotel empties and scraps the locker contents. Under the retain policy, the hotel keeps the belongings in a back room until a manager decides what to do. One is tidy, the other is careful.
| Policy | Disk after claim deletion | Best for | Main risk |
|---|---|---|---|
| Delete | Removed with the claim | Temporary data, test environments, caches | Accidental permanent data loss |
| Retain | Kept until an administrator acts | Databases and valuable records | Forgotten disks that cost money |
10Access Modes and Volume Expansion
Two more choices that shape how storage can be used and grown.
Access modes
An access mode describes how many nodes or pods may use a volume at the same time, and whether they may write. It is requested by the claim, and it must be supported by the underlying storage.
Read Write Once
The volume can be mounted for reading and writing by a single node at a time. Most block disks work this way.
Read Only Many
Many nodes can mount the volume at once, but only for reading. Useful for shared reference data.
Read Write Many
Many nodes can read and write at the same time. Typically offered by network file systems, not by simple disks.
Read Write Once Pod
Only a single pod in the whole cluster may use the volume for reading and writing. A stricter version of the first mode.
If several pods need to write to the same files at once, a simple block disk will not do. You need storage that supports shared writing, usually a network file system, and a storage class that provisions it.
Volume expansion
Data grows. When a storage class allows expansion, a user can edit an existing claim and request a larger size. The provider enlarges the disk, and the file system is grown to use the new space, sometimes while the pod is still running, sometimes after a restart, depending on the driver.
Expansion works in one direction only. You can make a claim bigger, but you cannot shrink it. If you request too much, you pay for it until you move the data to a smaller volume by hand. This is why many teams start modestly and grow when monitoring shows the need.
A storage locker that can be extended into the next room is handy, but you cannot hand back half the locker mid-contract. Plan for growth, but do not order the biggest size on day one.
11The Default Class and Storage Tiers
How clusters offer a sensible choice to people who do not ask for anything specific.
The default storage class
One storage class in a cluster can be marked as the default, using a special annotation. When a claim does not name any class at all, Kubernetes silently gives it the default. This makes life easy for beginners, who can ask for space without learning the menu.
There should be only one default at a time. If a claim explicitly names an empty class, Kubernetes understands that dynamic creation is not wanted and looks only for existing volumes to match. This small difference between “no class named” and “empty class named” surprises many people.
Leaving a cluster with no default class means claims that do not name a class will wait forever for a disk that nobody will create. On the other hand, a careless default might place important data on slow or short-lived storage.
Building tiers
Because a class is just a named recipe, administrators can create several, each representing a service level. A typical menu might look like this.
| Class name idea | Typical disk | Reclaim policy | Used for |
|---|---|---|---|
| Standard | Everyday general-purpose disk | Delete | Ordinary applications and test setups |
| Fast | High-speed solid-state disk | Delete or Retain | Busy databases and search indexes |
| Critical | High-speed disk with extra protection | Retain | Production records that cannot be lost |
| Shared | Network file system | Delete | Files that many pods must write together |
| Archive | Low-cost, slower disk | Retain | Logs, backups and rarely read data |
An airline offers economy, business and first class. Passengers pick a class based on need and budget, and the airline handles the rest. Storage tiers give teams the same simple choice.
12Provisioners and the Container Storage Interface
Who actually builds the disk? The answer is a plug-in system.
The problem it solves
There are countless storage systems in the world: cloud disks, network appliances, software-defined storage, local drives. If Kubernetes had to include code for every one, it would be enormous and slow to update. Instead, Kubernetes defines a standard plug-in interface called the Container Storage Interface, or CSI, and lets each storage vendor supply a driver.
What a driver does
A CSI driver knows how to create and delete disks, attach them to nodes, format them, mount them into pods, expand them and take snapshots. The storage class points to a driver by name through its provisioner field, and passes settings through the parameters field.
flowchart LR
K["Kubernetes core"] --> CSI["Container Storage Interface"]
CSI --> D1["Cloud disk driver"]
CSI --> D2["Network file system driver"]
CSI --> D3["Software-defined storage driver"]
CSI --> D4["Local disk driver"]
D1 --> S1["Block disks in the cloud"]
D2 --> S2["Shared file storage"]
D3 --> S3["Distributed storage cluster"]
D4 --> S4["Disks in the node itself"]
Kinds of storage a class might describe
Cloud Block Disks
Virtual disks offered by a cloud provider. They are fast and reliable, usually attach to one node at a time, and are tied to a specific zone.
Network File Systems
Shared folders reachable over the network. Many pods on many nodes can use them together, which makes them ideal for content sharing, though usually slower than local block disks.
Distributed Storage Clusters
Software that pools the disks of many machines into one storage service, offering block, file or object storage. It is popular in private data centres.
Local Disks
Disks physically inside a node. They can be very fast, but the data is tied to that machine, so if the node fails the data may be lost or unreachable.
The parameters allowed in a storage class depend entirely on the driver. Always read the driver’s own documentation to learn what settings it accepts, rather than copying a class made for a different driver.
13The Life of a Piece of Storage
From request to retirement, storage passes through clear stages.
Class Defined
An administrator writes a storage class describing the provider, settings, reclaim policy and binding mode.
Claim Created
A developer requests space by size, access mode and class. The claim starts in a pending state.
Disk Provisioned
The driver creates a real disk, and a persistent volume describing it is bound to the claim.
Attached and Mounted
When a pod uses the claim, the disk is attached to the pod’s node and mounted as a folder in the containers.
In Use and Growing
The application reads and writes data. If space runs low, the claim may be expanded, provided the class allows it.
Released and Reclaimed
When the claim is deleted, the reclaim policy decides whether the disk is destroyed or kept for an administrator.
Most beginners only see the middle steps. Experienced engineers plan for the first and last, because the class design decides cost and safety, and the reclaim step decides whether data survives a mistake.
14Storage for Stateful Applications
Databases and similar programs need special care, and Kubernetes has a dedicated tool for them.
Why a plain Deployment is not enough
A Deployment treats its pods as interchangeable. If several pods share one claim, they all fight over the same disk, and most block disks only allow one node at a time. Stateful applications need each copy to have its own stable identity and its own private storage.
The StatefulSet approach
A StatefulSet is a manager object designed for such programs. It gives each pod a permanent name and number. It can also carry a claim template, which means every pod gets its own personal claim created from the chosen storage class. If a pod is rebuilt, it reconnects to the very same claim and finds its data waiting.
flowchart TD
SS["StatefulSet with a claim template"] --> P0["Pod number 0"]
SS --> P1["Pod number 1"]
SS --> P2["Pod number 2"]
P0 --> C0["Own claim 0"]
P1 --> C1["Own claim 1"]
P2 --> C2["Own claim 2"]
C0 --> V0["Own disk 0"]
C1 --> V1["Own disk 1"]
C2 --> V2["Own disk 2"]
Think of hotel rooms numbered 1, 2 and 3. Each guest keeps the same room for the whole stay, with their own locker key. If a guest steps out and returns, they walk back into the same room and find their things untouched. That is what a StatefulSet does with storage.
Removing a StatefulSet does not automatically remove its claims, which is a deliberate safety feature. Forgotten claims can pile up and cost money, so include claim clean-up in your decommissioning routine.
15Security Considerations
Data at rest deserves protection, and storage classes are a good place to enforce it.
Encryption at rest
Many drivers accept a parameter that turns on disk encryption, sometimes with a key managed by a key service. By putting this in the storage class, an administrator ensures that every disk created from it is encrypted, without relying on each developer to remember.
Control who can create claims
Anyone allowed to create claims can cause disks to be created, which costs money and consumes capacity. Role-based access control decides who may do so. Combine it with limits, called resource quotas, that cap the total storage a namespace may request.
Control who can define classes
Storage classes are cluster-wide, so only trusted administrators should be able to create or edit them. A careless class could send data to an insecure location or use a dangerous reclaim policy.
Isolation between teams
Claims live in namespaces and cannot be used by pods in other namespaces. The underlying volumes, however, are cluster resources. Good policy prevents users from binding directly to volumes that belong to someone else.
Protect backups and snapshots
Snapshots of volumes contain the same data as the volumes, and must be protected in the same way. Keep them encrypted and limit who may create, view or restore them.
flowchart TD
A["Trusted administrators define storage classes"] --> B["Classes enforce encryption and reclaim policy"]
B --> C["Access control limits who may create claims"]
C --> D["Quotas cap storage per namespace"]
D --> E["Snapshots and backups are encrypted and restricted"]
E --> F["Audit logs record who created or deleted storage"]
A storage class is not a security boundary by itself. Encryption and access rules must be set deliberately. Never assume that data is safe just because it sits on a disk in your own account.
16Monitoring, Logging and Troubleshooting
Storage problems are quiet until they are suddenly loud. Watch them early.
What to monitor
Used Space
How full each volume is. Alert well before it reaches the limit, since a full disk can crash a database.
Pending Claims
Claims that stay pending for a long time signal a missing class, a driver problem or a zone mismatch.
Performance
Read and write speed and delay. A slow disk makes an application feel broken even when it is technically running.
Unused Volumes
Volumes that are released or unattached still cost money. Regular reports reveal forgotten disks.
Common problems and their usual causes
| Symptom | Likely cause | What to check |
|---|---|---|
| Claim stays pending | Class name is wrong, no default class, or driver is not running | Spelling of the class, list of classes, driver health |
| Pod stuck waiting for its volume | Disk and node are in different zones | Binding mode and zone rules |
| Cannot enlarge a claim | Class does not allow expansion | Expansion setting on the class |
| Data disappeared after cleanup | Delete reclaim policy on the class | Reclaim policy and backup routine |
| Two pods cannot share a disk | Access mode only allows a single node | Access mode and storage type |
Kubernetes records events on claims and pods explaining why something is waiting. Reading those events is usually the fastest way to find the cause, because the driver often writes a clear message about what it could not do.
17Design Patterns and Anti-Patterns
Patterns are proven habits. Anti-patterns are popular mistakes that keep costing teams.
Patterns worth adopting
A Small, Well-Named Menu
Offer a handful of classes with clear names based on purpose, such as standard, fast, critical and shared. Too many classes confuse developers, and too few force poor choices.
Wait for First Consumer on Zone-Bound Storage
Use this binding mode for any disk tied to a zone, so that pods and disks always land together.
Separate Classes for Separate Reclaim Needs
Create one class with the delete policy for disposable data and another with the retain policy for valuable data. Developers then choose safety by choosing a name.
Quotas per Namespace
Give every team a limit on total storage and number of claims. Costs stay predictable and runaway automation cannot fill the account.
Regular Backups and Restore Drills
Take snapshots or backups on a schedule and actually practise restoring them. A backup that has never been restored is only a hope.
Anti-patterns to avoid
Problem
Production databases are placed on the default class, which uses the delete reclaim policy and ordinary disks.
Why It’s Harmful
A single mistaken claim deletion, or a deleted namespace, destroys the disk and its data. Performance may also be too low for the workload.
Correct Approach
Create a dedicated class for critical data with the retain policy and suitable disk type, and combine it with tested backups.
Problem
Zone-bound disks are created with immediate binding in a cluster that spans several zones.
Why It’s Harmful
The disk may be created in a zone where no suitable node has room, leaving pods stuck and confusing engineers.
Correct Approach
Use the wait-for-first-consumer mode so the disk is created where the pod will run.
Problem
Several classes are marked as default, or none at all, depending on who last edited the cluster.
Why It’s Harmful
Behaviour becomes unpredictable. Some claims may fail to get a disk, and others may land on storage nobody chose deliberately.
Correct Approach
Mark exactly one class as the default, document it, and review it whenever classes change.
Problem
Several application pods are pointed at one block disk claim to “share” data.
Why It’s Harmful
Most block disks allow only one node at a time, so pods on other nodes fail to start. Where sharing does work, uncoordinated writes can corrupt files.
Correct Approach
Use a shared file system class for genuinely shared data, or give each pod its own claim through a StatefulSet.
Problem
Nobody reviews leftover volumes after projects end, and released disks accumulate for months.
Why It’s Harmful
Money is spent on storage no one uses, and old data with unknown sensitivity sits around unprotected.
Correct Approach
Run a regular clean-up review, label claims with owners, and remove or archive what is no longer needed.
18Advantages, Disadvantages and Trade-offs
An honest look at what storage classes give you, and what they cost.
Advantages
- Developers request storage on their own without tickets
- Administrators keep control through a curated menu
- The same application works across clouds by switching the class
- Consistent settings such as encryption are enforced automatically
- Disks are created only when needed, avoiding idle waste
- A standard plug-in interface supports many storage vendors
Disadvantages / Trade-offs
- Most class settings cannot be changed after creation
- Behaviour depends heavily on the specific driver
- Wrong reclaim policy choices can lead to data loss or wasted cost
- Zone and access-mode rules can surprise beginners
- Claims can be shrunk only by moving data manually
- Storage is not portable between clouds without a data copy
The main lesson is that a storage class makes provisioning easy, but it does not make data management easy. Backups, capacity planning and clean-up remain the team’s responsibility.
19Best Practices and Common Mistakes
A checklist of habits that separate steady clusters from surprising ones.
Best practices
- Offer a small menu of clear classes — name them by purpose so developers can choose without expert knowledge.
- Mark exactly one default — and make sure it is safe and sensible for everyday use.
- Use wait for first consumer — for any storage tied to a zone or a node.
- Choose reclaim policy on purpose — delete for disposable data, retain for valuable data.
- Allow expansion — so growth does not require copying data to a new disk.
- Enable encryption in the class — so every disk is protected without depending on memory.
- Set quotas and alerts — cap storage per namespace and warn before disks fill.
- Back up and rehearse restores — snapshots are only useful if restoring works.
Common mistakes
A storage class affects only disks created afterwards. Existing volumes keep the settings they were born with, so changes to a class never rewrite history.
Provisioner names and parameters are specific to a driver. A class written for one cloud will not work on another and may create nothing at all.
Disks have maximum sizes and every node can attach only a limited number of them. Plan for these limits, especially with many small claims.
A backup stored next to the original disk shares its fate. Keep copies in a separate location so that a single failure cannot destroy both.
20Real-World Examples
How the ideas in this guide appear in everyday engineering.
An Online Shop and Its Order Database
An online shop runs its order database on a fast class with the retain policy and encryption switched on. Backups run nightly and are restored monthly in a rehearsal. A deleted namespace during a clean-up mistake left the disk intact, and the team recovered within minutes.
A Bank Separating Environments
A bank offers separate classes for development, testing and production. Development uses low-cost disks with the delete policy so that costs fall automatically, while production uses protected, encrypted disks that are retained after deletion. Quotas keep each team within its budget.
A Media Company Sharing Content
A media company uses a shared file system class so that many web pods can serve and update the same library of images. Ordinary block disks would have blocked this, because they attach to one node at a time.
A Data Team Running Search and Analytics
A data team runs a search cluster as a StatefulSet. Each pod gets its own fast disk through a claim template. When a node fails, the pod restarts elsewhere and reconnects to the same disk, so the index does not need to be rebuilt from scratch.
A Start-up Controlling Costs
A start-up notices a growing bill. A review finds many released volumes from old experiments. They introduce owner labels on claims, a monthly clean-up review and namespace quotas, and storage costs drop noticeably without any application changes.
21Frequently Asked Questions
A persistent volume is an actual piece of storage in the cluster. A storage class is a template describing how such volumes should be created on demand. The class is the recipe, and the volume is the dish.
No. If administrators pre-create persistent volumes, claims can bind to them without any class doing dynamic creation. However, most modern clusters use storage classes because they remove manual work.
Common reasons include a misspelled class name, no default class, a driver that is not running, or a binding mode that waits for a pod. Check the events on the claim for a clear explanation.
Not directly. The class of a claim is fixed once set. To move to a different class, you create a new claim with the new class and copy the data across, often using snapshots or a migration tool.
It depends on the reclaim policy. With delete, the disk and data are removed. With retain, the disk is kept and an administrator decides what to do with it. Always check the policy before deleting anything important.
No. Kubernetes supports growing a claim only. To shrink, you must create a smaller volume and move the data yourself.
Many cloud disks exist in one zone only and can be attached only to nodes in that zone. If a pod runs in a different zone, it cannot reach the disk. The wait-for-first-consumer mode avoids this by creating the disk where the pod runs.
Only if the storage and its access mode allow it. Network file systems usually support shared reading and writing. Simple block disks generally allow one node at a time.
Exactly one should be marked default. Having several or none makes behaviour unpredictable for claims that do not name a class.
List your storage classes and check the reclaim policy and binding mode of each. Then make sure critical data uses a protected class and that backups exist and have been tested.
22Summary and Key Takeaways
Containers forget, but applications often must remember. Kubernetes solves this with persistent volumes, claims and storage classes. A claim is a request for space, a persistent volume is the real storage, and a storage class is the recipe that lets Kubernetes create that storage on demand through a driver. Choices such as binding mode, reclaim policy, access mode and expansion decide where a disk lives, whether it survives deletion, who can share it and whether it can grow.
Treat storage classes as the menu you offer your developers. Keep it small, name it clearly, protect what is valuable, and watch what is growing. Do that, and Kubernetes storage becomes a quiet, dependable part of your platform rather than a source of midnight surprises.
Key Takeaways
- A storage class is a recipe, not a disk — it describes the provider, settings and behaviour used to create disks on demand.
- Claims request, classes describe, volumes provide — developers ask for space, administrators curate the menu, and drivers build the real storage.
- Binding mode prevents stuck pods — use wait for first consumer for zone-bound disks so the disk is created where the pod runs.
- Reclaim policy decides data survival — delete is tidy but destructive, retain is safer but needs manual clean-up.
- Access mode limits sharing — most block disks serve one node at a time, and shared writing needs a network file system.
- Most class settings are fixed — create a new class for new behaviour, and remember that old disks keep their original settings.
- Storage still needs care — backups, encryption, quotas, monitoring and regular clean-up remain your responsibility.