<p>I know why use StatefulSet for stateful applications. (e.g. DB or something)
In most cases, I can see like &quot;You want to deploy stateful app to k8s? Use StatefulSet!&quot;
However, I couldn't see like &quot;You want to deploy stateless app to k8s? Then, DO NOT USE StatefulSet&quot; ever.</p>
<p>Even nobody says &quot;I don't recommend to use StatefulSet for stateless app&quot;, many stateless apps is deployed through Deployment, like it is the standard.</p>
<p>The StatefulSet has clear pros for stateful app, but I think Deployment doesn't for stateless app.
Is there any pros in Deployment for stateless apps? Or is there any clear cons in StatefulSet for stateless apps?</p>
<p>I supposed that StatefulSet cannot use LoadBalancer Service or StatefulSet has penalty to use HPA, but all these are wrong.</p>
<p>I'm really curious about this question.</p>
<p>P.S. Precondition is the stateless app also uses the PV, but not persists stateful data, for example logs.</p>
<p>I googled &quot;When not to use StatefulSet&quot;, &quot;when Deployment is better than StatefulSet&quot;, &quot;Why Deployment is used for stateless apps&quot;, or something more questions.</p>
<p>I also see the k8s docs about StatefulSet either.</p>

<h2>Different Priorities</h2>
<p>What happens when a Node becomes unreachable in a cluster?</p>
<h2>Deployment - Stateless apps</h2>
<p>You want to maximize availability. As soon as Kubernetes detects that there are fewer than the desired number of replicas running in your cluster, the controllers spawn new replicas of it. Since these apps are stateless, it is very easy to do for the Kubernetes controllers.</p>
<h2>StatefulSet - Stateful apps</h2>
<p>You want to maximize availability - but not you must ensure <strong>data consistency</strong> (the state). To ensure <em>data consistency</em>, each replica has its own unique ID, and there are never multiple replicas of this ID, e.g. it is unique. This means that you cannot spawn up a new replica, unless that you are sure that the replica on the unreachable Node are terminated (e.g. stops using the Persistent Volume).</p>
<h3>Conclusion</h3>
<p>Both Deployment and StatefulSet try to maximize the availability - but StatefulSet cannot sacrifice <strong>data consistency</strong> (e.g. your state), so it cannot act as fast as Deployment (stateless) apps can.</p>
<p>These priorities does not only happens when a Node becomes unreachable, but at all times, e.g. also during upgrades and deployments.</p>
