Reputation: 117
I have a Flask application deployed on GKE, duplicated in several pods. For performance issues, I want this app to read local files from the app repository. I need to update these files frequently with another Python script.
I could implement an endpoint to fetch the refreshed files from a server but if I ping this endpoint only one pod will update the local files, and I need all app instances to read from latest data files.
Do you have an idea on how to solve this issue?
Upvotes: 0
Views: 340
Reputation: 2498
There are multiple solutions, the best one is to set up a shared NFS volume for those files: The Flask Pods mount it read-only, the Python script mounts it read and write, and updates the files.
An NFS volume allows an existing NFS (Network File System) share to be mounted into a Pod. Unlike emptyDir, which is erased when a Pod is removed, the contents of an NFS volume are preserved and the volume is merely unmounted. This means that an NFS volume can be pre-populated with data, and that data can be shared between pods.
Reference link to create kubernetes NFS volume on GKE and advantages.
Upvotes: 1