@Mumshad Mannambeth and @Tej_Singh_Rana <https://beta.kodekloud.com/topic/mock-e . . .

Malayamanas Panda:
@Mumshad Mannambeth and @Tej_Singh_Rana https://beta.kodekloud.com/topic/mock-exam-2-4/

QUIZ#4

A pod definition file is created at /root/CKA/use-pv.yaml. Make use of this manifest file and mount the persistent volume called pv-1. Ensure the pod is running and the PV is bound.

mountPath: /data persistentVolumeClaim Name: my-pvc

Weight: 12

persistentVolume Claim configured correctly
pod using the correct mountPath
pod using the persistent volume claim

controlplane $ cat pvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 10Mi
storageClassName: slow

controlplane $ k get pv pv-1
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pv-1 10Mi RWO Retain Released default/my-pvc slow 32m
controlplane $ k get pv pv-1 -o yaml
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
http://pv.kubernetes.io/bound-by-controller|pv.kubernetes.io/bound-by-controller: “yes”
creationTimestamp: “2021-06-17T09:11:30Z”
finalizers:

  • http://kubernetes.io/pv-protection|kubernetes.io/pv-protection
    managedFields:
  • apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
    f:spec:
    f:accessModes: {}
    f:capacity:
    .: {}
    f:storage: {}
    f:hostPath:
    .: {}
    f:path: {}
    f:type: {}
    f:persistentVolumeReclaimPolicy: {}
    f:volumeMode: {}
    manager: python-requests
    operation: Update
    time: “2021-06-17T09:11:30Z”
  • apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
    f:metadata:
    f:annotations:
    .: {}
    f:http://pv.kubernetes.io/bound-by-controller|pv.kubernetes.io/bound-by-controller: {}
    f:spec:
    f:claimRef:
    .: {}
    f:apiVersion: {}
    f:kind: {}
    f:name: {}
    f:namespace: {}
    f:resourceVersion: {}
    f:uid: {}
    manager: kube-controller-manager
    operation: Update
    time: “2021-06-17T09:30:47Z”
  • apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
    f:spec:
    f:storageClassName: {}
    f:status:
    f:phase: {}
    manager: kubectl-edit
    operation: Update
    time: “2021-06-17T09:37:43Z”
    name: pv-1
    resourceVersion: “10888”
    selfLink: /api/v1/persistentvolumes/pv-1
    uid: a7ef89d7-f920-4833-9420-fec56d1caefc
    spec:
    accessModes:
  • ReadWriteOnce
    capacity:
    storage: 10Mi
    claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: my-pvc
    namespace: default
    resourceVersion: “8671”
    uid: cc160b37-0972-4f6e-9f68-09a4366ec1cf
    hostPath:
    path: /opt/data
    type: “”
    persistentVolumeReclaimPolicy: Retain
    storageClassName: slow
    volumeMode: Filesystem
    status:
    phase: Released
    controlplane $ k describe pvc my-pvc
    Name: my-pvc
    Namespace: default
    StorageClass: slow
    Status: Pending
    Volume:
    Labels: <none>
    Annotations: <none>
    Finalizers: [http://kubernetes.io/pvc-protection|kubernetes.io/pvc-protection]
    Capacity:
    Access Modes:
    VolumeMode: Filesystem
    Mounted By: use-pv
    Events:
    Type Reason Age From Message

Warning ProvisioningFailed 4s (x17 over 4m4s) persistentvolume-controller http://storageclass.storage.k8s.io|storageclass.storage.k8s.io “slow” not found
controlplane $

controlplane $ cat CKA/use-pv.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: use-pv
name: use-pv
spec:
containers:

  • image: nginx
    name: use-pv
    volumeMounts:
    • mountPath: “/data”
      name: mypd
      volumes:
    • name: mypd
      persistentVolumeClaim:
      claimName: my-pvc

controlplane $ kubectl get storageclass -A
No resources found

controlplane $

controlplane $ cat pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 10Mi
storageClassName: slow
controlplane $ k get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
my-pvc Pending slow 7m37s
controlplane $ k get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pv-1 10Mi RWO Retain Released default/my-pvc slow 36m
controlplane $ k get pod
redis-storage super-user-pod use-pv
controlplane $ k get pod use-pv
NAME READY STATUS RESTARTS AGE
use-pv 0/1 Pending 0 9m14s

controlplane $ k describe po use-pv
Name: use-pv
Namespace: default
Priority: 0
Node: <none>
Labels: run=use-pv
Annotations: <none>
Status: Pending
IP:
IPs: <none>
Containers:
use-pv:
Image: nginx
Port: <none>
Host Port: <none>
Environment: <none>
Mounts:
/data from mypd (rw)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-9h6xv (ro)
Conditions:
Type Status
PodScheduled False
Volumes:
mypd:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: my-pvc
ReadOnly: false
default-token-9h6xv:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-9h6xv
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: http://node.kubernetes.io/not-ready:NoExecute|node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
http://node.kubernetes.io/unreachable:NoExecute|node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message


Warning FailedScheduling 8m29s (x2 over 8m29s) default-scheduler persistentvolumeclaim “my-pvc” is being deleted
Warning FailedScheduling 56s (x9 over 9m38s) default-scheduler 0/2 nodes are available: 2 pod has unbound immediate PersistentVolumeClaims.

Malayamanas Panda:
@Mumshad Mannambeth @Tej_Singh_Rana Why there is no DEFAULT storageClass ?

Tej_Singh_Rana:
Why do we need it?

Malayamanas Panda:
@Tej_Singh_Rana I am getting no SC in already created PV , namely pv-1 . If there is no SC defined in PV, then what should be SC defined in PVC ? I tried to modify PV with SC of slow and manual, then changed the same with PVC . But PVC could not claim the PV. Please refer to screenshot .


Malayamanas Panda:
OK, without giving any storage class , it works.

Tej_Singh_Rana:
If there is no SC then don’t specify.

jumble:
thanks for sharing here even I was stuck with that question, Thanks a lot guys @Malayamanas Panda @Tej_Singh_Rana