Tuesday, June 9, 2026

K8S Reference - StorageClass YAML

A StorageClass defines how Kubernetes dynamically provisions storage volumes. Instead of manually creating PersistentVolumes, administrators create StorageClasses and allow PersistentVolumeClaims (PVCs) to automatically request storage from the underlying provider.

Element Required / Optional Description Example Syntax
apiVersion Required Specifies the Kubernetes API group and version for StorageClass resources.
apiVersion: storage.k8s.io/v1
kind Required Defines the Kubernetes resource type.
kind: StorageClass
metadata.name Required Name of the StorageClass that application teams will reference inside their PVC manifests.
name: fast-ssd-storage
provisioner Required Specifies the storage plugin or CSI driver responsible for physically creating disks.
provisioner: ebs.csi.aws.com
parameters Optional (Highly Recommended) Vendor-specific configuration settings such as storage type, performance profile, IOPS limits, throughput, encryption settings, or filesystem choices.
parameters:
  type: gp3
  iops: "3000"
volumeBindingMode Optional (Recommended) Controls when storage volumes are created and bound to claims. WaitForFirstConsumer is commonly preferred because it allows Kubernetes to choose storage in the same availability zone as the scheduled Pod.
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy Optional Determines what happens to dynamically created storage when the PVC is deleted. Delete removes the underlying disk, while Retain preserves it for manual recovery.
reclaimPolicy: Delete
allowVolumeExpansion Optional Allows existing PersistentVolumeClaims to grow in size without deleting and recreating them.
allowVolumeExpansion: true
Best Practice: For cloud environments, use volumeBindingMode: WaitForFirstConsumer and allowVolumeExpansion: true. These settings improve scheduling flexibility and allow storage growth without disrupting applications.

No comments:

Post a Comment

K8S - Important Reference Articles on this Blog

The following articles provide a neat and concise reference for creating YAML files for some of the most commonly use...