Dmytro Bogatov
Dmytro Bogatov

Reputation: 786

Kubernetes: strategy for out-of-cluster persistent storage

I need a piece of advice / recommendation / link to tutorial.

I am designing a kubernetes cluster and one of the projects is a Wordpress site with lots of pictures (photo blog).

I want to be able to tear down and re-create my cluster within an hour, so all "persistent" pieces need to be hosted outside of cluster (say, separate linux instance).

It is doable with database - I will just have a MySQL server running on that machine and will update WP configs accordingly.

It is not trivial with filesystem storage. I am looking at Kubernetes volume providers, specifically NFS. I want to setup NFS server on a separate machine and have each WP pod use that NFS share through volume mechanism. In that case, I can rebuild my cluster any time and data will be preserved. Almost like database access, but filesystem.

The questions are the following. Does this solution seem feasible? Is there any better way to achieve same goal? Does Kubernetes NFS plugin support the functionality I need? What about authorization?

Upvotes: 2

Views: 495

Answers (1)

damitj07
damitj07

Reputation: 2899

so I am using a very similar strategy for my cluster where all my PVC are placed on a standalone VM instance with a static IP and which has an NFS-server running and a simple nfs-client-provisioner helm chart on my cluster.

So here what I did :

  1. Created a server(Ubuntu) and installed the NFS server on it. Reference here
  2. Install a helm chart/app for nfs-client-proviosner with parameters.

    nfs.path = /srv ( the path on server which is allocated to NFS and shared)

    nfs.server = xx.yy.zz.ww ( IP of my NFS server configured above)

And that's it the chart creates an nfs-client storage class which you can use to create a PVC and attach to your pods.

Note - Make sure to configure the /etc/exports file on the NFS server to look like this as mentioned in the reference digital ocean document.

/srv kubernetes_node_1_IP(rw,sync,no_root_squash,no_subtree_check)

/srv kubernetes_node_2_IP(rw,sync,no_root_squash,no_subtree_check) ... and so on.

I am using the PVC for some php and laravel applications, seem to work well without any considerable delays. Although you will have to check for your specific requirements. HTH.

Upvotes: 1

Related Questions