Question

How do you re-attach a persistent volume to a kubernetes cluster?

I created a volume for my kubernetes cluster using a persistent volume claim (PVC). I destroyed the cluster when I had finished using it, but kept the volume because it might be useful in future. I now want to create a new cluster and attach the existing volume.

How can I attach that volume to a new kubernetes cluster?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hey there! Quick update for you. This solution should work for you to use an existing volume.

https://github.com/digitalocean/csi-digitalocean/blob/master/examples/kubernetes/pod-single-existing-volume/README.md

any response to this?

Has anyone tried the migration described in https://github.com/digitalocean/csi-digitalocean/blob/master/examples/kubernetes/pod-single-existing-volume/README.md by adding a claimRef that only specifies namespace and name but not uid? E.g.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: example
spec:
  accessModes:
  - ReadWriteOnce
  azureDisk:
    ...
  capacity:
    storage: 10Gi
  claimRef:
    apiVersion: v1
    kind: PersistentVolumeClaim
    name: caluma-adfinis-minio
    namespace: caluma-adfinis
  persistentVolumeReclaimPolicy: Delete
  storageClassName: default
  volumeMode: Filesystem