CKA 模拟真题 Killer.sh | Question 6 | Storage, PV, PVC, Pod volume
Use context: kubectl config use-context k8s-c1-H
Create a new PersistentVolume named safari-pv . It should have a capacity of 2Gi , accessMode ReadWriteOnce , hostPath /Volumes/Data and no storageClassName defined.
Next create a new PersistentVolumeClaim in Namespace project-tiger named safari-pvc . It should request 2Gi storage, accessMode ReadWriteOnce and should not define a storageClassName. The PVC should bound to the PV correctly.
Finally create a new Deployment safari in Namespace project-tiger which mounts that volume at /tmp/safari-data . The Pods of that Deployment should be of image httpd:2.4.41-alpine .
译文
创建一个新的PersistentVolume,名为 safari-pv 。它的容量为 2Gi ,访问模式为 ReadWriteOnce ,主机路径为 /Volumes/Data ,不定义存储类别名称。
接下来在namespace project-tiger创建一个新的 PersistentVolumeClaim ,命名为 safari-pvc 。它应该请求 2Gi 存储,访问模式 ReadWriteOnce ,并且不应该定义存储类名称。PVC应该正确地绑定到PV上。
最后在名字空间 project-tiger 中创建一个新的部署 safari ,将该卷挂载在 /tmp/safari-data 。该部署Pod的镜像是 httpd:2.4.41-alpine
解答
vim 6_pv.yaml |
6_pv.yaml
# 6_pv.yaml |
创建pv
k -f 6_pv.yaml |
vim 6_pvc.yaml |
6_pvc.yaml
# 6_pvc.yaml |
创建pvc
k -f 6_pvc.yaml create |
检查pv,pvc绑定情况
k -n project-tiger get pv,pvc |
创建一个部署并挂载卷,可以参考
https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-pod
k -n project-tiger create deploy safari \ |
6_dep.yaml
apiVersion: apps/v1 |
创建pod
k -f 6_dep.yaml create |
检查pod挂载情况
k -n project-tiger describe pod safari-xxx-xxx | grep -i -A2 mounts |



