Search code examples
kubernetesautoscalinghpakedakeda-scaledjob

Keda ScaledObject with MSSQL trigger


I'm using keda in my k8s cluster for autoscaling. After deploying my scaled object with MSSQL trigger , I'm getting ready and active status as unknown.. In logs I'm only seeing that it's trying to create a HPA and then nothing happens. I guess the keda-operator is getting stuck here as I'm not getting any updates on logs.

Scaledobject status

My ScaledObject:

Scaledobject

On query execution, I'm getting value as 300 which is enough to initate scaling.

Also I'm attaching operator logs : 2021-06-04T08:06:20.130Z INFO controller Starting EventSource {"reconcilerGroup": "keda.sh", "reconcilerKind": "ScaledJob", "controller": "scaledjob", "source": "kind source: /, Kind="} 2021-06-04T08:06:20.130Z INFO controller Starting EventSource {"reconcilerGroup": "keda.sh", "reconcilerKind": "ScaledObject", "controller": "scaledobject", "source": "kind source: /, Kind="} 2021-06-04T08:06:20.130Z INFO controller Starting EventSource {"reconcilerGroup": "keda.sh", "reconcilerKind": "TriggerAuthentication", "controller": "triggerauthentication", "source": "kind source: /, Kind="} 2021-06-04T08:06:20.230Z INFO controller Starting Controller {"reconcilerGroup": "keda.sh", "reconcilerKind": "ClusterTriggerAuthentication", "controller": "clustertriggerauthentication"} 2021-06-04T08:06:20.230Z INFO controller Starting workers {"reconcilerGroup": "keda.sh", "reconcilerKind": "ClusterTriggerAuthentication", "controller": "clustertriggerauthentication", "worker count": 1} 2021-06-04T08:06:20.230Z INFO controller Starting Controller {"reconcilerGroup": "keda.sh", "reconcilerKind": "TriggerAuthentication", "controller": "triggerauthentication"} 2021-06-04T08:06:20.230Z INFO controller Starting workers {"reconcilerGroup": "keda.sh", "reconcilerKind": "TriggerAuthentication", "controller": "triggerauthentication", "worker count": 1} 2021-06-04T08:06:20.230Z INFO controller Starting EventSource {"reconcilerGroup": "keda.sh", "reconcilerKind": "ScaledObject", "controller": "scaledobject", "source": "kind source: /, Kind="} 2021-06-04T08:06:20.232Z INFO controller Starting Controller {"reconcilerGroup": "keda.sh", "reconcilerKind": "ScaledJob", "controller": "scaledjob"} 2021-06-04T08:06:20.330Z INFO controller Starting Controller {"reconcilerGroup": "keda.sh", "reconcilerKind": "ScaledObject", "controller": "scaledobject"} 2021-06-04T08:06:20.331Z INFO controller Starting workers {"reconcilerGroup": "keda.sh", "reconcilerKind": "ScaledObject", "controller": "scaledobject", "worker count": 1} 2021-06-04T08:06:20.332Z INFO controller Starting workers {"reconcilerGroup": "keda.sh", "reconcilerKind": "ScaledJob", "controller": "scaledjob", "worker count": 1} 2021-06-04T08:07:19.986Z INFO controllers.ScaledObject Reconciling ScaledObject {"ScaledObject.Namespace": "xyz", "ScaledObject.Name": "mssql-keda-scaledobject"} 2021-06-04T08:07:19.986Z INFO controllers.ScaledObject Adding Finalizer for the ScaledObject {"ScaledObject.Namespace": "xyz", "ScaledObject.Name": "mssql-keda-scaledobject"} 2021-06-04T08:07:20.052Z INFO controllers.ScaledObject Detected resource targeted for scaling {"ScaledObject.Namespace": "xyz", "ScaledObject.Name": "mssql-keda-scaledobject", "resource": "apps/v1.Deployment", "name": "xyzxyzxyzxyzxyzxyzxyz"} 2021-06-04T08:07:20.052Z INFO controllers.ScaledObject Creating a new HPA {"ScaledObject.Namespace": "xyz", "ScaledObject.Name": "mssql-keda-scaledobject", "HPA.Namespace": "xyz", "HPA.Name": "keda-hpa-mssql-keda-scaledobject"}

I'm getting hpa created for other scaled objects. Also if I'm providing sql connection credentials wrong, I'm getting appropriate authentication error. So I guess this is not a connection issue.

Any leads would be greatly appreciated. Thanks in advance


Solution

  • I also had issues when I started using the MSSQL Trigger for KEDA on an Azure Function app in Azure Kubernetes Service.

    I faced a couple issues so you could try checking these out as well:

    KEDA VERSION

    KEDA version 2.2 was the first version to support the MSSQL trigger, I had to get the operator logs for keda-operator to figure out that the MSSQL trigger could not be found using version 2.1 of KEDA. Your operator logs don't seem to say "cannot find trigger MSSQL" but you could double check. I have had the best luck with KEDA 2.4 which you can install using these instructions: https://keda.sh/docs/2.4/deploy/

    Troubleshooting ScaledObject Issues

    You can start by finding the name of your ScaledObject with

    kubectl get scaledobject -A
    

    Then describe the ScaledObject, and you should see any errors or issues listed towards the bottom such as authentication issues or issues creating an HPA for KEDA:

    kubectl describe scaledobject <your-scaled-object-name> 
    

    Ultimately my issue required installing the right version of KEDA, and also modifying my MSSQL connection string.