<p>When it comes to PODS with:</p>

<pre><code>kind: Deployment
</code></pre>

<p>the command has a following format:</p>

<pre><code>kubectl exec -it [# POD_NAME #] -- sh
</code></pre>

<p>I am not sure how to accomplish the same, when I do have PODs defined using:</p>

<pre><code>apiVersion: apps/v1
kind: StatefulSet
</code></pre>

Artur Drożdżyk
<p>In <code>Statefulset</code> number of pods will be created defined in <code>spec.replicas</code>. The Pods' names take the form <code>&lt;statefulset name&gt;-&lt;ordinal index&gt;</code>. If your StatefulSet has two replicas, it creates two Pods, <strong><code>&lt;statefulset-name&gt;-0</code></strong> and <strong><code>&lt;statefulset-name&gt;-1</code></strong></p>

<p>You can exec</p>

<pre><code>$ kubectl exec -it **&lt;statefulset name&gt;-&lt;ordinal index&gt;** -- sh
</code></pre>

<p>You can see the created pod by your satefulset using</p>

<pre><code>kubectl get pods -l &lt;label in spec.template.metadata.labels&gt;
</code></pre>

<p>More details <a href="https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#pods-in-a-statefulset" rel="nofollow noreferrer">click</a></p>
