1.题目
There is a persistent volume name dev-pv in the cluster, create a persistent volume claim name dev-pvc, make sure this persistent volume claim will bound the persistent volume, and then create a pod name test-pvc that mount this pvc at path /tmp/data, use nginx image.
2.解析
3.答案
查看已存在pv dev-pv的信息
kubectl get pv dev-pv -oyamlkubectl describe pv dev-pv
拷贝官方文档pvc.yaml,根据已存在pv信息accessModes=ReadWriteOnce, capacity.storage=1Gi修改后创建
apiVersion: v1kind: PersistentVolumeClaimmetadata:name: dev-pvcspec:accessModes:- ReadWriteOnceresources:requests:storage: 1Gi
# 创建pvckubectl apply -f pvc.yaml# 查看该pvc是否绑定kubectl get pvc
创建pod,拷贝官方文档test-pvc.yaml,根据题意修改yaml
apiVersion: v1kind: Podmetadata:name: test-pvcspec:containers:- name: nginximage: nginxvolumeMounts:- mountPath: "/tmp/data"name: dev-pvcvolumes:- name: dev-pvcpersistentVolumeClaim:claimName: dev-pvc
# 创建podkubectl apply -f test-pvc.yaml
https://kubernetes.io/zh/docs/concepts/storage/persistent-volumes/
