Skip to content
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.

Support sb topic subscriptions #59

Merged
merged 24 commits into from
Jun 28, 2019
Merged

Conversation

jsturtevant
Copy link
Collaborator

Allow for users of the metrics adapter to gather message counts from Azure Service Bus Topic Subscriptions to decide their scaling targets

Closes #42

This replaces #49 which I didn't have permission to push updates too. Thanks to @marc-sensenich for the initial implementation.

@jsturtevant
Copy link
Collaborator Author

cc: @lee0c

@tomkerkhove
Copy link
Member

We might want to add queues as well in a new PR

@paaland
Copy link

paaland commented Mar 12, 2019

Can the pipleline be fixed so we can get this? Subscription message count is what I'm waiting for....

@jsturtevant jsturtevant force-pushed the support-sb-topic-subscriptions branch from 1575d76 to 39b5350 Compare March 15, 2019 20:31
@jsturtevant jsturtevant force-pushed the support-sb-topic-subscriptions branch from 59d7e8e to a64dcdf Compare March 26, 2019 04:35
@jsturtevant
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@tomkerkhove
Copy link
Member

I don't like your motivation @azure-pipelines, try harder!

Also, it's not easy to configure this app correctly ☹️

@jsturtevant
Copy link
Collaborator Author

It seems that Azure devops does find the pipeline as it started to run. Have not figured out why it sends that message.

Which app is not easy to configure?

@tomkerkhove
Copy link
Member

I find the Azure Pipelines GitHub app not easy to setup, but that might just be me..

@jsturtevant
Copy link
Collaborator Author

/azp run image-pipeline

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

hack/e2e-scripts/configure-topic-subscriptions-metrics.sh Outdated Show resolved Hide resolved
hack/e2e-scripts/run-topic-consumer.sh Outdated Show resolved Hide resolved
samples/servicebus-queue/readme.md Show resolved Hide resolved
samples/servicebus-queue/readme.md Show resolved Hide resolved
CONTRIBUTING.md Show resolved Hide resolved
CONTRIBUTING.md Show resolved Hide resolved
@aminebizid
Copy link

Any news guys

@aminebizid
Copy link

aminebizid commented May 5, 2019

Hello,
I couldn't get the metrics using this PR on my 1.13 K8S:

My External Metric

apiVersion: azure.com/v1alpha2
kind: ExternalMetric
metadata:
  name: example-external-metric-service-bus-subscription
spec:
  type: servicebussubscription
  azure:
    resourceGroup: RG-TEST
    serviceBusNamespace: ttalogs
    serviceBusTopic: testk8s
    serviceBusSubscription: testk8ssub
  metric:
    # This would default to activeMessageCount, but could be updated to one of the counts from /~https://github.com/Azure/azure-sdk-for-go/blob/master/services/servicebus/mgmt/2017-04-01/servicebus/models.go#L1116
    metricName: activeMessageCount

My HPA

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
 name: consumer-scaler
spec:
 scaleTargetRef:
   apiVersion: extensions/v1beta1
   kind: Deployment
   name: consumer
 minReplicas: 1
 maxReplicas: 10
 metrics:
  - type: External
    external:
      metricName: activeMessageCount
      targetValue: 30

Testing

kubectl -n hpa get hpa consumer-scaler -w
consumer-scaler   Deployment/consumer   <unknown>/30   1         10        1          20m

k -n azure-metrics logs -f azure-metrics-azure-k8s-metrics-adapter-6bb89f96fb-nbv8v
I0505 22:01:57.976022       1 provider_external.go:24] Received request for namespace: hpa, metric name: activemessagecount, metric selectors:
I0505 22:01:57.976060       1 metric_cache.go:41] metric not found ExternalMetric/hpa/activemessagecount
I0505 22:01:57.976082       1 metricrequest.go:104] Successfully parsed AzureMetric


kubectl get --raw /apis/azure.com/v1alpha2/namespaces/hpa/externalmetrics/example-external-metric-service-bus-subscription| jq
{
  "apiVersion": "azure.com/v1alpha2",
  "kind": "ExternalMetric",
  "metadata": {
    "annotations": {
      "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"azure.com/v1alpha2\",\"kind\":\"ExternalMetric\",\"metadata\":{\"annotations\":{},\"name\":\"example-external-metric-service-bus-subscription\",\"namespace\":\"hpa\"},\"spec\":{\"azure\":{\"resourceGroup\":\"RG-TEST\",\"serviceBusNamespace\":\"ttalogs\",\"serviceBusSubscription\":\"testk8ssub\",\"serviceBusTopic\":\"testk8s\"},\"metric\":{\"metricName\":\"ActiveMessageCount\"},\"type\":\"servicebussubscription\"}}\n"
    },
    "creationTimestamp": "2019-05-05T20:59:42Z",
    "generation": 2,
    "name": "example-external-metric-service-bus-subscription",
    "namespace": "hpa",
    "resourceVersion": "3697203",
    "selfLink": "/apis/azure.com/v1alpha2/namespaces/hpa/externalmetrics/example-external-metric-service-bus-subscription",
    "uid": "b41c2510-6f78-11e9-8ce8-000d3a48b4d9"
  },
  "spec": {
    "azure": {
      "resourceGroup": "RG-TEST",
      "serviceBusNamespace": "ttalogs",
      "serviceBusSubscription": "testk8ssub",
      "serviceBusTopic": "testk8s"
    },
    "metric": {
      "metricName": "ActiveMessageCount"
    },
    "type": "servicebussubscription"
  }
}

The Field "value" is not found

How can I debug?

@jsturtevant
Copy link
Collaborator Author

@aminebizid You HPA metricName should reference the name of the External Metric which would be example-external-metric-service-bus-subscription instead of the metric name activeMessageCount

Additionally you should now check out the KEDA project for future work. Specifically topic subscriptions are supported.

@jsturtevant
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@jsturtevant jsturtevant merged commit b8f3644 into master Jun 28, 2019
@jsturtevant jsturtevant deleted the support-sb-topic-subscriptions branch June 28, 2019 04:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Service Bus Queue Topic Subscriptions
6 participants