<p>I have in Azure a Kubernetes cluster that deploys three Docker containers: a Flask server, a Dask Scheduler and a Dask Worker. This works fine, now I need to deploy N workers instead of one.</p>
<p>This is the yaml file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: img-python
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cont-python
  template:
    metadata:
      labels:
        app: cont-python
    spec:
      containers:
        - name: cont-flask
          image: xxx.azurecr.io/myimage:latest
          command: [&quot;gunicorn&quot;]
          args: [&quot;-t&quot;, &quot;7200&quot;, &quot;-b&quot;, &quot;0.0.0.0:5000&quot;, &quot;--reload&quot;, &quot;app.front.app:app&quot;]
          ports:
            - containerPort: 5000
          volumeMounts:
            - name: volcode
              mountPath: /code
        - name: cont-scheduler
          image: xxx.azurecr.io/myimage:latest
          command: [&quot;dask-scheduler&quot;]
          ports:
            - containerPort: 8786
            - containerPort: 8787
        - name: cont-worker
          image: xxx.azurecr.io/myimage:latest
          workingDir: /code
          command: [&quot;dask-worker&quot;]
          args: [&quot;scheduler:8786&quot;]
          volumeMounts:
            - name: volcode
              mountPath: /code
      volumes:
        - name: volcode
          azureFile:
            shareName: py-code
            readOnly: false
</code></pre>
<p>I looked at the <code>kubectl scale</code> command however it seems to scale the entire cluster, not only specifically the worker's container.</p>
<p>How to specify the number of workers?</p>

ps0604
<p>The yaml file specifies a deployment, which can be scaled horizontally to any number of pods (either by setting the <code>spec.replicas</code> in the yaml file or on the fly using <code>kubectl scale</code>)</p>
<p><strong>It is not possible to scale individual containers inside a pod</strong> since pods are the smallest deployable units of computing that can be managed by Kubernetes</p>
<p>From the <a href="https://kubernetes.io/docs/concepts/workloads/pods/#using-pods" rel="nofollow noreferrer">docs</a>:</p>
<blockquote>
<p>Each Pod is meant to run a single instance of a given application. <strong>If
you want to scale your application horizontally (to provide more
overall resources by running more instances), you should use multiple
Pods</strong>, one for each instance. In Kubernetes, this is typically referred
to as replication. Replicated Pods are usually created and managed as
a group by a workload resource and its controller.</p>
</blockquote>
<p>Thus, to scale out the number of workers to 10 without scaling the server and scheduler, the worker needs to be a separate deployment (so that the worker is run it its own pod).</p>
