File IO operations in an application running in kubernetes

101 views Asked by At

In my application, I have a requirement to save an object to a file.

Application runs in kubernetes environment, so file is to be saved in persistent volumes configured.

I wanted to know what is best practise to do so in context of kubernetes.

Is it just like normal IO operation or is there some standard kubernetes API to make use of?

1

There are 1 answers

0
Sai Chandini Routhu On BEST ANSWER

While k8s itself does not provide a specific API for file IO operations. Applications can communicate with PV in a standardized and scalable way due to its strong infrastructure for managing storage resources through PVs and PVCs.

So Persistent Volumes are the suggested method in this case, thus you are on the correct path for applications operating on K8s that require persistent storage for file IO.

As per official kubernetes doc on Persistent volumes and PVCs :

Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources. Claims can request specific size and access modes. Pods use PVCs to define their storage requirements, which are then bound to PVs that are available.

Kubernetes resources stand for persistent storage resources that the cluster has access to AWS EBS, GCP persistent disk, local storage, NFS and cloud storage providers are some of the technologies that can support PVs external storage.

Choose the appropriate PV storage class based on your application performance capacity and cost requirements. As per David Maze suggestion, also try to avoid manually establishing StatefulSets or PersistentVolumeClaims and instead use an external storage. Perhaps a nice fit would be an object-storage system such as MinIO (or) a comparable cloud system like AWS S3). Keeping data in local files can cause issues if you wish to have several copies of a pod in the future.