Hey everyone! I'm working on a GitHub workflow to build static files that I plan to bundle into an Nginx image and push to my container registry. Since these files might be quite large, I'm considering using a PersistentVolume and a PersistentVolumeClaim to store them. This way, the Nginx Pod can mount it directly to serve the files. However, I'm stuck on how to update the files inside these volumes automatically without having to do it manually. I've thought about using Cloudflare Worker/Pages or AWS CloudFront, but those might not be suitable since these files are for internal use only. Any suggestions?
4 Answers
A popular approach nowadays is to publish your static files to an OCI registry as artifacts and then mount them into your container as an image volume. You could also consider using a sidecar or init container to help manage this process.
Why not consider using an NFS server with your Pod as a client? Just mount it in your deployment, and you should be good to go.
But you know that NFS can be pretty unreliable, right?
I have a different setup where I use a Caddy server with the S3 plugin to load content dynamically from an S3 compatible storage. My CI pipeline uploads new content directly to this S3, allowing for automatic updates without needing to modify the Caddy configuration at all.
Pods are inherently ephemeral, so CI/CD may not fit nicely since it often involves manual or semi-manual actions. I recommend setting up another container that can continuously sync those static files for you. One tool you might want to look into is 'git-sync'; it's widely used, for instance, in Apache Airflow projects.
That's true, but using git-sync may not be ideal for handling large files.

Just keep in mind that this method requires the latest Kubernetes version (1.33+), which isn't always available. I’d also suggest using OCI volume mounts for better configuration management.