Hi Team, please I need clarification on what I did wrong here:
Solve this question on: ssh cluster1-controlplane
A storage class called coconut-stc-cka01-str was created earlier.
Use this storage class to create a persistent volume called
coconut-pv-cka01-str as per below requirements:
- Capacity should be 100Mi.
- The volume type should be hostpath and the path
should be /opt/coconut-stc-cka01-str.
- Use coconut-stc-cka01-str storage class.
- This volume must be created on cluster1-node01
(the /opt/coconut-stc-cka01-str directory already exists on this node).
- It must have a label with key: storage-tier with value: gold.
Also, create a persistent volume claim with the name
coconut-pvc-cka01-str as per the below specs:
- Request 50Mi of storage from coconut-pv-cka01-str
PV. It must use matchLabels to use the PV.
- Use coconut-stc-cka01-str storage class.
- The access mode must be ReadWriteMany.
Ultimately, the examiner didn’t like my PVC. I cross-checked with the provided solution but it is a match (in my eyes, anyway…lol). I’ll provide examiner’s solution and mine below.
Examiner’s solution for the PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: coconut-pvc-cka01-str
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Mi
storageClassName: coconut-stc-cka01-str
selector:
matchLabels:
storage-tier: gold
My solution for the PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: coconut-pv-cka01-str
spec:
storageClassName: coconut-stc-cka01-str
selector:
matchLabels:
storage-tier: gold
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Mi
My kubectl get pvc output:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"coconut-pv-cka01-str","namespace":"default"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"50Mi"}},"selector":{"matchLabels":{"storage-tier":"gold"}},"storageClassName":"coconut-stc-cka01-str"}}
creationTimestamp: "2025-05-09T21:40:44Z"
finalizers:
- kubernetes.io/pvc-protection
name: coconut-pv-cka01-str
namespace: default
resourceVersion: "10575"
uid: 062f44c5-cdb8-4971-b173-60d4a74fd027
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Mi
selector:
matchLabels:
storage-tier: gold
storageClassName: coconut-stc-cka01-str
volumeMode: Filesystem
status:
phase: Pending
Also the reason it says pending
under status is because the storage class is “waitforfirstconsumer” and no pod is utilizing it.
the results of the examination are:
Is PV created correctly?
Is PVC created correctly?
Please help.
Thank you so much.
Ola