In k8s, we can use the memory
medium(tmpfs
instance) to define the emptyDir
volume and mount it to pod's container. In the container, we can read and write data according to the file
interface.
I want to know how does k8s achieve the association of file
and memory
? What is the principle of reading and writing memory
data as file
? mmap
?
According to wikipdia:
tmpfs is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory instead of a persistent storage device. A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a disk file system.
So its not k8s feature. Is is a Linux feature that just appears to be used by k8s.
You can read more about it in linux kernel documentation