<p>I am not sure where is the number of pods that should run defined in Kubernetes.</p>

<p>If I run <code>kubectl get pods -n my-namespace</code>, I can see:</p>

<pre><code>NAME                                                              READY     STATUS    RESTARTS   AGE
my-project-code-php-fpm-6db9cc4796-spz72                          3/3       Running   0          52m
my-project-code-php-fpm-6cb598f7c5-4hhhc                          3/3       Running   0          45m
my-project-code-rabbit-worker-6cb598f7c5-4ldx9                    3/3       Running   0          4m
</code></pre>

<p>I would like to change the number of pods for <code>my-project-code-rabbit-worker-6cb598f7c5-4ldx9</code>, but I am not sure where this number 3 is coming from. Any help?</p>

<p>Thanks!</p>

Bob
<p>When you deploy your application in kubernetes (<code>k8s</code>), it is weird that you rely directly on pod deployments (deploying pods yourself).</p>

<p><strong>The Managed Approach</strong></p>

<p>There are a set of higher abstraction entities that allow you to control the behavior of your application, and they can manage the number of desired pods.</p>

<p>These entities include <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">statefulsets</a>, <a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/" rel="nofollow noreferrer">replicasets</a> or <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">deployments</a>. The latest, deployments, are the most common used for stateless apps. They use beneath them replicasets, which is the real component that is able to manage how many pods do you want to have deployed.</p>

<p>If you have deployed your application by defining a deployment, in your <code>.yaml</code> file you should have a <code>replicas</code> key with the desired number of pods that you want to be executing in parallel. Something like:</p>

<pre><code>spec:
  replicas: 3
</code></pre>

<p>If you were to get this info after having deployed your <code>deployment</code> object, your should get it with <code>kubectl</code> as:</p>

<pre><code>kubectl get deployments
</code></pre>

<p>With an output like, for example:</p>

<pre><code>NAME               READY   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   0/3     0            0           1s
</code></pre>

<p>Where the <code>ready</code> column is the one with <code>pods ready</code> / <code>desired pod replicas</code>.</p>

<p><strong>The Unmanaged Approach</strong></p>

<p>On the other side, if you choose to initialize your pods without these higher level entities, they will be not managed pods, and therefore you will have to manage them yourself.</p>

<p>Find further info in the links from the official docs above.</p>

<p><strong>Pods VS Containers</strong></p>

<p>If we jump back to your question, you were watching a <code>3/3</code> value in your <code>kubectl</code> answer. When getting <code>pods</code>, a <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/" rel="nofollow noreferrer">pod</a> is composed by one or several <code>containers</code>. They are defined in the pod <code>.yaml</code> definition file, and they don't have to be the same application or service.</p>

<p>In fact, they usually aren't, since you will group in the same pod containers that need to be together for some reason or to achieve some specific tasks (see Init Containers patterns, and so on).</p>

<p>So when you're retrieving the pods, you're not looking at a number of how many pod replicas are available, but how many of its containers have reached a <code>ready</code> state / all containers that compose the pod.</p>
