0
0
Kubernetesdevops~30 mins

Storage classes for dynamic provisioning in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Storage classes for dynamic provisioning
📖 Scenario: You are managing a Kubernetes cluster that needs to automatically create storage volumes for applications when they request storage. This is called dynamic provisioning. You will create a StorageClass to define how storage is dynamically created, then create a PersistentVolumeClaim that uses this StorageClass.
🎯 Goal: Build a StorageClass named fast-storage that provisions storage dynamically with the kubernetes.io/aws-ebs provisioner and a PersistentVolumeClaim named fast-pvc that uses this StorageClass to request 5Gi of storage.
📋 What You'll Learn
Create a StorageClass named fast-storage with provisioner kubernetes.io/aws-ebs
Set the StorageClass parameter type to gp2
Create a PersistentVolumeClaim named fast-pvc that uses the fast-storage StorageClass
Request exactly 5Gi of storage in the PersistentVolumeClaim
Use access mode ReadWriteOnce in the PersistentVolumeClaim
💡 Why This Matters
🌍 Real World
Dynamic provisioning allows Kubernetes to automatically create storage volumes when applications need them, saving manual setup time and reducing errors.
💼 Career
Understanding StorageClasses and PVCs is essential for Kubernetes administrators and DevOps engineers managing stateful applications in cloud environments.
Progress0 / 4 steps
1
Create the StorageClass manifest
Create a YAML manifest for a StorageClass named fast-storage with the provisioner set to kubernetes.io/aws-ebs.
Kubernetes
Need a hint?

The kind must be StorageClass. The metadata.name is fast-storage. The provisioner is kubernetes.io/aws-ebs. Add parameters: with type: gp2.

2
Create the PersistentVolumeClaim manifest
Create a YAML manifest for a PersistentVolumeClaim named fast-pvc that uses the StorageClass fast-storage.
Kubernetes
Need a hint?

The kind is PersistentVolumeClaim. The metadata.name is fast-pvc. Under spec, set storageClassName to fast-storage. Request 5Gi storage and use access mode ReadWriteOnce.

3
Apply the manifests to the cluster
Use the kubectl apply -f command to apply the YAML file containing both the StorageClass and PersistentVolumeClaim manifests.
Kubernetes
Need a hint?

Use kubectl apply -f storage.yaml to create the StorageClass and PersistentVolumeClaim in the cluster.

4
Verify the PersistentVolumeClaim status
Run the command kubectl get pvc fast-pvc to check the status of the PersistentVolumeClaim and print the output.
Kubernetes
Need a hint?

Run kubectl get pvc fast-pvc to see the status. The output should include the name fast-pvc and show its status like Bound.