How to access ephemeral block storage in Kubernates jobs

I have Kubernates jobs which each require ~300GB of temporary disk space whilst they are running, then send files to an external service when done.

Currently I’m using DigitalOcean managed Kubernates with their storage optmised Droplets. However this is much more expensive than using Droplets with less vCPU but atatched block storage.

These jobs are automated (run by a Python script). DigitalOcean’s support article talks about creating a StatefulSet but I don’t understand how to do this at each jobs runtime, or if this is the right approach.

So how would you reccomend the following? Running Kubernates jobs which each require ~300GB of temp space but relatively low vCPU and Memory.

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.

Hi there @d825171ca273f05,

What I would do in this case is to also use a block storage and a PVC. That way you could attach the storage to a specific deployment and use it as a volume just like you would with a standard Droplet.

So rather than a StatefulSet you could use a standard Kubernetes deployment, for example:

  • First create the PVC:
apiVersion: v1
kind: PersistentVolumeClaim
  name: your-pvc
  - ReadWriteOnce
      storage: 1Gi
  storageClassName: do-block-storage
  • Then attach the volume to your pods:
apiVersion: apps/v1
kind: Deployment
  name: your_app
      app: your_app
        app: your_app
      - name: your_app
        image: your_image:latest
          privileged: true
        - mountPath: "/var/lib/your_path"
          name: do-block-storage
        - name: do-block-storage
            claimName: your-pvc

Here is a similar discussion here:

The main thing that you need to keep in mind is that the volume can be attached as ReadWriteOnce meaning that it would only be available on one node. So in case that you need to use multiple pods, they all need to be scheduled on the same node.

Hope that this helps! Regards, Bobby