keda icon indicating copy to clipboard operation
keda copied to clipboard

Provide support for using SAS token in Service Bus scaler

Open tomkerkhove opened this issue 2 years ago • 22 comments

Proposal

Provide support for using SAS token in Service Bus scaler.

Use-Case

Different scenario for authentication, similar to https://github.com/kedacore/keda/issues/2705

Anything else?

No response

tomkerkhove avatar Apr 20 '22 06:04 tomkerkhove

Working on this.

sushmithavangala avatar Apr 26 '22 09:04 sushmithavangala

@tomkerkhove quick doubt - SAS authentication is currently handled if it's provided through the connection string. Are we looking at a provision to use SAS token other than through connection string?

sushmithavangala avatar Apr 26 '22 11:04 sushmithavangala

If that's the case then we can close it, I thought we didn't support that yet.

Thanks for checking!

tomkerkhove avatar Apr 26 '22 11:04 tomkerkhove

@tomkerkhove @SushmithaVReddy I try to setup scaledObject with trigger "azure-servicebus" that uses SAS token(trigger authentication ---> k8s secret). At the current moment KEDA 2.6 doesn't support this feature.

When I deploy the scaledObject with SAS token, I get ' "Endpoint" must not be empty' error message.

https://github.com/Azure/azure-amqp-common-go/blob/6b7304f631077f049a7249a2f36fe87e5c27b674/conn/conn.go#L100

Could you try to use new lib for Azure Service Bus where you can send SAS token as connection parameter?

https://github.com/Azure/azure-sdk-for-go/blob/241bdb849ce431e1a5e398a5649cde93149ee374/sdk/messaging/azservicebus/client.go#L92

zzhakhin avatar Apr 27 '22 08:04 zzhakhin

@SushmithaVReddy Can you verify this please?

tomkerkhove avatar Apr 27 '22 08:04 tomkerkhove

Hi @zzhakhin , are you using a key value pair like "connectionString" : " Endpoint=sb://.servicebus.windows.net;SharedAccessSignature=SharedAccessSignature sr=.servicebus.windows.net&sig=&se=&skn=" in your trigger auth CRD referred in scaled object?

sushmithavangala avatar Apr 27 '22 08:04 sushmithavangala

Hi @SushmithaVReddy. These are my setup

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: worker-scaledobject
  namespace: somenamespace
spec:
  scaleTargetRef:
    name: nameofpod
  pollingInterval: 30
  cooldownPeriod: 300
  minReplicaCount: 1
  maxReplicaCount: 3
  advanced:
    restoreToOriginalReplicaCount: true
  triggers:
  - type: azure-servicebus
    metadata:
      queueName: queue-name
      messageCount: "5"
    authenticationRef:
      name: worker-trigger-authentication
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: worker-trigger-authentication
  namespace: somenamespace
spec:
  secretTargetRef:
  - parameter: connection
    name: worker-queue-secret
    key: queue-connection-string

And I create secret with key:value

queue-connection-string='SharedAccessSignature sr=https://servicebussand.servicebus.windows.net/queue-name&sig=<Signature>&se=<Unixtime>&skn=root'

zzhakhin avatar Apr 27 '22 08:04 zzhakhin

@zzhakhin thanks for sharing the yaml content. You are getting the Endpoint can't be null error because the connection string you are providing in your secret doesn't have endpoint information. For eg: Connection string can be defined in two ways

  1. Endpoint=sb://.servicebus.windows.net/;SharedAccessKeyName=;SharedAccessKey=
  2. Endpoint=sb://.servicebus.windows.net;SharedAccessSignature=SharedAccessSignature sr=.servicebus.windows.net&sig=&se=&skn=

I understand you want to use the 2nd way of pointing connection string. If that's the case, yes, keda doesn't support it yet.(tag: @tomkerkhove )

sushmithavangala avatar Apr 27 '22 09:04 sushmithavangala

We use the older Service Bus sdk .

It only supports connection strings of the first type -

Endpoint=sb://<sb>.servicebus.windows.net/;SharedAccessKeyName=<key name>;SharedAccessKey=<key value>

and not

Endpoint=sb://<sb>.servicebus.windows.net;SharedAccessSignature=SharedAccessSignature sr=<sb>.servicebus.windows.net&sig=<base64-sig>&se=<expiry>&skn=<keyname>

In fact, if I recall correctly, service bus is not the only place we use the older Azure SDKs. We should ideally be migrating to the newer versions for all of the Azure scalers.

v-shenoy avatar Apr 27 '22 09:04 v-shenoy

@tomkerkhove should we work on migrating to the sdk that seems to be maintained - https://github.com/Azure/azure-sdk-for-go

sushmithavangala avatar Apr 27 '22 10:04 sushmithavangala

Endpoint=sb://<sb>.servicebus.windows.net;SharedAccessSignature=SharedAccessSignature sr=<sb>.servicebus.windows.net&sig=<base64-sig>&se=<expiry>&skn=<keyname>

The goal of the issue was actually to support this scenario which I thought we were supporting but I've misread. Can you work on this please @SushmithaVReddy?

tomkerkhove avatar Apr 27 '22 11:04 tomkerkhove

@tomkerkhove quick pointer - https://github.com/Azure/azure-sdk-for-go/blob/main/README.md requires go1.18+ and keda supports go1.17+ , so we'll have to modify this https://github.com/kedacore/keda/blob/ac86c9455b9c2272b3e0158457587d9869da8b07/go.mod#L3 to 1.18 . Let me know if this understanding is right and any repercussions on customers using <= 1.17.

sushmithavangala avatar Apr 29 '22 12:04 sushmithavangala

Let's do a seperate PR to bump to go 1.18 unless @kedacore/keda-maintainers don't agree?

But we might want to hold this off until KEDA 2.7 is shipped on thursday.

tomkerkhove avatar Apr 29 '22 14:04 tomkerkhove

I don't have any strong opinion about that, but I'm really interested on @zroubalik opinion here

JorTurFer avatar Apr 29 '22 14:04 JorTurFer

@tomkerkhove if we have to do this separately we'll have to 1st migrate KEDA to 1.18 and only then push fix for https://github.com/kedacore/keda/issues/2920.

sushmithavangala avatar May 09 '22 05:05 sushmithavangala

@zroubalik Any reason why we didn't go to 1.18 in https://github.com/kedacore/keda/pull/3019?

tomkerkhove avatar May 09 '22 06:05 tomkerkhove

@tomkerkhove 1.18 is relatively new. I want to wait a couple of micro release for it. And also majority of libs that we depend on (k8s) aren't build on top of 1.18. It might bring problems with code generators etc.

zroubalik avatar May 09 '22 11:05 zroubalik

Let's put this on hold then @SushmithaVReddy!

tomkerkhove avatar May 09 '22 12:05 tomkerkhove

Even though the docs mention go1.18 this package is already being used in the repo.

v-shenoy avatar Jun 07 '22 06:06 v-shenoy

Then we should revise this, unless the limitation is just for Azure Service Bus.

tomkerkhove avatar Jun 07 '22 08:06 tomkerkhove

They migrated to 1.18 in March as per this PR. But I don't think they're using any of the new 1.18 features.

v-shenoy avatar Jun 07 '22 08:06 v-shenoy

Honestly, it's confusing as to how this repo works to me. It's a monorepo with all of SDKs for multiple Azure offerings. Some of them have individual go.mod files, some of them don't. There are also multiple versions of the same package in the repo so that users can import older ones if required.

It's a bit of a headache.

v-shenoy avatar Jun 07 '22 08:06 v-shenoy