I'm new to Kubernetes and I'm having trouble with a Deployment that specifies the backend database for the system. For some reason, the Pod hosting the database container gets randomly recreated, and so the data get wiped out. I'm adding a config for the database deployment to use a separate emptyDir
volume, but I'm not sure how persistent that is. Will it survive recreation of the Pod? Also, is there a way to check why the Pod seems to get randomly recreated? How do I force Kubernetes to recreate the Pod so I can check if emptyDir
volume persists?
Kubernetes' Deployment abstraction is not a good fit for stateful programs such as a database. It's not entirely impossible to that right, but that's not the right tool for the job.
I suggest you look into StatefulSet, which as the the name suggests is meant for stateful loads.
With either, to force a recreation of a pod, simply delete the pod hosting your database, and observe the difference between a pod created by a Deployment and one created by a StatefulSet controller.