StatefulSet, ReplicaSet or DaemonSet. What is the best for a single Pod?

1/18/2019

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 ?

-- Nurza
daemonset
kubernetes
pod
replicaset
statefulset

1 Answer

1/18/2019

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
Source: StackOverflow