<p>I have a Kubernetes deployment that deploys a pod that will pull down a single message from a RabbitMQ queue. I'm also using KEDA to scale the deployment based on the RabbitMQ messages currently in the queue. It correctly scales to 0, and then to 1 whenever there is a message, but the deployment never scales above 1. My current deployment YAML file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: scale
  labels:
    app: scale
spec:
  replicas: 1
  selector: 
    matchLabels:
      app: scale
  template:
    metadata:
      labels:
        app: scale
    spec:
      containers:
        - name: scale-deployment
          image: bharper7/scale:v1
          imagePullPolicy: Never
</code></pre>
<p>My KEDA YAML file:</p>
<pre><code>apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: scale-keda-deployment
  labels:
    app: scale
    deploymentName: scale
spec:
  scaleTargetRef:
    name: scale
  pollingInterval: 5
  minReplicaCount: 0
  maxReplicaCount: 10
  cooldownPeriod: 60
  triggers:
  - type: rabbitmq
    metadata:
      host: amqp://EmZn4ScuOPLEU1CGIsFKOaQSCQdjhzca:dJhLl2aVF78Gn07g2yGoRuwjXSc6tT11@192.168.49.2:30861
      mode: QueueLength
      value: '1'
      queueName: scaleTest
</code></pre>
<p>The KEDA operator log files:</p>
<pre><code>2021-04-28T19:25:39.846Z        INFO    scaleexecutor   Successfully updated ScaleTarget        {&quot;scaledobject.Name&quot;: &quot;scale-keda-deployment&quot;, &quot;scaledObject.Namespace&quot;: &quot;default&quot;, &quot;scaleTarget.Name&quot;: &quot;scale&quot;, &quot;Original Replicas Count&quot;: 0, &quot;New Replicas Count&quot;: 1}
2021-04-28T19:25:40.272Z        INFO    controllers.ScaledObject        Reconciling ScaledObject        {&quot;ScaledObject.Namespace&quot;: &quot;default&quot;, &quot;ScaledObject.Name&quot;: &quot;scale-keda-deployment&quot;}
</code></pre>
<p>I know everything as far as the RabbitMQ connection is working, and that KEDA knows what deployment to look at, as well as what queue. All of this is proven by the fact that the pod scales to 0 and 1. But for some reason it never goes beyond 1 even when I have 50 messages in the queue.</p>
<p>So far I've tried messing around with the <code>pollingInterval</code> and <code>cooldownPeriod</code> tags but neither seem to have an effect. Any ideas?</p>
<p>Edit:</p>
<p>I removed the <code>replicas</code> value from the deployment YAML file as suggested below. And also looked at the HPA logs.</p>
<p>The generated HPA logs:</p>
<pre><code>Name:                                           keda-hpa-scale-keda-deployment
Namespace:                                      default
Labels:                                         app=scale
                                                app.kubernetes.io/managed-by=keda-operator
                                                app.kubernetes.io/name=keda-hpa-scale-keda-deployment
                                                app.kubernetes.io/part-of=scale-keda-deployment
                                                app.kubernetes.io/version=2.1.0
                                                deploymentName=scale
                                                scaledObjectName=scale-keda-deployment
Annotations:                                    &lt;none&gt;
CreationTimestamp:                              Wed, 28 Apr 2021 11:24:15 +0100
Reference:                                      Deployment/scale
Metrics:                                        ( current / target )
  &quot;rabbitmq-scaleTest&quot; (target average value):  4 / 20
Min replicas:                                   1
Max replicas:                                   10
Deployment pods:                                1 current / 1 desired
Conditions:
  Type            Status  Reason              Message
  ----            ------  ------              -------
  AbleToScale     True    ReadyForNewScale    recommended size matches current size
  ScalingActive   True    ValidMetricFound    the HPA was able to successfully calculate a replica count from external metric rabbitmq-scaleTest(&amp;LabelSelector{MatchLabels:map[string]string{scaledObjectName: scale-keda-deployment,},MatchExpressions:[]LabelSelectorRequirement{},})
  ScalingLimited  False   DesiredWithinRange  the desired count is within the acceptable range
Events:
  Type     Reason             Age                From                       Message
  ----     ------             ----               ----                       -------
  Warning  FailedGetScale     22m (x6 over 23m)  horizontal-pod-autoscaler  deployments/scale.apps &quot;scale&quot; not found
  Normal   SuccessfulRescale  15m                horizontal-pod-autoscaler  New size: 1; reason: All metrics below target
</code></pre>
<p>This is after sending 5 messages into the queue. For some reason it only thinks 1 pod is needed even though I set <code>value</code> to 1 in the KEDA YAML file.</p>

Brady Harper
<p>In case anyone else stumbles across this issue, I managed to find a work around. According the <a href="https://keda.sh/docs/2.2/scalers/rabbitmq-queue/" rel="nofollow noreferrer">docs</a>, the use of <code>queueLength</code> is deprecated and <code>mode</code> should be used instead. But changing back to the deprecated tags worked for me, for some reason the new tags don't work. Not really a proper fix but at least it got my deployment scaling as expected. My KEDA deployment file now looks like this:</p>
<pre><code>apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: keda-deployment
  labels:
    apps: ffmpeg
    deploymentName: ffmpeg
spec:
  scaleTargetRef:
    name: ffmpeg
  pollingInterval: 10
  cooldownPeriod: 1200
  maxReplicaCount: 50
  triggers:
  - type: rabbitmq
    metadata:
      host: amqp://EmZn4ScuOPLEU1CGIsFKOaQSCQdjhzca:dJhLl2aVF78Gn07g2yGoRuwjXSc6tT11@192.168.49.2:30861
      queueName: files
      queueLength: '1'
</code></pre>
