exam questions

Exam CKA All Questions

View all questions & answers for the CKA exam

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 (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
fc146fc
Highly Voted 10 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 7 times
...
noahsark
Most Recent 1 month, 3 weeks ago
killer_sh_lab part3: Note, doesn’t work: waiting for external controller to expand this PVC
upvoted 1 times
...
noahsark
1 month, 3 weeks ago
killer_sh_lab part2: vi web-server.yml apiVersion: v1 kind: Pod metadata: name: web-server spec: volumes: - name: task-pv-storage persistentVolumeClaim: claimName: pv-volume containers: - name: web-server image: nginx volumeMounts: - mountPath: "/usr/share/nginx/html" name: task-pv-storage k apply -f web-server.yml k get pvc pv-volume -o json | jq -c 'paths|join(".")' k patch -h k patch pvc pv-volume -p '{"spec":{"resources":{"requests":{"storage":"20Mi"}}}}' --record # or # update yml k apply -f pv-volume.yml --record
upvoted 1 times
...
noahsark
1 month, 3 weeks ago
killer_sh_lab part 1: Note: Storage Class was changed to local-path (default) for testing purposes. # add allowVolumeExpansion: true # example apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: local-path provisioner: rancher.io/local-path allowVolumeExpansion: true vi pv-volume.yml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pv-volume spec: storageClassName: local-path accessModes: - ReadWriteOnce resources: requests: storage: 10Mi k apply -f pv-volume.yml
upvoted 1 times
...
Jamshif01
2 months ago
kubectl edit pvc pv-volume --record
upvoted 1 times
...
taod
3 months, 2 weeks ago
I got this question today in exam with these YAMls as mentioned @fc146fc but either pod or PVC was always in Pending state. Since I solved all other questions and only 10 minutes left and I wanted to go toilet so much, so I ended the exam. I am not sure why it was in pending state, maybe because I put storageClassName in double quotes like this dunno: storageClassName: "csi-hostpath-sc"
upvoted 1 times
...
LavaPup
1 year, 2 months 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
1 year, 3 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
1 year, 4 months 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
Jamshif01
2 months, 1 week ago
how do you memorize after -p I can't find kubernetes doc for this path.
upvoted 1 times
...
Portman
1 year, 2 months ago
i think its k patch pvc pv-volume -p '{"spec":{"resources":{"requests":{"storage":"70Mi"}}}}' --record
upvoted 1 times
...
...
shedyb
1 year, 5 months 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 3 times
...
iiiaz
1 year, 5 months 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
1 year, 6 months 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
1 year, 6 months 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
1 year, 5 months 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
11 months, 1 week ago
Yea when you 'get' the storageclass you can see if expansion has been enabled
upvoted 1 times
...
...
...
leebug
1 year, 6 months 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
1 year, 7 months ago
I have notice, PV was not created In the exam, without PV how can we create PVC directly ?
upvoted 2 times
iiiaz
1 year, 5 months 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
1 year, 5 months 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago