天天看點

pvc yaml示例

vi pcv-volume.yaml

apiVersion: v1

kind: PersistentVolumeClaim

metadata:

    name: pvc-volume

spec:

    accessModes:

        - ReadWriteOnce

    resources:

       requests:

          storage: 1Gi

   storageClassName:csi-host-sc

:wq

kubectl apply -f pvc-volume.yaml

修改大小(--record=true表示記錄修改曆史):

kubectl edit pvc pvc-volume --record=true

nginx 引用pvc

kubectl run aa --image=nginx --dry-run=client -o yaml > aa.yaml

vi aa.yaml

apiVersion: v1

kind: Pod

metadata:

  creationTimestamp: null

  labels:

    run: aa

  name: aa

spec:

volumes:

 - name:  pvc-volume

   persistentVolumeClaim:

       claimName:  pvc-volume

 containers:

 - image: nginx

   name: aa

   volumeMounts:

   - mountPath: "/usr/share/nginx/html"

      name: pvc-volume-storage

   resources: {}

 dnsPolicy: ClusterFirst

 restartPolicy: Always

status: {}

:wq

pvc

繼續閱讀