Lab: CKA Mock Exam 2:SECTION: STORAGE

Hi Team,

Good Day…

While attending an CKA Mock exam in the " Ultimate Certified Kubernetes Admistrator series" Mock Exam-2 in storage section the below is question and tried to fix but unfortunately getting the wrong storage size from PVC.

Question:
Create a storage class called orange-stc-cka07-str as per the properties given below:

- Provisioner should be kubernetes.io/no-provisioner .

- Volume binding mode should be WaitForFirstConsumer .

Next, create a persistent volume called orange-pv-cka07-str as per the properties given below:

- Capacity should be 150Mi .

- Access mode should be ReadWriteOnce .

- Reclaim policy should be Retain .

- It should use storage class orange-stc-cka07-str .

- Local path should be /opt/orange-data-cka07-str .

- Also add node affinity to create this value on cluster1-controlplane .

Finally, create a persistent volume claim called orange-pvc-cka07-str as per the properties given below:

- Access mode should be ReadWriteOnce .

- It should use storage class orange-stc-cka07-str .

- Storage request should be 128Mi .

- The volume should be orange-pv-cka07-str .

Ans in the Yaml file:

Storage Class:

student-node ~ ➜ cat storage-class.yaml

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: orange-stc-cka07-str
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain # default value is Delete
volumeBindingMode: WaitForFirstConsumer

PV:

student-node ~ ➜ cat pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: orange-pv-cka07-str
spec:
  capacity:
    storage: 150Mi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: orange-stc-cka07-str
  local:
    path: /opt/orange-data-cka07-str
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - cluster1-controlplane

PVC:
student-node ~ ➜ cat pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: orange-pvc-cka07-str
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 128Mi
  storageClassName: orange-stc-cka07-str
  volumeName: orange-pv-cka07-str

Output from the Terminal:

student-node ~ ➜ k get storageclasses.storage.k8s.io orange-stc-cka07-str
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
orange-stc-cka07-str kubernetes.io/no-provisioner Retain WaitForFirstConsumer false 13m

student-node ~ ➜ k get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS VOLUMEATTRIBUTESCLASS REASON AGE
orange-pv-cka07-str 150Mi RWO Retain Bound default/orange-pvc-cka07-str orange-stc-cka07-str 9m6s

student-node ~ ➜ k get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
orange-pvc-cka07-str Bound orange-pv-cka07-str 150Mi RWO orange-stc-cka07-str 6m20s

Not wrong – just true due to the persistent volume that the PVC bound. The PVC requested 128Mi, but once it binds a PV with a capacity of 150Mi, it gets the whole volume. So while it requested 128Mi, it got 150Mi. This is correct behavior. Note that your YAML probably passed the grader, as well.

Hi @rob,

Thank you but could you please confirm, assume that the PV size is 1GB but the pvc size is 500Mi then pvc size will be 500Mi or 1GB.

once it binds, it will be equal to the PV, or 1G

1 Like