Using NFS Server to share external storage between containers

Please use the thread below to discuss the related blog post:

https://balena.io/blog/using-nfs-server-to-share-external-storage-between-containers-balena/

@ts-cfield, thanks for this blog contribution!

Very interesting to see the OpenRC init system approach. Would you be able to share the docker-entrypoint.sh script too? It looks like there is a Dockerfile → entrypoint.sh → docker-entrypoint.sh, and I suspect the docker-entrypoint.sh contains start processes and maybe an OpenRC configuration? This would be helpful to allow it to be replicable.

Ideally a little GitHub repo example would be fantastic! It would mean that the community can also help with some of the questions and issues you mentioned. I suspect the NGINX container not starting if the server isn’t ready is because it has a reverse proxy pointing to the server? This is a common issue in NGINX and overcome by the rather odd step of storing the proxy address in a variable and then passing the variable to the proxy_pass:

set $variable http://0.0.0.0:8080;
proxy_pass $variable;

Of course that may not be any help at all, I am taking a best guess based on the description. A mini repo would be really great, I would love to experiment with the OpenRC process.

Hello @Maggie,

Thank you for the comment. Script docker-entrypoint.sh is specific to the TimescaleDB and was not modified.
OpenRC does not require any configuration after initial setup. I want to mention that removing previous run files is crucial to restarting docker containers.

## NFS Server
rm -rf /run/*
mkdir /run/openrc
touch /run/openrc/softlevel
openrc

We can look into creating a repository if there is an interest from the community. All steps and configurations are mentioned in the article and nothing else should be required to reproduce.

Ahh yes, I see the rc-update entry now. I thought OpenRC used the run directories/service files like systemd or s6.

I think it could be useful to have a repo, if you are able to put the initial code up I would happily chip in by adding a pull request with some of the Balena elements (.yml files, workflows etc.) and then can push it to the Balena Hub. I was thinking something that simply exposes a volume. My hope is to get a few different approaches available to experiment with (I see from the link in your blog post you found one of my earlier ones). I will then try and get some benchmarks, and may delve in to GlusterFS too. I think there is a bunch of potential use cases, the one high up on my list has been exposing of the content from a device to allow hot reload of compiled languages for live development on a device. A repo would open a door for different contributions and evolutions, and I would happily work off an open repository so we can all fork and edit the evolutions as suits the different projects.

Hello @Maggie,

We created a repo and balenaHub project to demonstrate how to create a NFS Server and Client based on PostgreSQL and NGINX Alpine images: balenaHub: an easier way to find and publish fleets, projects, and blocks for edge devices. You are welcome to fork and experiment. GitHub repository: GitHub - VolkovLabs/balena-nfs: Balena NFS Server and Client Project.
Also, we added our new Grafana Application, which communicates with Supervisor API and allows to display device information, see logs in real-time and manage containers. I thought it would be interested for you to look at as it’s similar to your balena-device-ui project.

I would love to take a look at your benchmarks and will check GlusterFS.

1 Like

There is a wealth of stuff I want to try here. The Grafana Application is very interesting too and will be sharing it with others! I will be sure to come back here once I have had a chance to test it all out.

1 Like

Hello @Maggie, we released an updated version of the balena-nfs project supporting NFS version 4: Release Balena NFS 1.1.0 · VolkovLabs/balena-nfs · GitHub. Please let us know if you have any questions.

1 Like

Nice! I haven’t really read up on the pros of v4 over 3. I think that the default behaviour for sync/async changed though. Not that it impacts your project as you specify sync and as its database related makes sense. For my use cases where there are lots of little files, and data corruption wouldn’t be the end of the world (and is rare) the async has a big performance boost.

I still haven’t got around to giving it a whirl, but I think it is going to be the base for the development environment on the balena-device-ui, so certainly going to.

1 Like