<p>Is it possible to pass different args to pods based on their ordinal index in StatefulSets? Didn't find the answer on the StatefulSets documentation. Thanks!</p>

<p>Recommended way, see <a href="https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/#statefulset" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/#statefulset</a></p>

<pre class="lang-sh prettyprint-override"><code># Generate server-id from pod ordinal index.

[[ `hostname` =~ -([0-9]+)$ ]] || exit 1
ordinal=${BASH_REMATCH[1]}

# ${ordinal} now holds the replica number

server-id=$((100 + $ordinal))

# Copy appropriate conf.d files from config-map to emptyDir.
if [[ $ordinal -eq 0 ]]; then
  # do something
else
  # do something else
fi
</code></pre>
