<p>I have a k8s cluster on which I have installed openfaas in the following way:</p>
<pre class="lang-yaml prettyprint-override"><code>helm repo add openfaas https://openfaas.github.io/faas-netes/
helm repo update

kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml

helm upgrade openfaas --install openfaas/openfaas \
  --namespace openfaas \
  --set generateBasicAuth=true \
  --set serviceType=LoadBalancer \
  --set clusterRole=true \
  --set functionNamespace=openfaas-fn
</code></pre>
<p>Now, I have the following <code>stack.yml</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>version: 1.0
provider:
  name: openfaas
  gateway: http://localhost:31112
functions:
  my-function:
    lang: csharp
    handler: ./MyFunction
    image: my-function:my-tag
    labels:
      com.openfaas.scale.min: 1
      com.openfaas.scale.max: 1
      com.openfaas.scale.factor: 0
</code></pre>
<p>The deployed function is then decorated with the above mentioned labels, which I found in the <a href="https://docs.openfaas.com/architecture/autoscaling/#minmax-replicas" rel="nofollow noreferrer">openfaas documentation</a>. However, if I look at the replica set controlling the function's pod, I see it is adorned with the following annotation:</p>
<pre><code>deployment.kubernetes.io/max-replicas=2
</code></pre>
<p>What is the effect of this latter annotation on the function's replica set over the actual function's scaling? What would happen if I set</p>
<pre><code>com.openfaas.scale.max: 3
</code></pre>
<p>as my function's label?</p>
<p>I would like to make sure to really have control over my function's horizontal scaling. How should I proceed?</p>

Laurent Michel
<p>The OpenFaas is equiped with autoscaler itself with its own alert manager:</p>
<blockquote>
<p>OpenFaaS ships with a single auto-scaling rule defined in the mounted
configuration file for AlertManager. AlertManager reads usage
(requests per second) metrics from Prometheus in order to know when to
fire an alert to the API Gateway.</p>
</blockquote>
<p>After some reading I found out that OpenFaas autoscaler/alertmanger is more focused on API hit rates whereas Kubernetes HPA is more focused on CPU and memory usage so it all depends on what you exactly need.</p>
<p>So you have two different annotations for two different tools for scaling.
The <code>deployment.kubernetes.io/max-replicas=2</code> is for Kubernetes HPA and <code>com.openfaas.scale.max: 1</code> is for the OpenFaas autoscaler.</p>
<p>The OpenFaas has a great <a href="https://docs.openfaas.com/tutorials/kubernetes-hpa/" rel="nofollow noreferrer">example</a> of how you can use HPA instead built in scaler.  You can also use custom Prometheus metrics with HPA as described <a href="https://docs.openfaas.com/tutorials/kubernetes-hpa-custom-metrics/" rel="nofollow noreferrer">here</a>.</p>
