Updates to Pub/sub component docs

This commit is contained in:
Mark Fussell 2021-01-11 20:18:29 -08:00
parent 08c68f13bc
commit acc724fc3b
3 changed files with 113 additions and 82 deletions

View File

@ -5,6 +5,46 @@ linkTitle: "Apache Kafka"
description: "Detailed documentation on the Apache Kafka pubsub component"
---
## Format
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: kafka-pubsub
namespace: default
spec:
type: pubsub.kafka
version: v1
metadata:
# Kafka broker connection setting
- name: brokers
value: "dapr-kafka.myapp.svc.cluster.local:9092"
- name: authRequired
value: "true"
- name: saslUsername
value: "adminuser"
- name: saslPassword
value: "KeFg23!"
```
{{% alert title="Warning" color="warning" %}}
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}).
{{% /alert %}}
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| brokers | Y | Comma separated list of kafka brokers | `localhost:9092`, `dapr-kafka.myapp.svc.cluster.local:9092`
| authRequired | N | Enable authentication on the Kafka broker. Defaults to `"false"`. |`"true"`, `"false"`
| saslUsername | N | Username used for authentication. Only required if authRequired is set to true | `"adminuser"`
| saslPassword | N | Password used for authentication. Can be `secretKeyRef` to use a secret reference. Only required if authRequired is set to true | `""`, `"KeFg23!"`
## Create a Dapr component
To setup Apache Kafka pubsub, you create a component of type `pubsub.kafka`
## Setup Kafka
{{< tabs "Self-Hosted" "Kubernetes">}}
@ -19,43 +59,11 @@ To run Kafka on Kubernetes, you can use the [Helm Chart](https://github.com/helm
{{< /tabs >}}
## Create a Dapr component
The next step is to create a Dapr component for Kafka.
Create the following YAML file named `kafka.yaml`:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: pubsub.kafka
version: v1
metadata:
# Kafka broker connection setting
- name: brokers
# Comma separated list of kafka brokers
value: "dapr-kafka.dapr-tests.svc.cluster.local:9092"
# Enable auth. Default is "false"
- name: authRequired
value: "false"
# Only available is authRequired is set to true
- name: saslUsername
value: <username>
# Only available is authRequired is set to true
- name: saslPassword
value: <password>
```
{{% alert title="Warning" color="warning" %}}
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}).
{{% /alert %}}
## Apply the configuration
Visit [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components.
## Related links
- [Basic schema for a Dapr component]({{< ref component-schema >}})
- [Pub/Sub building block]({{< ref pubsub >}})

View File

@ -5,51 +5,63 @@ linkTitle: "Azure Events Hub"
description: "Detailed documentation on the Azure Event Hubs pubsub component"
---
## Setup Azure Event Hubs
Follow the instructions [here](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-create) on setting up Azure Event Hubs.
Since this implementation uses the Event Processor Host, you will also need an [Azure Storage Account](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal).
## Create a Dapr component
The next step is to create a Dapr component for Azure Event Hubs.
Create the following YAML file named `eventhubs.yaml`:
## Format
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
name: eventhubs-pubsub
namespace: default
spec:
type: pubsub.azure.eventhubs
version: v1
metadata:
- name: connectionString
value: <REPLACE-WITH-CONNECTION-STRING> # Required. "Endpoint=sb://****"
value: "Endpoint=sb://{EventHubNamespace}.servicebus.windows.net/;SharedAccessKeyName={PolicyName};SharedAccessKey={Key};EntityPath={EventHub}"
- name: storageAccountName
value: <REPLACE-WITH-STORAGE-ACCOUNT-NAME> # Required.
value: "myeventhubstorage"
- name: storageAccountKey
value: <REPLACE-WITH-STORAGE-ACCOUNT-KEY> # Required.
value: "112233445566778899"
- name: storageContainerName
value: <REPLACE-WITH-CONTAINER-NAME > # Required.
value: "myeventhubstoragecontainer"
```
See [here](https://docs.microsoft.com/en-us/azure/event-hubs/authorize-access-shared-access-signature) on how to get the Event Hubs connection string. Note this is not the Event Hubs namespace.
{{% alert title="Warning" color="warning" %}}
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}).
{{% /alert %}}
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| connectionString | Y | Connection-string for the Event Hubs | `Endpoint=sb://{EventHubNamespace}.servicebus.windows.net/;SharedAccessKeyName={PolicyName};SharedAccessKey={Key};EntityPath={EventHub}`
| storageAccountName | Y | The storage account name to use for the EventProcessorHost |`"myeventhubstorage"`
| storageAccountKey | Y | Storage account key to use for the EventProcessorHost | `"112233445566778899"`
| storageContainerName | Y | The storage container name for the storage account name. | `"myeventhubstoragecontainer"`
## Create a Dapr component
To setup Azure Event Hubs, you create a component of type `pubsub.azure.eventhubs`
## Setup Azure Event Hubs
Follow the instructions [here](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-create) on setting up Azure Event Hubs.
Since this implementation uses the Event Processor Host, you will also need an [Azure Storage Account](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal). Follow the instructions [here](https://docs.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage) to manage the storage account access keys.
See [here](https://docs.microsoft.com/en-us/azure/event-hubs/authorize-access-shared-access-signature) on how to get the Event Hubs connection string. Note this is not the Event Hubs namespace.
## Create consumer groups for each subscriber
For every Dapr app that wants to subscribe to events, create an Event Hubs consumer group with the name of the `dapr id`.
For example, a Dapr app running on Kubernetes with `dapr.io/app-id: "myapp"` will need an Event Hubs consumer group named `myapp`.
For example, a Dapr app running on Kubernetes with `dapr.io/app-id: "myapp"` will need an Event Hubs consumer group named `myapp`.
Note: Dapr passes the name of the Consumer group to the EventHub and so this is not supplied in the metadata.
## Apply the configuration
Visit [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components.
## Related links
- [Pub/Sub building block]({{< ref pubsub >}})
- [Basic schema for a Dapr component]({{< ref component-schema >}})
- [Pub/Sub building block]({{< ref pubsub >}})

View File

@ -6,6 +6,45 @@ description: "Detailed documentation on the Redis Streams pubsub component"
weight: 100
---
## Format
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: redis-pubsub
namespace: default
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: "KeFg23!"
- name: consumerID
value: "myGroup"
- name: enableTLS
value: "false"
```
{{% alert title="Warning" color="warning" %}}
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}).
{{% /alert %}}
## Spec metadata fields
| Field | Required | Details | Example |
|--------------------|:--------:|---------|---------|
| redisHost | Y | Connection-string for the redis host | `localhost:6379`, `redis-master.default.svc.cluster.local:6379`
| redisPassword | Y | Password for Redis host. No Default. Can be `secretKeyRef` to use a secret reference | `""`, `"KeFg23!"`
| consumerID | N | The consumer group ID | `"myGroup"`
| enableTLS | N | If the Redis instance supports TLS with public certificates, can be configured to be enabled or disabled. Defaults to `"false"` | `"true"`, `"false"`
## Create a Dapr component
To setup Redis Streams pubsub, you create a component of type `pubsub.redis`
## Setup a Redis instance
Dapr can use any Redis instance - containerized, running on your local dev machine, or a managed cloud service, provided the version of Redis is 5.0.0 or later. If you already have a Redis instance > 5.0.0 installed, move on to the [Configuration](#configuration) section.
@ -62,35 +101,6 @@ You can use [Helm](https://helm.sh/) to quickly create a Redis instance in our K
{{< /tabs >}}
## Create a Dapr component
To setup Redis, you need to create a component for `pubsub.redis`.
The following yaml files demonstrates how to define each. If the Redis instance supports TLS with public certificates it can be configured to enable or disable TLS in the yaml.
Create a file called pubsub.yaml, and paste the following:
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: messagebus
namespace: default
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: <HOST>
- name: redisPassword
value: <PASSWORD>
- name: enableTLS
value: <bool>
```
{{% alert title="Warning" color="warning" %}}
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}).
{{% /alert %}}
## Apply the configuration
@ -101,4 +111,5 @@ The Dapr CLI automatically deploys a redis instance and creates Dapr components
Visit [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components.
## Related links
- [Basic schema for a Dapr component]({{< ref component-schema >}})
- [Pub/Sub building block]({{< ref pubsub >}})