0
0
Kubernetesdevops~20 mins

PersistentVolume (PV) definition in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PersistentVolume Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of kubectl get pv command
You have created a PersistentVolume (PV) in Kubernetes with the following YAML. What will be the output of kubectl get pv after applying this configuration?
Kubernetes
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-example
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /mnt/data
AError from server (NotFound): persistentvolumes "pv-example" not found
B
NAME         CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
pv-example   5Gi        RWX            Delete           Available           standard      1m
C
NAME         CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
pv-example   5Gi        RWO            Retain           Available           <unset>      1m
D
NAME         CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
pv-example   5Gi        RWO            Retain           Bound               standard      1m
Attempts:
2 left
💡 Hint
Check the persistentVolumeReclaimPolicy and status fields after creation.
🧠 Conceptual
intermediate
1:30remaining
Understanding PersistentVolume reclaim policies
Which reclaim policy for a PersistentVolume causes the volume to be deleted automatically when the PersistentVolumeClaim is deleted?
AArchive
BRecycle
CRetain
DDelete
Attempts:
2 left
💡 Hint
Think about what happens to the storage after the claim is removed.
Configuration
advanced
2:30remaining
Correct PersistentVolume YAML for NFS storage
Which of the following PersistentVolume YAML snippets correctly defines a PV using NFS storage with 10Gi capacity and ReadWriteMany access mode?
A
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-nfs
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 10.0.0.1
  persistentVolumeReclaimPolicy: Retain
B
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-nfs
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  nfs:
    path: /exported/path
    server: 10.0.0.1
  persistentVolumeReclaimPolicy: Retain
C
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-nfs
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadOnlyMany
  hostPath:
    path: /exported/path
  persistentVolumeReclaimPolicy: Retain
D
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-nfs
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  nfs:
    path: /exported/path
    server: 10.0.0.1
  persistentVolumeReclaimPolicy: Delete
Attempts:
2 left
💡 Hint
Check the access mode and the storage type fields carefully.
Troubleshoot
advanced
2:00remaining
Troubleshooting PV binding failure
A PersistentVolumeClaim (PVC) requesting 20Gi with access mode ReadWriteOnce is stuck in Pending state. The cluster has a PV with 10Gi capacity and access mode ReadWriteOnce. What is the most likely reason the PVC is not binding?
AThe PV capacity is less than the PVC requested size
BThe PV access mode does not match the PVC access mode
CThe PV reclaim policy is set to Retain
DThe PV is already bound to another PVC
Attempts:
2 left
💡 Hint
Check if the PV can satisfy the PVC size requirement.
Best Practice
expert
1:30remaining
Best practice for PersistentVolume naming and labels
Which of the following is the best practice when defining PersistentVolumes in a production Kubernetes cluster to facilitate management and selection by PersistentVolumeClaims?
AUse descriptive names and add labels that indicate storage type and environment
BUse random UUIDs as names and avoid labels to keep PVs simple
CName PVs after the node they are on and do not use labels
DUse numeric names and label PVs only with reclaim policy
Attempts:
2 left
💡 Hint
Think about how labels help in selecting PVs for PVCs.