Report this

What is the reason for this report?

Reuse volume as PVC?

Posted on November 15, 2018

Hi,

is it possible in any way to create a PVC / PV and link it to a currently existing, unbound volume, which was previously created via a Kubernetes cluster? If this would be possible, it would enable quick migration of huge datasets in case of severe cluster failures. Any documentation or planned work on that?

Dennis



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!

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.

Hi.What aws the method to do this?

Dennis,

I needed a way to transfer data between separate clusters as well -the same use case as you described.

Instead of trying to create another PVC and get k8s/digitalocean link the existing target volume to it, I had the k8s pod refer to it via the ‘hostpath’ construct. ( https://kubernetes.io/docs/concepts/storage/volumes/#hostpath )

Steps:

  • Detach the volume from the droplet.

  • Attach it to the target droplet . This is the droplet ( node) that you will want to ‘select’ in your k8s pod or deployment script.

    Login to your droplet and mount it ( https://www.digitalocean.com/docs/volumes/how-to/mount/)

    I assume you’ve mounted it under /mnt . ( will be referenced next)

  • Use the followin stanza in your k8s ( here it is a pod ) script:

    volumeMounts:

    • mountPath: /mnt name: restore-pv volumes:
    • name: restore-pv hostPath: path: /mnt
  • Finally, apply your script.

I hope that helps.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.