<p>I am trying to patch horizontal pod autoscaler by setting minimum replica through kubernetes api</p>
<p>Here is the curl which I am using</p>
<pre><code>curl -k  \
    --request PATCH \
            --header &quot;Authorization: Bearer $KUBE_TOKEN&quot; \
            --header &quot;Content-Type: application/strategic-merge-patch+json&quot; \
            --data '{
                &quot;apiVersion&quot;: &quot;autoscaling/v1&quot;,
                &quot;kind&quot;: &quot;HorizontalPodAutoscaler&quot;,
                &quot;metadata&quot;: {
                    &quot;labels&quot;: {
                        &quot;app.kubernetes.io/instance&quot;: &quot;test&quot;
                    },
                    &quot;name&quot;: &quot;test&quot;,
                    &quot;namespace&quot;: &quot;default&quot;
                },
                &quot;spec&quot;: {
                    &quot;maxReplicas&quot;: 2,
                    &quot;minReplicas&quot;: 1,
                    &quot;scaleTargetRef&quot;: {
                        &quot;apiVersion&quot;: &quot;apps/v1&quot;,
                        &quot;kind&quot;: &quot;Deployment&quot;,
                        &quot;name&quot;: &quot;test&quot;
                    },
                    &quot;targetCPUUtilizationPercentage&quot;: 60
                }
            
            }' \
            https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers
</code></pre>
<p>I receive following response</p>
<pre><code>{
  &quot;kind&quot;: &quot;Status&quot;,
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;metadata&quot;: {
    
  },
  &quot;status&quot;: &quot;Failure&quot;,
  &quot;message&quot;: &quot;the server does not allow this method on the requested resource&quot;,
  &quot;reason&quot;: &quot;MethodNotAllowed&quot;,
  &quot;details&quot;: {
    
  },
  &quot;code&quot;: 405
}
</code></pre>
<p>Can anyone know where am I missing?</p>
<p>Thanks</p>

Ali Mehdi
<p>The URL path must contain the name:</p>
<pre><code>/apis/autoscaling/v1/namespaces/{namespace}/horizontalpodautoscalers/{name}
</code></pre>
<p>Its documented on this page <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#horizontalpodautoscaler-v1-autoscaling" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#horizontalpodautoscaler-v1-autoscaling</a></p>
