I am reading local storage design of kubernetes. It has a section for distributed database
where db replicates data by itself.
My question is that if any process of db goes down, will it be restarted on the same node/machine ? I think it's a yes.
If it's yes, will it have access to its local storage
that it had before it crashed ?
I read an older article about stateful sets
when it was in beta. The article didn't encourage use of local storage at that time.
I am new to Kubernetes, so please answer this question with more information that a some new needs for understanding.
In the local storage design, as you can read here, it is used with stateful sets. So for example if you want three mongodb instances named mongodb, then k8s will create for you three pods:
If the mongodb-2 fails then k8s will restart it with the same local storage or persistent volume. If you increase the number of replicas, then k8s will create new persistent volumes through your persistentVolumeClaimTemplate. If you shrink it down to two those newly created volumes won't be deleted and will be used it you go back to your previous number of replicas.
If your persistent volume is bound to a specific node then k8s will know to create your pod on that node.
You can read about a mongodb cluster statefulset example here : https://kubernetes.io/blog/2017/01/running-mongodb-on-kubernetes-with-statefulsets
Or you can check a great talk here (with demos): https://www.youtube.com/watch?v=m8anzXcP-J8&feature=youtu.be
The use of statefuls sets and local storage is really well explained.