Skip to content
tezvyn:

Kubernetes StorageClass: A Menu for Your Data

Source: kubernetes.ioMediumHow cards are made

Kubernetes StorageClass: A Menu for Your Data

A StorageClass is an admin-defined 'menu' of storage options, abstracting the provider. Developers request storage by name (e.g., 'fast-ssd') via a PersistentVolumeClaim, and Kubernetes dynamically provisions it.

Why it exists

In a large cluster, manually creating a physical storage volume for every application is slow and error-prone. StorageClass was created to automate this, allowing storage to be provisioned on-demand based on abstract requests, decoupling applications from the underlying storage infrastructure.

The mental model

Think of a StorageClass as a restaurant menu. The menu lists different dishes ('fast-ssd', 'backup-storage') without detailing the kitchen's specific recipes or ingredient suppliers. A developer (the customer) orders a dish using a PersistentVolumeClaim (PVC). The cluster (the kitchen) then prepares the actual dish—a PersistentVolume (PV)—according to the recipe defined in the StorageClass.

How it works

An administrator defines a StorageClass resource in YAML. This definition includes a name (e.g., aws-gp3-fast), a provisioner (e.g., ebs.csi.aws.com), and parameters specific to that provisioner (e.g., type: gp3, fsType: ext4). When a user creates a PersistentVolumeClaim that references this StorageClass by name, the specified provisioner is triggered. It dynamically creates a matching PersistentVolume and binds it to the claim, making it available for a Pod to mount.

When to use it

Use StorageClasses whenever you need to provide persistent storage for stateful applications in Kubernetes. It is the standard, cloud-native way to manage storage lifecycles automatically, especially in public cloud environments like AWS, GCP, or Azure where storage options are API-driven. It's essential for enabling self-service for development teams.

When not to use it

You might not use dynamic provisioning via StorageClass if you are working with pre-existing, manually provisioned storage volumes that you need to map into the cluster. In this case, you would create PersistentVolume objects manually and have PVCs bind to them directly, without a StorageClass. This is common for migrating legacy stateful services or for specialized hardware.

One canonical example

A major footgun is the reclaimPolicy. The default is Delete, which permanently destroys the underlying storage volume when the PVC is deleted. For production data, you almost always want to set reclaimPolicy: Retain to prevent accidental data loss. Another common issue is the default StorageClass. If a PVC is created without specifying a storageClassName, it uses the default, which might be an expensive tier of storage, leading to unexpected costs.

Interview question

In which scenario would you typically not use a StorageClass for Kubernetes storage provisioning?

  • a.When enabling self-service storage for development teams.
  • b.When integrating pre-existing, manually managed storage resources.Correct
  • c.When dynamically creating storage volumes for stateful applications.
  • d.When abstracting underlying storage infrastructure from applications.
Why?

The card states that StorageClasses are not typically used when working with pre-existing, manually provisioned storage volumes; instead, PersistentVolume objects would be created manually. The other options describe key benefits or use cases for StorageClasses.

Just read this? Test yourself on what you have been reading.

Read the original → kubernetes.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.

See open roles