Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam CKA topic 1 question 16 discussion

Actual exam question from CNCF's CKA
Question #: 16
Topic #: 1
[All CKA Questions]

SIMULATION -


Task -
Create a new PersistentVolumeClaim:
✑ Name: pv-volume
✑ Class: csi-hostpath-sc
✑ Capacity: 10Mi
Create a new Pod which mounts the PersistentVolumeClaim as a volume:
✑ Name: web-server
✑ Image: nginx
✑ Mount path: /usr/share/nginx/html
Configure the new Pod to have ReadWriteOnce access on the volume.
Finally, using kubectl edit or kubectl patch expand the PersistentVolumeClaim to a capacity of 70Mi and record that change.

Show Suggested Answer Hide Answer
Suggested Answer:


















Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
fc146fc
2 months, 2 weeks ago
Create a pvc.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pv-volume spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Mi storageClassName: csi-hostpath-sc kubectl create -f pvc.yaml Configure the new Pod to have ReadWriteOnce access on the volume. apiVersion: v1 kind: Pod metadata: name: web-server spec: containers: - name: web-server image: nginx volumeMounts: - mountPath: "/usr/share/nginx/html " name: pv-volume volumes: - name: pv-volume persistentVolumeClaim: claimName: pv-volume k patch pvc pv-volume -p '{"spec":{"resources":{"requests":{"storage":"70Mi"}}}}' --record
upvoted 4 times
...
LavaPup
6 months, 2 weeks ago
@dim11 - You are correct. In my local, I am getting the same error when creating the web-server pod. I do not have storageclass, do I have to create one? If yes, what should be the provider? Any help is appreciated
upvoted 1 times
...
dim11
8 months ago
When i try it in home environment i am getting follwing when i create pvc " storageclass.storage.k8s.io "csi-hostpath-sc" not found". And thats why pvc is in pending state. In exam is the storageclass already existing or do we have to troubleshoot it ourselves?
upvoted 2 times
...
dav_yip
8 months, 2 weeks ago
Please note that the last part of the question is to expand the PersistentVolumeClaim and record that change. The "--record" will be required otherwise we will not be able to fulfill the record requirement. # k patch pv-volume -p '{"spec":{"resources":{"requests":{"storage":"70Mi"}}}}' --record
upvoted 3 times
Portman
6 months, 2 weeks ago
i think its k patch pvc pv-volume -p '{"spec":{"resources":{"requests":{"storage":"70Mi"}}}}' --record
upvoted 1 times
...
...
shedyb
9 months, 1 week ago
You PVC should be apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pv-volume spec: storageClassName: csi-hostpath-sc accessModes: - ReadWriteOnce resources: requests: storage: 10Mi and your pod can be like this: apiVersion: v1 kind: Pod metadata: name: web-server spec: containers: - name: nginx-container image: nginx volumeMounts: - name: pv-volume mountPath: /usr/share/nginx/html volumes: - name: pv-volume persistentVolumeClaim: claimName: pv-volume Check the stirage class already existing to ensure it allowVolumeExpansion: true , if it does, eidt it to have this attribute
upvoted 2 times
...
iiiaz
9 months, 2 weeks ago
@leebug: Related to your error "I'm getting an error "could not be patched" when increasing the storage to 70MB", where do you practice this? In your home lab or Udemy Kodekloud labs? Maybe the storage class "Class: csi-hostpath-sc" is not configured in your environment as in the CKA exam.
upvoted 1 times
...
leebug
10 months, 4 weeks ago
I'm getting an error "could not be patched" when increasing the storage to 70MB k edit pvc pv-volume --save-config error: persistentvolumeclaims "pv-volume" could not be patched: persistentvolumeclaims "pv-volume" is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize You can run `kubectl replace -f /tmp/kubectl-edit-777230424.yaml` to try this update again.
upvoted 1 times
leebug
10 months, 3 weeks ago
just realised you will need to have a storage class " csi-hostpath-sc" created with allowVolumeExpansion: true (See https://kubernetes.io/docs/concepts/storage/storage-classes/) #csi-hostpath-sc.yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: csi-hostpath-sc provisioner: vendor-name.example/magicstorage parameters: resturl: "http://192.168.10.100:8080" restuser: "" secretNamespace: "" secretName: "" allowVolumeExpansion: true
upvoted 2 times
real111
9 months, 4 weeks ago
There in requirements are mention class name - i would think that this is storage class what is created in exam env, if we add it to pod spec and in that class there expansion is set to true , then it should be possible to expend,no?
upvoted 1 times
Jibbajabba
3 months, 2 weeks ago
Yea when you 'get' the storageclass you can see if expansion has been enabled
upvoted 1 times
...
...
...
leebug
10 months, 3 weeks ago
I'm also getting the same error when trying to increase the Storage size on the PVC using the command below: k edit pvc pv-volume error: persistentvolumeclaims "pv-volume" could not be patched: persistentvolumeclaims "pv-volume" is forbidden: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize
upvoted 1 times
...
...
mrallrounder123453656
11 months, 2 weeks ago
I have notice, PV was not created In the exam, without PV how can we create PVC directly ?
upvoted 2 times
iiiaz
9 months, 2 weeks ago
From your solution screenshots, you listed pv, pvc with no results. Then you created the pvc only. Then list pv, pvc again and they show both. It means pv was dynamically provisioned. This seems to be the explanation: https://stackoverflow.com/questions/56450272/can-we-get-persistent-volume-with-only-pvc-without-pv-in-k8s
upvoted 1 times
...
real111
9 months, 4 weeks ago
I think you can use claims as values https://kubernetes.io/docs/concepts/storage/persistent-volumes/ (search claim as value)
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...