<p>My team is currently working on migrating a Discord chat bot to Kubernetes. We plan on using a <strong>StatefulSet</strong> for the main bot service, as each <a href="https://discord.com/developers/docs/topics/gateway#sharding" rel="noreferrer">Shard</a> (pod) should only have a single connection to the <a href="https://discord.com/developers/docs/topics/gateway" rel="noreferrer">Gateway</a>. Whenever a shard connects to said Gateway, it tells it its ID (in our case the pod's ordinal index) and <strong>how many shards we are running in total</strong> (the amount of replicas in the StatefulSet).</p>

<p>Having to tell the gateway the total number of shards means that in order to scale our StatefulSet up or down <strong>we'd have to stop all pods in that StatefulSet before starting new ones with the updated value</strong>.</p>

<p>How can I achieve that? Preferrably through configuration so I don't have to run a special command each time.</p>

Pedro Fracassi
<p>Try <code>kubectl rollout restart sts &lt;sts name&gt;</code> command. It'll restart the pods one by one in a RollingUpdate way.</p>

<p>Scale down the sts
<code>kubectl scale --replicas=0 sts &lt;sts name&gt;</code></p>

<p>Scale up the sts
<code>kubectl scale --replicas=&lt;number of replicas&gt; sts &lt;sts name&gt;</code></p>
