<p>I want to change the number of replications (pods) for a <strong>Deployment</strong> using the Kubernetes API (v1beta1).</p>

<p>For now I'm able to increase the replicas from CLI using the command: </p>

<pre><code>kubectl scale --replicas=3 deployment my-deployment
</code></pre>

<p>In the <a href="https://kubernetes.io/docs/api-reference/v1.5/#replace-scale" rel="noreferrer">Kubernetes API documentation</a> it's mention that there is a PUT request to do the same </p>

<pre><code>PUT /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale
</code></pre>

<p>but there is no example of how to do it.</p>

<p>I'm not sure what to send in the request body in order to perform the update.</p>

<p>the easiest way is to retrieve the actual data first with:</p>

<pre><code>GET /apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale
</code></pre>

<p>This will give you an yaml or json object which you can modify and send back with the <code>PUT</code> request.</p>

<hr>

<p>With curl the roundtrip look like this:</p>

<pre><code>API_URL="http://kubernetes:8080/apis/extensions/v1beta1/namespaces/{namespace}/deployments/{name}/scale"
curl  -H 'Accept: application/json' $API_URL &gt; scale.json
# edit scale.json
curl -X PUT -d@scale.json -H 'Content-Type: application/json' $API_URL
</code></pre>

<hr>

<p>Alternatively you could just use a <code>PATCH</code> call:</p>

<pre><code>PAYLOAD='[{"op":"replace","path":"/spec/replicas","value":"3"}]'
curl -X PATCH -d$PAYLOAD -H 'Content-Type: application/json-patch+json' $API_URL
</code></pre>
