题目主干
Task

创建名为 app-config 的 persistent volume,容量为 1Gi,访问模式为 ReadWriteMany。
volume 类型为 hostPath,位于 /srv/app-config

参考说明

https://kubernetes.io/zh/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolume

PV是全局的概念,创建时不需要指定namespae

题目解答

创建文件pv.yaml,文件内容

  1. apiVersion: v1
  2. kind: PersistentVolume
  3. metadata:
  4. name: app-config
  5. spec:
  6. capacity:
  7. storage: 1Gi
  8. accessModes:
  9. - ReadWriteMany
  10. hostPath:
  11. path: "/srv/app-config"
  1. student@master01:~$ kubectl apply -f pv.yaml
  2. persistentvolume/app-config created
  3. student@master01:~$ kubectl get pv
  4. NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
  5. app-config 1Gi RWX Retain Available 3s
  6. pv01 10Mi RWO Retain Available csi-hostpath-sc 70d
  7. student@master01:~$