Useful Resources: Persistent Volumes Claim
题干
For this question, please set this context (In exam, diff cluster name)
kubectl config use-context kubernetes-admin@kubernetes
A persistent volume named red-pv-cka is available. Your task is to create a PersistentVolumeClaim (PVC) named red-pvc-cka and request 30Mi of storage from the red-pv-cka PersistentVolume (PV).
Ensure the following criteria are met:
- Access mode: ReadWriteOnce
- Storage class: manual
解题思路
- 切换集群环境
kubectl config use-context kubernetes-admin@kubernetes
- 编写pvc资源清单,内容如下:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:name: red-pvc-cka
spec:accessModes: - ReadWriteOncevolumeName: red-pv-ckastorageClassName: manualresources:requests: storage: 30Mi
善于利用
kubectl explain pvc
查看资源清单需要的参数
- 提交资源清单
controlplane $ k apply -f red-pvc-cka.yaml
persistentvolumeclaim/red-pvc-cka created
- 查看pvc资源创建情况
controlplane $ k get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
red-pvc-cka Bound red-pv-cka 50Mi RWO manual <unset> 4s