From dbc5667eba23014cdaa32d178769caa2368f1a42 Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Fri, 11 Sep 2020 09:49:08 -0700 Subject: [PATCH] Update declarative subscriptions (#785) * Update declarative subscriptions Add more details on how to use in Kubernetes/Self-Hosted. * Update README.md * comments --- howto/consume-topic/README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/howto/consume-topic/README.md b/howto/consume-topic/README.md index 2c423599f..e5f6dd5f6 100644 --- a/howto/consume-topic/README.md +++ b/howto/consume-topic/README.md @@ -38,7 +38,7 @@ Dapr allows two methods by which you can subscribe to topics: programatically, w ### Declarative subscriptions -You can subscribe to a topic using the following CRD: +You can subscribe to a topic using the following Custom Resources Definition (CRD): ```yaml apiVersion: dapr.io/v1alpha1 @@ -76,6 +76,27 @@ app.post('/orders', (req, res) => { app.listen(port, () => console.log(`consumer app listening on port ${port}!`)) ``` +#### Subscribing on Kubernetes + +In Kubernetes, save the CRD to a file and apply it to the cluster: + +``` +kubectl apply -f subscription.yaml +``` + +#### Subscribing in Self Hosted + +When running Dapr in Self-hosted, either locally or on a VM, put the CRD in your `./components` directory. +When Dapr starts up, it will load subscriptions along with components. + +The following example shows how to point the Dapr CLI to a components path: + +``` +dapr run --app-id myapp --components-path ./myComponents -- python3 myapp.py +``` + +*Note: By default, Dapr loads components from $HOME/.dapr/components on MacOS/Linux and %USERPROFILE%\.dapr\components on Windows. If you place the subscription in a custom components path, make sure the Pub/Sub component is present also.* + ### Programmatic subscriptions To subscribe to topics, start a web server in the programming language of your choice and listen on the following `GET` endpoint: `/dapr/subscribe`.