4

I want to deploy a single Pod on a Node to host my service (like GitLab for the example). The problem is : a Pod will not be re-created after the Node failure (like a reboot). The solution(s) : Use a StatefulSet, ReplicaSet or DaemonSet to ensure the Pod creation after a Node failure. But what is the best for this case ?

This Pod is stateful (I am using volume hostPath to keep the data) and is deployed using nodeSelector to keep it always on the same Node.

Here is a simple YAML file for the example : https://pastebin.com/WNDYTqSG

It creates 3 Pods (one for each Set) with a volume to keep the data statefully. In practice, all of these solutions can feet my needs, but I don't know if there are best practices for this case.

Can you help me to choose between these solutions to deploy a single stateful Pod please ?

Jonas
  • 121,568
  • 97
  • 310
  • 388
Nurza
  • 201
  • 2
  • 10

1 Answers1

11

Deployment is the most common option to manage a Pod or set of Pods. These are normally used instead of ReplicaSets as they are more flexible and creating a Deployment results in a ReplicaSet - see https://www.mirantis.com/blog/kubernetes-replication-controller-replica-set-and-deployments-understanding-replication-options/

You would only need a StatefulSet if you had multiple Pods and needed dedicated persistence per Pod or you had multiple Pods and the Pods need individual names because they relate to each other (e.g. one is a leader) - https://stackoverflow.com/a/48006210/9705485

A DaemonSet would be used when you want one Pod/replica per Node

Ryan Dawson
  • 11,832
  • 5
  • 38
  • 61
  • 1
    StatefulSet is also an option, although unnecessary in this case. For the sake of completeness, please be aware of [this issue](https://github.com/kubernetes/kubernetes/issues/2630) with using StatefulSets with hostpath mounts. – Aditya Sundaramurthy Jan 18 '19 at 20:10
  • 1
    Thanks to both of you for your response. I agree, Deployments seam a bit overkill for a single Pod. I think StatefulSet is good for this job, but [the issue](https://github.com/kubernetes/kubernetes/issues/2630) is annoying. – Nurza Jan 21 '19 at 08:39