Running Stateful Services on Kubernetes
Step 1 - Deploy NFS Server
NFS is a protocol that allows nodes to read/write data over a network. The protocol works by having a master node running the NFS daemon and stores the data. This master node makes certain directories available over the network.
Clients access the masters shared via drive mounts. From the viewpoint of applications, they are writing to the local disk. Under the covers, the NFS protocol writes it to the master.
In this scenario, and for demonstration and learning purposes, the role of the NFS Server is handled by a customised container. The container makes directories available via NFS and stores the data inside the container. In production, it is recommended to configure a dedicated NFS Server.
Start the NFS using the command
docker run -d --net=host \
--privileged --name nfs-server \
The NFS server exposes two directories, data-0001 and data-0002. In the next steps, this is used to store data.