<p>I heard that statefulset is suitable for database.
But StatefulSet will create different pvc for echo pod.
If I set the replicas=3.then I get 3 pod and 3 different pvc with different data.
For database users,they only want a database not 3 database.
So Its clear we should not use statefulset in this situation.
But when should we use statefulset.</p>

<p>A StatefulSet does three big things differently from a Deployment:</p>
<ol>
<li>It creates a new PersistentVolumeClaim for each replica;</li>
<li>It gives the pods sequential names, starting with <code>statefulsetname-0</code>; and</li>
<li>It starts the pods in a specific order (ascending numerically).</li>
</ol>
<p>This is useful when the database itself knows how to replicate data between different copies of itself.  In Elasticsearch, for example, indexes are broken up into shards.  There are by default two copies of each shard.  If you have five Pods running Elasticsearch, each one will have a different fraction of the data, but internally the database system knows how to route a request to the specific server that has the datum in question.</p>
<p>I'd recommend using a StatefulSet in preference to manually creating a PersistentVolumeClaim.  For database workloads that can't be replicated, you can't set <code>replicas:</code> greater than 1 in either case, but the PVC management is valuable.  You usually can't have multiple databases pointing at the same physical storage, containers or otherwise, and most types of Volumes can't be shared across Pods.</p>
