Update declarative subscriptions (#785)

* Update declarative subscriptions

Add more details on how to use in Kubernetes/Self-Hosted.

* Update README.md

* comments
This commit is contained in:
Yaron Schneider 2020-09-11 09:49:08 -07:00 committed by GitHub
parent 382f4d5ce4
commit dbc5667eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 1 deletions

View File

@ -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`.