Header Fragment
Logo

A career growth machine

Home Alumni Courses Simulators eBooks Audio Books Pricing Contact Us
× Login Home Alumni
⚡ Top Skills
Courses Simulators eBooks Audio Books Pricing Contact Us
FAQ

Unlimited Learning, One Price $299 / ₹23,999

All Content for $129 / ₹9,999 (3 Days Left)

Subscribe

Certified Kubernetes Administrator (CKA)

Download eBook in PDF format - Easy to follow • Step-by-step guidance

Storage - Understand Storage Classes and Persistent Volumes

  • Storage Classes:
    • Define storage provisioning parameters: Access modes, reclaim policy, storage type.
    • Used by users to request specific storage configurations.
  • Persistent Volumes (PVs):
    • Represent actual storage resources in the cluster.
    • Can be created manually or dynamically provisioned by Storage Classes.
  • Persistent Volume Claims (PVCs):
    • Requests for storage by Pods.
    • Specify storage requirements, like size and access mode.
    • Bound to PVs based on matching Storage Class and resource availability.
  • PV and PVC Binding:
    • PVCs are bound to PVs, effectively providing Pods access to persistent storage.
    • Binding ensures that Pods retain access to data even if the Pod is rescheduled to another node.
  • Dynamic Provisioning:
    • Allows PVs to be automatically created when PVCs are requested.
    • Simplify storage management and provide flexibility.

Storage Classes

Imagine you're ordering a pizza. You want to choose the size, the crust type, the toppings, etc. Storage Classes are like your pizza order for your Kubernetes storage. They let you define the exact type of storage you want for your applications.

Here's how they work:

  • Define Storage Provisioning Parameters:

    • You can specify things like:
      • Access Modes: How other parts of the cluster can access the storage (e.g., Read-Only, Read-Write-Once, Read-Write-Many). This is similar to choosing whether you want a pizza with just cheese or extra toppings.
      • Reclaim Policy: What happens to the storage when it's no longer needed. Do you want it to be deleted or kept around?
      • Storage Type: The underlying storage technology (e.g., standard disk, SSD, or a network file system). Think of this like selecting the crust type: thin crust, thick crust, deep dish.
  • Used by Users to Request Specific Storage Configurations:

    • When you need storage for your applications, you use a Storage Class to request the specific configuration you need. For example, you might want a Storage Class that provides SSD storage for a database, or a different Storage Class with standard disks for a web server.

Example

Let's imagine we have two Storage Classes:

  • "fast-disk": Provides SSD storage with Read-Write-Once access mode and a reclaim policy of 'Delete'. This is great for applications that need quick access to data, like databases.
  • "standard-disk": Provides standard disk storage with Read-Write-Once access mode and a reclaim policy of 'Retain'. This is a good choice for applications that don't require super-fast access, like web servers.

Code Example:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: fast-disk
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  encrypted: "true"
reclaimPolicy: Delete
accessModes:
  - ReadWriteOnce

This code defines a Storage Class called "fast-disk" using Amazon Elastic Block Storage (EBS). It specifies that it uses the gp2 storage type (SSD), is encrypted, and has a reclaim policy of "Delete".

Points to remember:

  • Storage Classes are essential for defining storage configurations in Kubernetes.
  • You can have multiple Storage Classes, each with different configurations.
  • Storage Classes make it easy to request and use the right type of storage for your applications.

Multiple-Choice Questions:

1. What is a Storage Class used for in Kubernetes?

* A. It defines the size of the storage volume you need.
* B. It defines the network bandwidth for your pods.
* C. **It defines the provisioning parameters for your storage volumes.** 
* D. It defines the number of pods that can access a particular storage volume.

**Reason:** Storage Classes define the overall characteristics of a storage volume, not just its size or access. 

2. You are deploying a database application that requires fast access to data. Which of the following Storage Class parameters would be most relevant in this scenario?

* A. Reclaim Policy
* B. Access Mode
* C. **Storage Type**
* D. Provisioner

**Reason:** The storage type directly impacts performance. Choosing a Storage Class with SSDs will provide faster access. 

3. You have a Storage Class defined with a reclaim policy of "Delete". What happens when a Persistent Volume Claim (PVC) using this Storage Class is deleted?

* A. The PVC is deleted, but the underlying storage volume persists.
* B. **The PVC and the underlying storage volume are deleted.**
* C. The PVC is deleted, and the underlying storage volume is archived.
* D. The PVC is deleted, and the underlying storage volume is made available for other PVCs.

**Reason:**  A reclaim policy of "Delete" means that the underlying storage volume is removed when the PVC is deleted.

4. You have a Storage Class called "standard-disk" defined with a provisioner of "kubernetes.io/gce-pd". Which cloud provider does this Storage Class likely target?

* A. Amazon Web Services (AWS)
* B. Microsoft Azure
* C. **Google Cloud Platform (GCP)**
* D. OpenStack

**Reason:**  The provisioner "kubernetes.io/gce-pd" is specific to Google Cloud Platform's Persistent Disks.

5. You have a Storage Class defined with an access mode of "ReadWriteOnce". Which of the following scenarios is NOT possible with this Storage Class?

* A. A single pod mounts the storage volume.
* B. Multiple pods mount the storage volume, but only one can write to it at a time.
* C. **Multiple pods can mount the storage volume and write to it concurrently.** 
* D. A pod mounts the storage volume in read-only mode.

**Reason:** ReadWriteOnce means that only one pod can write to the volume at a time, preventing concurrent writes from multiple pods.

Certified Kubernetes Administrator (CKA)

Book Cover
Chapter 4: Storage-Know how to configure applications with persistent storage
Chapter 11: Workloads & Scheduling-Understand deployments and how to perform rolling update and rollbacks
Chapter 14: Workloads & Scheduling-Understand the primitives used to create robust, self-healing, application deployments
Chapter 16: Workloads & Scheduling-Awareness of manifest management and common templating tools
Chapter 17: Cluster Architecture, Installation & Configuration-Manage role based access control (RBAC)
Chapter 18: Cluster Architecture, Installation & Configuration-Use Kubeadm to install a basic cluster
Chapter 23: Services & Networking-Understand host networking configuration on the cluster nodes
Chapter 26: Services & Networking-Know how to use Ingress controllers and Ingress resources