可以使用对 pv 打 label 的方式,具体如下:

$ cat nfs-pv2.yaml 
apiVersion: v1
kind: PersistentVolume # PV是全局概念,不用设置namespace
metadata:
  name: nfs-pv2
  namespace: chenqiang-pv-test
  labels:
    pv: nfs-pv2
spec:
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteMany
  nfs:
    # FIXME: use the right IP
    server: 10.130.44.20
    path: "/test/mysql-nfs01"

创建 pvc,使用 matchLabel 来关联刚创建的 pv:nfs-pv2

$ cat nfs-pvc2.yaml   
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc2
  namespace: chenqiang-pv-test
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: ""
  resources:
    requests:
      storage: 90Mi
  selector:
    matchLabels:
      pv: nfs-pv2

相关文章:

  • 2022-12-23
  • 2021-12-06
  • 2021-09-12
  • 2021-12-13
  • 2021-12-08
  • 2022-01-10
  • 2022-12-23
猜你喜欢
  • 2021-06-12
  • 2022-01-18
  • 2022-12-23
  • 2021-11-04
  • 2021-06-12
  • 2022-12-23
  • 2021-12-26
相关资源
相似解决方案