Using Preexisiting Persistent Disks as PersistentVolumes

This page explains how to create a PersistentVolume using an existing Compute Engine persistent disk populated with data.

Creating the Persistent Volume

If you already have a 500 GB persistent disk named pd-name, the manifest file below describes a corresponding PersistentVolume and PersistentVolumeClaim.

existing-pd.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-demo
spec:
  storageClassName: ""
  capacity:
    storage: 500G
  accessModes:
    - ReadWriteOnce
  gcePersistentDisk:
    pdName: pd-name
    fsType: ext4
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pv-claim-demo
spec:
  # It's necessary to specify "" as the storageClassName
  # so that the default storage class won't be used, see
  # https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
  storageClassName: ""
  volumeName: pv-demo
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 500G
    

Use kubectl apply -f existing-pd.yaml to create the PersistentVolume and PersistentVolumeClaim.

Was this page helpful? Let us know how we did:

Send feedback about...

Kubernetes Engine