<p>I would like to set auto-scaling feature in Azure Pipelines for deployment of containers with Kubernetes. How can I do that if I want to auto-scaling by below rules:</p>

<blockquote>
  <ol>
  <li>depeneds on no. of messages in ServiceBus message queue</li>
  <li>it will scale inside a node first (better to set maximum pods in node as it depends on thread no.?)</li>
  <li>if reach maximum pods in a node, then it will scale out to use another node (can scale to use maximum pods of node as well?i.e. 3 pods for 1 node, 6 pods for 2 nodes without total 4/5 pods)</li>
  </ol>
</blockquote>

<p>Finally, how to set by using Azure Pipelines? (above only set in Yaml file, right?)</p>

DaiKeung
<p>I dont think there is a way to scale based on number of message in the ServiceBus queue (at least native to kubernetes), that being said - you should use <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="nofollow noreferrer">Horizontal Pod Autoscaler</a> with <a href="https://kubernetes.io/docs/tasks/administer-cluster/cluster-management/#cluster-autoscaling" rel="nofollow noreferrer">Cluster Autoscaler</a>. These are native kubernetes mechanisms to scale pods\cluster based on the load on the pods.</p>

<p>Its in preview with AKS: <a href="https://learn.microsoft.com/en-us/azure/aks/autoscaler" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/aks/autoscaler</a></p>

<p>Another approach I've seen: using cronJobs. Just start your message processors every minute with cronJobs and make them scale. this is an easy approach that requires not a lot of configuration. You can drop pod autoscaler with this approach and only use cluster autoscaler, I haven't used this approach, but it looks promising.</p>
