All exams← All Certified Kubernetes Administrator (CKA) notes

Storage: Certified Kubernetes Administrator (CKA) revision notes

Revision notes

## Kubernetes Storage Overview

Kubernetes abstracts underlying storage with PersistentVolumes (PVs), PersistentVolumeClaims (PVCs), and StorageClasses, crucial for stateful applications.

## PersistentVolumes (PVs)

A PersistentVolume (PV) is a cluster-wide storage resource, provisioned by an administrator or dynamically. It represents actual storage (e.g., NFS, cloud disks) and is independent of Pods. PVs define access modes and a reclaim policy.

## PersistentVolumeClaims (PVCs)

A PersistentVolumeClaim (PVC) is a user's request for storage. Kubernetes binds a PVC to an available PV that matches its requirements (size, access mode). If no suitable PV exists, the PVC remains pending or triggers dynamic provisioning.

## StorageClasses & Dynamic Provisioning

A StorageClass defines a "class" of storage, specifying a provisioner (e.g., `kubernetes.io/aws-ebs`) and parameters. It enables dynamic provisioning: when a PVC requests a StorageClass, the provisioner automatically creates a new PV on the backend storage to fulfill the claim, automating storage setup.

## Access Modes & Reclaim Policy

Access Modes dictate how storage can be mounted:

  • ReadWriteOnce (RWO): Mounted read-write by a single node.
  • ReadOnlyMany (ROX): Mounted read-only by many nodes.
  • ReadWriteMany (RWX): Mounted read-write by many nodes (e.g., NFS).

The Reclaim Policy defines PV behavior after its PVC is deleted:

  • Retain: PV and data preserved; manual cleanup required. Safest for data.
  • Delete: Underlying storage asset and PV are deleted. Common with dynamic provisioning.

## Using Storage in Pods

Pods use persistent storage by referencing a PVC in their `volumes` section and then mounting that volume into containers via `volumeMounts`. The Pod interacts with the PVC, which is bound to a PV.

```yaml

apiVersion: v1

kind: Pod

metadata:

name: my-app

spec:

containers:

  • name: my-container

image: nginx

volumeMounts:

  • name: my-storage

mountPath: /data

volumes:

  • name: my-storage

persistentVolumeClaim:

claimName: my-pvc

```

Key facts

Flashcards

What is a PersistentVolume (PV)?
A cluster-wide resource representing a piece of storage provisioned for use by Kubernetes.
tap to reveal
What is a PersistentVolumeClaim (PVC)?
A request for storage by a user, which binds to an available PersistentVolume (PV).
tap to reveal
What is the primary purpose of a StorageClass?
To define classes of storage and enable dynamic provisioning of PersistentVolumes (PVs).
tap to reveal
Name the three main Access Modes for PersistentVolumes.
ReadWriteOnce (RWO), ReadOnlyMany (ROX), ReadWriteMany (RWX).
tap to reveal
What is the "Retain" reclaim policy for a PV?
The PV and its data are preserved after the PVC is deleted, requiring manual cleanup.
tap to reveal
How does a Pod specify that it wants to use persistent storage?
By referencing a PersistentVolumeClaim (PVC) in its `volumes` section.
tap to reveal
What is dynamic provisioning in Kubernetes storage?
The automatic creation of a PersistentVolume (PV) by a StorageClass provisioner when a PVC requests storage.
tap to reveal
What happens if a PVC cannot find a suitable PV to bind to?
The PVC will remain in a "Pending" state until a matching PV becomes available or is dynamically provisioned.
tap to reveal
Practice questions

Storage: 5 practice questions

Q1. A developer needs to provide persistent storage for a Pod. Which Kubernetes object is referenced in the Pod's `volumes` section to request storage that is independent of the Pod's lifecycle?
  • A.  PersistentVolume
  • B.  StorageClass
  • C.  PersistentVolumeClaim
  • D.  ConfigMap
Show answer & explanation
✓ Answer: C. PersistentVolumeClaim
A Pod uses a PersistentVolumeClaim (PVC) to request and mount storage. The PVC is an abstract request that gets fulfilled by a PersistentVolume (PV).
Q2. You are configuring a PersistentVolume (PV) that must be mountable as read-write by only a single node at a time. Which `accessMode` should you specify?
  • A.  ReadWriteOncePod
  • B.  ReadOnlyMany
  • C.  ReadWriteMany
  • D.  ReadWriteOnce
Show answer & explanation
✓ Answer: D. ReadWriteOnce
`ReadWriteOnce` (RWO) allows the volume to be mounted as read-write by a single node. This is a common access mode for block storage like AWS EBS or GCE Persistent Disk.
Q3. A PersistentVolume (PV) has its `persistentVolumeReclaimPolicy` set to `Delete`. What happens to the underlying physical storage when the associated PersistentVolumeClaim (PVC) is deleted?
  • A.  Both the PV object and the underlying physical storage are deleted.
  • B.  The PV object is deleted, but the physical storage remains.
  • C.  The PV object enters a 'Failed' state, requiring manual cleanup.
  • D.  The physical storage is deleted, but the PV object becomes 'Available'.
Show answer & explanation
✓ Answer: A. Both the PV object and the underlying physical storage are deleted.
The `Delete` reclaim policy instructs the volume plugin to delete both the PV Kubernetes object and the associated storage asset in the external infrastructure (e.g., the EBS volume).
Q4. A StorageClass is configured with `volumeBindingMode: WaitForFirstConsumer`. When will the PersistentVolume (PV) be provisioned and bound to the PersistentVolumeClaim (PVC)?
  • A.  After the PVC has been manually approved by an administrator.
  • B.  When the StorageClass is first created by the administrator.
  • C.  Only after a Pod that uses the PVC is scheduled to a node.
  • D.  Immediately after the PVC is created.
Show answer & explanation
✓ Answer: C. Only after a Pod that uses the PVC is scheduled to a node.
`WaitForFirstConsumer` delays PV binding and provisioning until a Pod using the PVC is scheduled. This allows the scheduler to make intelligent decisions based on node topology.
Q5. To enable online resizing of a PersistentVolumeClaim, what field must be set to `true` in the corresponding StorageClass definition?
  • A.  allowVolumeExpansion
  • B.  enableVolumeResizing
  • C.  volumeExpansionEnabled
  • D.  resizable
Show answer & explanation
✓ Answer: A. allowVolumeExpansion
The `allowVolumeExpansion` field in a StorageClass must be set to `true` to permit users to resize PVCs that are provisioned by that class.
Test yourself
See the Certified Kubernetes Administrator (CKA) page

More Certified Kubernetes Administrator (CKA) topics