mirror of https://github.com/dapr/docs.git
Document on Component metadata. (#1141)
* Document on Component metadata. * Update component-schema.md * Update setup-mqtt.md * Update component-schema.md Co-authored-by: Mark Fussell <mfussell@microsoft.com>
This commit is contained in:
parent
25be2fd366
commit
f70c9645be
|
|
@ -42,6 +42,31 @@ spec:
|
||||||
| spec.ignoreErrors | N | Tells the Dapr sidecar to continue initialization if the component fails to load. Default is false | `false`
|
| spec.ignoreErrors | N | Tells the Dapr sidecar to continue initialization if the component fails to load. Default is false | `false`
|
||||||
| **spec.metadata** | - | **A key/value pair of component specific configuration. See your component definition for fields**|
|
| **spec.metadata** | - | **A key/value pair of component specific configuration. See your component definition for fields**|
|
||||||
|
|
||||||
|
### Special metadata values
|
||||||
|
|
||||||
|
Metadata values can contain a `{uuid}` tag that is replaced with a randomly generate UUID when the Dapr sidecar starts up. A new UUID is generated on every start up. It can be used, for example, to have a pod on Kubernetes with multiple application instances consuming a [shared MQTT subscription]({{< ref "setup-mqtt.md" >}}). Below is an example of using the `{uuid}` tag.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: dapr.io/v1alpha1
|
||||||
|
kind: Component
|
||||||
|
metadata:
|
||||||
|
name: messagebus
|
||||||
|
spec:
|
||||||
|
type: pubsub.mqtt
|
||||||
|
version: v1
|
||||||
|
metadata:
|
||||||
|
- name: consumerID
|
||||||
|
value: "{uuid}"
|
||||||
|
- name: url
|
||||||
|
value: "tcp://admin:public@localhost:1883"
|
||||||
|
- name: qos
|
||||||
|
value: 1
|
||||||
|
- name: retain
|
||||||
|
value: "false"
|
||||||
|
- name: cleanSession
|
||||||
|
value: "false"
|
||||||
|
```
|
||||||
|
|
||||||
## Further reading
|
## Further reading
|
||||||
- [Components concept]({{< ref components-concept.md >}})
|
- [Components concept]({{< ref components-concept.md >}})
|
||||||
- [Reference secrets in component definitions]({{< ref component-secrets.md >}})
|
- [Reference secrets in component definitions]({{< ref component-secrets.md >}})
|
||||||
|
|
@ -49,4 +74,4 @@ spec:
|
||||||
- [Supported pub/sub brokers]({{< ref supported-pubsub >}})
|
- [Supported pub/sub brokers]({{< ref supported-pubsub >}})
|
||||||
- [Supported secret stores]({{< ref supported-secret-stores >}})
|
- [Supported secret stores]({{< ref supported-secret-stores >}})
|
||||||
- [Supported bindings]({{< ref supported-bindings >}})
|
- [Supported bindings]({{< ref supported-bindings >}})
|
||||||
- [Set component scopes]({{< ref component-scopes.md >}})
|
- [Set component scopes]({{< ref component-scopes.md >}})
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ metadata:
|
||||||
namespace: default
|
namespace: default
|
||||||
spec:
|
spec:
|
||||||
type: pubsub.mqtt
|
type: pubsub.mqtt
|
||||||
|
version: v1
|
||||||
metadata:
|
metadata:
|
||||||
- name: url
|
- name: url
|
||||||
value: "tcps://host.domain[:port]"
|
value: "tcps://host.domain[:port]"
|
||||||
|
|
@ -71,6 +72,32 @@ spec:
|
||||||
value: ''
|
value: ''
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Consuming a shared topic
|
||||||
|
|
||||||
|
When consuming a shared topic, each consumer must have a unique identifier. By default, the application Id is used to uniquely identify each consumer and publisher. In self-hosted mode, running each Dapr run with a different application Id is sufficient to have them consume from the same shared topic. However on Kubernetes, a pod with multiple application instances shares the same application Id, prohibiting all instances from consuming the same topic. To overcome this, configure the component's `ConsumerID` metadata with a `{uuid}` tag, making each instance to have a randomly generated `ConsumerID` value on start up. For example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: dapr.io/v1alpha1
|
||||||
|
kind: Component
|
||||||
|
metadata:
|
||||||
|
name: messagebus
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
type: pubsub.mqtt
|
||||||
|
version: v1
|
||||||
|
metadata:
|
||||||
|
- name: consumerID
|
||||||
|
value: "{uuid}"
|
||||||
|
- name: url
|
||||||
|
value: "tcp://admin:public@localhost:1883"
|
||||||
|
- name: qos
|
||||||
|
value: 1
|
||||||
|
- name: retain
|
||||||
|
value: "false"
|
||||||
|
- name: cleanSession
|
||||||
|
value: "false"
|
||||||
|
```
|
||||||
|
|
||||||
{{% alert title="Warning" color="warning" %}}
|
{{% 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 >}}).
|
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 %}}
|
{{% /alert %}}
|
||||||
|
|
@ -149,4 +176,4 @@ You can then interact with the server using the client port: `tcp://mqtt-broker.
|
||||||
## Related links
|
## Related links
|
||||||
- [Basic schema for a Dapr component]({{< ref component-schema >}})
|
- [Basic schema for a Dapr component]({{< ref component-schema >}})
|
||||||
- Read [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components
|
- Read [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components
|
||||||
- [Pub/Sub building block]({{< ref pubsub >}})
|
- [Pub/Sub building block]({{< ref pubsub >}})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue