-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaler for GCP PubSub #274
Scaler for GCP PubSub #274
Conversation
Merging changes from main
Remove imagePullSecrets (kedacore#272)
This is for issue 141 |
Merged from Upstream
Merged from Upstream kedacore/keda:master
Merge from kedacore/keda - master
@ahmelsayed could you please review this change? It's a scaler for GCP pub sub and uses the Stackdriver API to fin the number of pending messages in a subscription. |
@patnaikshekhar very sorry about the delay for your 2 PRs. I wanted to learn a bit more about both GCP PubSub and AAD Pods and get to try it before merging but kept getting randomized. I'll finish my review by Monday. |
No problem. I'm in the process of creating samples so that might help! :) |
@patnaikshekhar the code looks fine to me. however trying it I'm getting this error:
I have a simple nodejs producer pubsub
.topic('projects/swift-kiln-183720/topics/stuff')
.publisher
.publish(Buffer.from(new Date() + ''))
.then(messageId => {
console.log(`Message ${messageId} published.`);
})
.catch(err => {
console.error('ERROR:', err);
}) and consumer const subscription = pubsub.subscription('projects/swift-kiln-183720/subscriptions/foo')
subscription.on(`message`, msg => {
console.log(msg)
msg.ack()
}) I can see my producer and consumer working. This is my trigger in the scaledObject - type: gcp-pubsub
metadata:
subscriptionSize: "5"
subscriptionName: "projects/swift-kiln-183720/subscriptions/foo"
credentials: googcreds I'm just learning about PubSub so excuse me if it's a very dummy question. |
@ahmelsayed have you given the service account access to view stackdriver logs? gcloud projects add-iam-policy-binding $PROJECT_ID Additionally the subscription name is just the name of the subscription without the project ID. I'm automatically picking up the project ID from the JSON of the service account. (Maybe I shouldn't be?) kubectl create secret generic pubsub-secret apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
name: pubsub-scaledobject
namespace: keda-pubsub-test
labels:
deploymentName: keda-pubsub-go
spec:
scaleTargetRef:
deploymentName: keda-pubsub-go
triggers:
- type: gcp-pubsub
metadata:
subscriptionSize: "5"
subscriptionName: "sub1" # Required
credentials: GOOGLE_APPLICATION_CREDENTIALS_JSON # Required
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: keda-pubsub-go
namespace: keda-pubsub-test
spec:
selector:
matchLabels:
service: keda-pubsub-go
replicas: 1
template:
metadata:
labels:
service: keda-pubsub-go
spec:
containers:
- image: patnaikshekhar/keda-pubsub-sample:1
name: consumer
env:
- name: SUBSCRIPTION_NAME
value: "sub1"
- name: GOOGLE_APPLICATION_CREDENTIALS_JSON
valueFrom:
secretKeyRef:
name: pubsub-secret
key: GOOGLE_APPLICATION_CREDENTIALS_JSON I'm out of office today.. but I'll publish the sample tomorrow containing all the steps required |
@ahmelsayed here is a link to the WIP tutorial for this scaler. |
Followed your tutorial and everything worked for me! Thank you very much @patnaikshekhar for your contribution and sorry it took me a while to get to the PR. |
@patnaikshekhar I think it would be nice if we add your repo (https://github.com/patnaikshekhar/KEDA-GCP-PubSub-Sample) to the kedacore org as another sample repo like the ones here. I can fork it into the kedacore org, or create a new one. Not sure what you'd prefer. /cc @jeffhollan |
* Added GCP PubSub scaler * Added GCP PubSub scaler * Ran dep ensure again after merging with GCP Scaler Former-commit-id: c7dc513
* Added GCP PubSub scaler * Added GCP PubSub scaler * Ran dep ensure again after merging with GCP Scaler Former-commit-id: 7d42275
* update only when spec is changed Former-commit-id: f640458 * update only when spec is changed * remove unused script Former-commit-id: ac7b28f * remove unused script * HPA update on scaled object change Former-commit-id: 78a1d6d * HPA update on scaled object change * updating readme (#137) Former-commit-id: 36eada5 * updating readme (#137) * Update README.md Minor replacement from scalar to scaler on readme Former-commit-id: aa306ad * Update README.md Minor replacement from scalar to scaler on readme * adding GIF to README (#140) Former-commit-id: 82b32c1 * adding GIF to README (#140) * Update default tag in the helm chart Former-commit-id: 6b55d7e * Update default tag in the helm chart * Update default tag in the helm chart Former-commit-id: 661b106 * Update default tag in the helm chart * Update Makefile Former-commit-id: 9118d22 * Update Makefile * README changing default helm install Former-commit-id: b4890f2 * README changing default helm install * Add a boilerplate.go.txt for autogenrated files Closes #143 Former-commit-id: 925c508 * Add a boilerplate.go.txt for autogenrated files Closes #143 * kafka - don't scale beyond number of partitions Former-commit-id: 0eaa52c * kafka - don't scale beyond number of partitions * Fix scaler tests error re: default connection setting change Former-commit-id: cfb8f17 * Fix scaler tests error re: default connection setting change * don't scale if deployment is nil Former-commit-id: a6cf946 * don't scale if deployment is nil * return before iterating scalers if deployment is nil Former-commit-id: a44eeba * return before iterating scalers if deployment is nil * Use configmap/secret key names instead of env var name in function calls Former-commit-id: da0007f * Use configmap/secret key names instead of env var name in function calls * Update README.md Former-commit-id: a538f81 * Update README.md * updating README Former-commit-id: 2d321a9 * updating README * replacing image Former-commit-id: aaf0a08 * replacing image * Emphasize Project Status (#163) Former-commit-id: a5b86b2 * Emphasize Project Status (#163) * Tweak logo so it works on white backgrounds. (#174) Former-commit-id: 5efba2a * Tweak logo so it works on white backgrounds. (#174) * fixing example labels Former-commit-id: fb81ff7 * fixing example labels * prevent hpa from getting 0 for MinReplicaCount Former-commit-id: a7f8ff0 * prevent hpa from getting 0 for MinReplicaCount * Configure Kubevalidator Former-commit-id: 97d6dbc * Configure Kubevalidator * fix update ScaledObject Former-commit-id: 62cad00 * fix update ScaledObject * fix typos (#183) * Update scaler.go fix typo * Update kafka_scaler.go fix typo * Update rabbitmq_scaler.go fix typo * Update kafka_scaler.go resolve requested change Former-commit-id: 7d31b26 * fix typos (#183) * Update scaler.go fix typo * Update kafka_scaler.go fix typo * Update rabbitmq_scaler.go fix typo * Update kafka_scaler.go resolve requested change * update scaledObject Former-commit-id: b1ea9ca * update scaledObject * Fix glob for examples for Kubevalidator (#193) Fix glob for examples for Kubevalidator but it won't be able to validate our own objects. Kudos to @zach-dunton-sf for pointing this out Former-commit-id: 7eead79 * Fix glob for examples for Kubevalidator (#193) Fix glob for examples for Kubevalidator but it won't be able to validate our own objects. Kudos to @zach-dunton-sf for pointing this out * Update kubevalidator.yaml Former-commit-id: efa7f9d * Update kubevalidator.yaml * Improved kafka scaler debug log Former-commit-id: 09018fe * Improved kafka scaler debug log * simplify Former-commit-id: aba95d0 * simplify * Updating README meeting timezone Former-commit-id: cab3cde * Updating README meeting timezone * Multiple logos Former-commit-id: cebce8f * Multiple logos * Add Keda Logo to Helm Chart Former-commit-id: 291169f * Add Keda Logo to Helm Chart * Basic Helm chart README (#207) Former-commit-id: 0e41b2d * Basic Helm chart README (#207) * Add singular and short names to scaledobject spec (#211) * Add singular and short names to scaledobject spec * Delete second shortname Former-commit-id: 0feeec0 * Add singular and short names to scaledobject spec (#211) * Add singular and short names to scaledobject spec * Delete second shortname * Feature/add sqs scaler (#191) * Initial sqs scaler * Update aws_sqs_queue_scaler.go * Add AWS SQS scaler. * Add example AwsSqsQueue Scaled Object. * Update Aws Sqs Scaler test. * Add vedored libraries Former-commit-id: 11ff32f * Feature/add sqs scaler (#191) * Initial sqs scaler * Update aws_sqs_queue_scaler.go * Add AWS SQS scaler. * Add example AwsSqsQueue Scaled Object. * Update Aws Sqs Scaler test. * Add vedored libraries * fix sqs auth, remove hardcoded region Former-commit-id: 3cef947 * fix sqs auth, remove hardcoded region * fixed sqs test Former-commit-id: c4cc7bc * fixed sqs test * fix scale from zero when minReplicaCount is 0 (#227) Former-commit-id: 8feec5f * fix scale from zero when minReplicaCount is 0 (#227) * update kafka test with latst metadata (#229) Former-commit-id: fc43cee * update kafka test with latst metadata (#229) * allow multiple containers on deployment Former-commit-id: d7853e5 * allow multiple containers on deployment * handle nil container if containerName not found Former-commit-id: 57bb8af * handle nil container if containerName not found * Updated scaledobject.yaml with containerName Former-commit-id: a8598b9 * Updated scaledobject.yaml with containerName * Update pkg/scalers/aws_sqs_queue_scaler.go Co-Authored-By: Ahmed ElSayed <[email protected]> Former-commit-id: 0352b3a * Update pkg/scalers/aws_sqs_queue_scaler.go Co-Authored-By: Ahmed ElSayed <[email protected]> * tab fix, remove redundant check Former-commit-id: f9174a4 * tab fix, remove redundant check * Read me updates for minikube, HPA Former-commit-id: adcf29a * Read me updates for minikube, HPA * Update README.md Co-Authored-By: Jeff Hollan <[email protected]> Former-commit-id: 89375aa * Update README.md Co-Authored-By: Jeff Hollan <[email protected]> * Update README.md Co-Authored-By: Jeff Hollan <[email protected]> Former-commit-id: ec7dc52 * Update README.md Co-Authored-By: Jeff Hollan <[email protected]> * Add prometheus scaler (#252) * Add prometheus scaler * remove disableScaleToZero Former-commit-id: 35c0cc4 * Add prometheus scaler (#252) * Add prometheus scaler * remove disableScaleToZero * enable ARM deployment Former-commit-id: 592932f * enable ARM deployment * Custom metrics API service removal and external metrics list (#258) * Removing custom metrics adapater and adding external metrics list. * Change refCount check to ==0 instead of <=0 for removal from ExternalMetricsList Former-commit-id: 0cf7c44 * Custom metrics API service removal and external metrics list (#258) * Removing custom metrics adapater and adding external metrics list. * Change refCount check to ==0 instead of <=0 for removal from ExternalMetricsList * fix aws sqs test (#256) Former-commit-id: 47d62a6 * fix aws sqs test (#256) * HPA creation retry when scaled object validation fails Former-commit-id: 2d6e2d7 * HPA creation retry when scaled object validation fails * Provide list of configuration values for Helm Chart Signed-off-by: Tom Kerkhove <[email protected]> Former-commit-id: 0aea9da * Provide list of configuration values for Helm Chart Signed-off-by: Tom Kerkhove <[email protected]> * Added Redis scaler (#266) * Added redis scaler * Made changes for review comments * Added doc strings to methods in redis scaler Former-commit-id: 793440c * Added Redis scaler (#266) * Added redis scaler * Made changes for review comments * Added doc strings to methods in redis scaler * Added test for RabbitMQ Former-commit-id: ff8f43f * Added test for RabbitMQ * RabbitMQ Tests - Fixed hostname Former-commit-id: c68247c * RabbitMQ Tests - Fixed hostname * Fix tests Former-commit-id: 6528b8c * Fix tests * Enable CI unit tests Former-commit-id: 4e27a75 * Enable CI unit tests * Remove imagePullSecrets (#272) Former-commit-id: 0cb6bfd * Remove imagePullSecrets (#272) * Update README.md Former-commit-id: 66efaa3 * Update README.md * Scaler for Azure Event Hub (#259) * Created scaler for Azure Event Hub * Returned more errors and created Azure Storage file * Change image back to kedacore * Small changes to code * Read blob storage set up by eventhub-triggered functions * Change trigger name back to azure-eventhub * Change event hub metadata setting and constants, other minor changes * Change ParseStorageConnection method to also parse endpoint protocol and endpoint suffix * Create example yaml for event hub scaled object * Add comments Former-commit-id: 98b50e7 * Scaler for Azure Event Hub (#259) * Created scaler for Azure Event Hub * Returned more errors and created Azure Storage file * Change image back to kedacore * Small changes to code * Read blob storage set up by eventhub-triggered functions * Change trigger name back to azure-eventhub * Change event hub metadata setting and constants, other minor changes * Change ParseStorageConnection method to also parse endpoint protocol and endpoint suffix * Create example yaml for event hub scaled object * Add comments * Event Hub Scaler (#276) * Created scaler for Azure Event Hub * Returned more errors and created Azure Storage file * Change image back to kedacore * Small changes to code * Read blob storage set up by eventhub-triggered functions * Change trigger name back to azure-eventhub * Change event hub metadata setting and constants, other minor changes * Change ParseStorageConnection method to also parse endpoint protocol and endpoint suffix * Create example yaml for event hub scaled object * Add comments * Comment out test Former-commit-id: 526d109 * Event Hub Scaler (#276) * Created scaler for Azure Event Hub * Returned more errors and created Azure Storage file * Change image back to kedacore * Small changes to code * Read blob storage set up by eventhub-triggered functions * Change trigger name back to azure-eventhub * Change event hub metadata setting and constants, other minor changes * Change ParseStorageConnection method to also parse endpoint protocol and endpoint suffix * Create example yaml for event hub scaled object * Add comments * Comment out test * Update tests that use ParseStorageConnectionString (#277) * Created scaler for Azure Event Hub * Returned more errors and created Azure Storage file * Change image back to kedacore * Small changes to code * Read blob storage set up by eventhub-triggered functions * Change trigger name back to azure-eventhub * Change event hub metadata setting and constants, other minor changes * Change ParseStorageConnection method to also parse endpoint protocol and endpoint suffix * Create example yaml for event hub scaled object * Add comments * Comment out test * Update tests that use ParseStorageConnectionString Former-commit-id: 69b3810 * Update tests that use ParseStorageConnectionString (#277) * Created scaler for Azure Event Hub * Returned more errors and created Azure Storage file * Change image back to kedacore * Small changes to code * Read blob storage set up by eventhub-triggered functions * Change trigger name back to azure-eventhub * Change event hub metadata setting and constants, other minor changes * Change ParseStorageConnection method to also parse endpoint protocol and endpoint suffix * Create example yaml for event hub scaled object * Add comments * Comment out test * Update tests that use ParseStorageConnectionString * Update return values for ParseAzureStorageConnectionString (#278) * Created scaler for Azure Event Hub * Returned more errors and created Azure Storage file * Change image back to kedacore * Small changes to code * Read blob storage set up by eventhub-triggered functions * Change trigger name back to azure-eventhub * Change event hub metadata setting and constants, other minor changes * Change ParseStorageConnection method to also parse endpoint protocol and endpoint suffix * Create example yaml for event hub scaled object * Add comments * Comment out test * Update tests that use ParseStorageConnectionString * Update return values for ParseAzureStorageConnectionString Former-commit-id: 8a2ba37 * Update return values for ParseAzureStorageConnectionString (#278) * Created scaler for Azure Event Hub * Returned more errors and created Azure Storage file * Change image back to kedacore * Small changes to code * Read blob storage set up by eventhub-triggered functions * Change trigger name back to azure-eventhub * Change event hub metadata setting and constants, other minor changes * Change ParseStorageConnection method to also parse endpoint protocol and endpoint suffix * Create example yaml for event hub scaled object * Add comments * Comment out test * Update tests that use ParseStorageConnectionString * Update return values for ParseAzureStorageConnectionString * Update E2E tests (#271) Former-commit-id: d8a8ef7 * Update E2E tests (#271) * Update README.md with Redis (#273) Former-commit-id: a759e6b * Update README.md with Redis (#273) * Update AWS authentication methods (#280) Former-commit-id: 63cd04f * Update AWS authentication methods (#280) * Enable builds for forks (#285) Former-commit-id: fbc1773 * Enable builds for forks (#285) * Scaler for aws cloudwatch (#282) * Adding cloudwatch metric as a scaler * Adding examples and fixing the error on null metrics received * Updating the Gopkg, removing redundant logs and adding tests * Updating the formatting for the test data * Renaming region to awsRegion * Updating the default region name and value Former-commit-id: 9a6591a * Scaler for aws cloudwatch (#282) * Adding cloudwatch metric as a scaler * Adding examples and fixing the error on null metrics received * Updating the Gopkg, removing redundant logs and adding tests * Updating the formatting for the test data * Renaming region to awsRegion * Updating the default region name and value * Update README.md Former-commit-id: 2ef94c1 * Update README.md * Update config.yml Former-commit-id: 21a562e * Update config.yml * Fix SQS tests (#283) * Fix SQS tests * Add missing vendor files Former-commit-id: 382583e * Fix SQS tests (#283) * Fix SQS tests * Add missing vendor files * Update config.yml Former-commit-id: c380a5b * Update config.yml * Update README.md Former-commit-id: 81cb843 * Update README.md * Update README.md Adding that EventHub is supported now. Former-commit-id: f81b92b * Update README.md Adding that EventHub is supported now. * Scaler for GCP PubSub (#274) * Added GCP PubSub scaler * Added GCP PubSub scaler * Ran dep ensure again after merging with GCP Scaler Former-commit-id: c7dc513 * Scaler for GCP PubSub (#274) * Added GCP PubSub scaler * Added GCP PubSub scaler * Ran dep ensure again after merging with GCP Scaler * Azure AD Pod Identity support for Azure Storage Queue (#275) * Added Azure Pod Identity support for Azure Queues * Pod Identity for Azure Queues - Updated Keda Helm chart to include labels on pods * Fixed GetAzureQueueLength to call new ParseAzureStorageConnectionString method * Fixed tests for AAd Pod Identity Metadata checks * Removed test_cases directory Former-commit-id: ba76e15 * Azure AD Pod Identity support for Azure Storage Queue (#275) * Added Azure Pod Identity support for Azure Queues * Pod Identity for Azure Queues - Updated Keda Helm chart to include labels on pods * Fixed GetAzureQueueLength to call new ParseAzureStorageConnectionString method * Fixed tests for AAd Pod Identity Metadata checks * Removed test_cases directory * Eventhub scaler test (#286) Former-commit-id: f051953 * Eventhub scaler test (#286) * Add GCP PubSub and alphabetize scalers list Former-commit-id: 731f576 * Add GCP PubSub and alphabetize scalers list * set umask value explicitly for MkdirAll (#290) - set umask value explicitly for MkdirAll - pass a file to UploadFileToBlockBob instead of a dir Former-commit-id: 864ddb5 * set umask value explicitly for MkdirAll (#290) - set umask value explicitly for MkdirAll - pass a file to UploadFileToBlockBob instead of a dir * Bump lodash from 4.17.11 to 4.17.14 in /tests (#291) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.14. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.11...4.17.14) Signed-off-by: dependabot[bot] <[email protected]> Former-commit-id: 2cac44f * Fix variable shadow in azure_queue.go (#292) Former-commit-id: 87817e9 * Added external scaler * Added example for external scaler * Fixed conflict in Azure queue * Fixed Merge conflict in scale handler * Added tests for external scaler * External Scaler - Added TLS Support * External Scaler - Fixed comments * Proposal - Move scaler specifications to GitHub repo instead of wiki (#304) * Migrate wiki to repo Signed-off-by: Tom Kerkhove <[email protected]> * Provide spec intro + seperate sample Signed-off-by: Tom Kerkhove <[email protected]> * Link to triggers from ScaledObject spec Signed-off-by: Tom Kerkhove <[email protected]> * Finalize first version Signed-off-by: Tom Kerkhove <[email protected]> * Changed serviceURI to scalerAddress. Fixed gRPC connection close * Fixed tests after changing serviceURI to scalerAddress
Signed-off-by: Rahul Rai <[email protected]>
Added new scaler for GCP PubSub. It uses the stackdriver api to determine the number of messages in the pubsub subscription