Question

Difference between block storage and persistent volume

Is there a difference between DO’s block storage and a standard persistent volume in k8s? based on my reading it seems there is. SO for example if I add a PV using the following config:

apiVersion: v1
kind: PersistentVolume # Create PV
metadata:
  name: postgres-volume # Sets PV name
  labels:
    type: local # Sets PV's type
    app: postgres
spec:
  storageClassName: manual
  capacity:
    storage: 2Gi # Sets PV's size
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/data/postgresql" # Sets PV's host path


And then proceed to delete the Node then this PV will also be deleted right? But if I was to create the PV using DO’s block storage, would that persist even if node was destroyed?

i.e with:

apiVersion: v1
kind: PersistentVolume # Create PV
metadata:
  name: postgres-volume # Sets PV name
  labels:
    type: local # Sets PV's type
    app: postgres
spec:
  storageClassName: do-block-storage # DIFF HERE
  capacity:
    storage: 2Gi # Sets PV's size
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/data/postgresql" # Sets PV's host path


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.

Bobby Iliev
Site Moderator
Site Moderator badge
October 17, 2022

Hi there,

Yes, this sounds is correct, if you just create a PV, the data will be stored directly on the node itself. However, if you use a block storage, you would actually spin up new volume which would then be attached to one of your Kubernetes nodes.

Hope that this helps!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.