Question

How to provision Kubernetes Persistent Volumes to use with S3 or DO spaces

Posted January 10, 2021 2.1k views
StorageKubernetesObject StorageDigitalOcean Spaces

Hi,

I’m a beginner on k8s and I’ve been struggling for a long time trying to do Kubernetes storage the right way. I’ve learnt that stateless applications offers great performances and database shouldn’t be inside pods for performance/availability reasons.

So is there a way to use a S3-compatible API (like DO spaces) as a storage backend ? Ideally, I’d like to migrate my databases out of k8s in a managed SQL cluster, and use object storage for my newly created PVs. I could just use S3 directly in my applications, but this is sometimes not compatible with the design of the app (e.g: Nextcloud).

Thanks,

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.

×
Submit an Answer
1 answer

If I’m understanding your question, I think all you need to do is provide your application with configuration parameters to connect to whatever storage you need.

For example, in most of my applications, I’ll create a kubernetes secret that has my database name/address/password/etc., and then I’ll provide that data to my stateless pod as an environment variable. The application can then read the environment variable and connect to the database.

Does this answer your question?

  • Hi, thanks for your answer!

    As I said, I could just connect to S3 directly in my applications, but this is sometimes not compatible with the design of the app (e.g: Nextcloud).

    I wish I could do that independently of the app configuration.

    For example, what if I had a Minio cluster and I wanted to create PVCs to mount my buckets ? Is block storage not compatible with the k8s’ storage system ?

    • To see if I’m understanding this correctly: You’re asking how to handle situations where the app you’re running requires disk space?

      • Yes. The app would just use the filesystem as usual but the data would be stored in a s3 bucket. Does that sounds possible ?

        • Possible: yes
          Easy: probably no :-)

          This is not something I have direct experience with, but I can imagine there are two routes you could explore:

          1) I have in the past used software to mount an S3 bucket onto my linux machine. I’m not sure if this software is compatible with containers, but you could try that. Sorry, I don’t remember the name of the software.

          2) There might already be tools available to give you the ability mount S3 buckets as a PVC. However I have not heard of such a thing.

          The second option would definitely be the preferable approach if it exists.

          Let me know if you find a solution. I’m curious about this as well.