<p>So yes, <code>StatefulSet</code> helps preserve the order and name of the pod, but what is it that it does extra (or different) that is advantageous over a regular <code>Deployment</code> with respect to volumes.</p>
<p>I see many examples of master/slave setup for databases as a use case for <code>StatefulSet</code>, but can't that problem be solved with just a <code>Deployment</code> (replicas=1) for the master and a <code>Deployment</code> (replicas=<code>&lt;multiple&gt;</code>) for the slaves. For volumes just create a <code>PV</code>/<code>PVC</code>.</p>
<p>Can someone please let me know what is the difference with respect to volumes?</p>

Gurleen Sethi
<blockquote>
<p>So yes, StatefulSet helps preserve the order and name of the pod, but what is it that it does extra (or different) that is advantageous over a regular Deployment with respect to volumes.</p>
</blockquote>
<p>With a <strong>StatefulSet</strong> each Pod get its own PersistentVolumeClaim, but with <strong>Deployment</strong> all Pods use the same PersistentVolumeClaim.</p>
<p><code>StatefulSet</code> has <code>volumeClaimTemplates</code> that creates volumes for you from the template and it adds <code>-&lt;ordinal&gt;</code> on the name for PersistentVolumeClaims, so a name with <code>my-pvc</code> will be <code>my-pvc-0</code> and <code>my-pvc-1</code> if the StatefulSet has <code>replicas: 2</code>.</p>
<blockquote>
<p>I see many examples of master/slave setup for databases as a use case for StatefulSet, but can't that problem be solved with just a Deployment (replicas=1) for the master and a Deployment (replicas=) for the slaves. For volumes just create a PV/PVC.</p>
</blockquote>
<p>Yes, that would probably work - for testing and development. But it would not be recommended in a production environment. Typically in a cloud (and Kubernetes) environment, you use a Database that use three replicas and that has an instance in every <em>Availability Zone</em> - this is easier to manage with a single <code>StatefulSet</code> with <code>replicas: 3</code> and proper PodAffinity configuration.</p>
