From 11b02ca9aa1055997fa02762b057da54bf824b36 Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Tue, 31 May 2022 21:29:04 -0700 Subject: [PATCH 1/3] Add namespace state strategy (#2474) * Add namespace state strategy Signed-off-by: yaron2 * Update daprdocs/content/en/developing-applications/building-blocks/state-management/howto-share-state.md Co-authored-by: Mark Fussell Co-authored-by: Mark Fussell --- .../state-management/howto-share-state.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/daprdocs/content/en/developing-applications/building-blocks/state-management/howto-share-state.md b/daprdocs/content/en/developing-applications/building-blocks/state-management/howto-share-state.md index bfe44dcfe..fd33bcc27 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/state-management/howto-share-state.md +++ b/daprdocs/content/en/developing-applications/building-blocks/state-management/howto-share-state.md @@ -16,6 +16,8 @@ To enable state sharing, Dapr supports the following key prefixes strategies: * **`appid`** - This is the default strategy. the `appid` prefix allows state to be managed only by the app with the specified `appid`. All state keys will be prefixed with the `appid`, and are scoped for the application. +* **`namespace`** - If set, this setting prefixes the `appid` key with the configured namespace, resulting in a key that is scoped to a given namespace. This allows apps in different namespace with the same `appid` to reuse the same state store. If a namespace is not configured, the setting fallbacks to the `appid` strategy. For more information on namespaces in Dapr see [How-To: Scope components to one or more applications]({{< ref component-scopes.md >}}) + * **`name`** - This setting uses the name of the state store component as the prefix. Multiple applications can share the same state for a given state store. * **`none`** - This setting uses no prefixing. Multiple applications share state across different state stores. @@ -59,6 +61,23 @@ curl -X POST http://localhost:3500/v1.0/state/redis \ The key will be saved as `myApp||darth`. +### `namespace` + +A Dapr application running in namespace `production` with app id `myApp` is saving state into a state store named `redis`: + +```shell +curl -X POST http://localhost:3500/v1.0/state/redis \ + -H "Content-Type: application/json" + -d '[ + { + "key": "darth", + "value": "nihilus" + } + ]' +``` + +The key will be saved as `production.myApp||darth`. + ### `name` A Dapr application with app id `myApp` is saving state into a state store named `redis`: From 51dfc28dd724fc404cf23c3fa4c3a11dc8ae351f Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Wed, 8 Jun 2022 09:50:46 +0530 Subject: [PATCH 2/3] Add docs for RocketMQ pubsub (#2469) * Remove Alibaba and incorporate suggestions Signed-off-by: Shubham Sharma * Update metadata Signed-off-by: Shubham Sharma --- .../supported-pubsub/_index.md | 1 + .../supported-pubsub/setup-rocketmq.md | 79 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rocketmq.md diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/_index.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/_index.md index 17c6af791..40aef862d 100644 --- a/daprdocs/content/en/reference/components-reference/supported-pubsub/_index.md +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/_index.md @@ -31,6 +31,7 @@ Table captions: | [Pulsar]({{< ref setup-pulsar.md >}}) | Alpha | v1 | 1.0 | | [RabbitMQ]({{< ref setup-rabbitmq.md >}}) | Beta | v1 | 1.6 | | [Redis Streams]({{< ref setup-redis-pubsub.md >}}) | Stable | v1 | 1.0 | +| [RocketMQ]({{< ref setup-rocketmq.md >}}) | Alpha | v1 | 1.8 | ### Amazon Web Services (AWS) diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rocketmq.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rocketmq.md new file mode 100644 index 000000000..fbfebfa27 --- /dev/null +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-rocketmq.md @@ -0,0 +1,79 @@ +--- +type: docs +title: "RocketMQ" +linkTitle: "RocketMQ" +description: "Detailed documentation on the RocketMQ pubsub component" +aliases: + - "/operations/components/setup-pubsub/supported-pubsub/setup-rocketmq/" +--- + +## Component format +To setup RocketMQ pubsub, create a component of type `pubsub.rocketmq`. See [this guide]({{< ref "howto-publish-subscribe.md#step-1-setup-the-pubsub-component" >}}) on how to create and apply a pubsub configuration. + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: rocketmq-pubsub + namespace: default +spec: + type: pubsub.rocketmq + version: v1 + metadata: + - name: nameServer + value: "http://localhost:9876" + - name: accessKey + value: "admin" + - name: secretKey + value: "password" + - name: consumerGroup + value: "GID_0001" + - name: retries + value: 10 +``` + +{{% 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 | +|--------------------|:--------:|--------|---------| +| accessKey | N | Access Key (Username) | `"admin"` +| secretKey | N | Secret Key (Password) | `"password"` +| nameServer | N | Name server address | `"127.0.0.1:9876;127.0.0.2:9877"` +| nameServerDomain | N | Name server domain | `"https://my-app.net:8080/nsaddr"` +| nameSpace | N | Namespace of the producer/consumer | `"namespace"` | +| groupName | N | Producer group name for RocketMQ publishers | `"my_unique_group_name"` | +| consumerGroup | N | Consumer group name for RocketMQ subscribers| `"my_unique_group_name"` +| content-type | N | Message content-type, e.g., `"application/cloudevents+json; charset=utf-8"`, `"application/octet-stream"` | `"text/plain"` +| retries | N | Number of times to retry to connect rocketmq's broker, optional | `0` +| sendTimeOut | N | Timeout duration for publishing a message in nanoseconds | `0` + +## Setup RocketMQ +See https://rocketmq.apache.org/docs/quick-start/ to setup a local RocketMQ instance. + +## Per-call metadata fields + +### Partition Key + +When invoking the RocketMQ pub/sub, it's possible to provide an optional partition key by using the `metadata` query param in the request url. + +You need to specify `rocketmq-tag`,`"rocketmq-key"` in `metadata` + +Example: + +```shell +curl -X POST http://localhost:3500/v1.0/publish/myRocketMQ/myTopic?metadata.rocketmq-tag=?&metadata.rocketmq-key=? \ + -H "Content-Type: application/json" \ + -d '{ + "data": { + "message": "Hi" + } + }' +``` + +## Related links +- [Basic schema for a Dapr component]({{< ref component-schema >}}) +- [Pub/Sub building block]({{< ref pubsub >}}) +- Read [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components From 0889a11500c39f21f8df023781c4b1f531144945 Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Thu, 9 Jun 2022 03:48:00 +0530 Subject: [PATCH 3/3] Add volume mount support to annotations reference (#2455) * Add docs to reference Signed-off-by: Shubham Sharma * Trigger Build Signed-off-by: Shubham Sharma * Add usage docs under operations Signed-off-by: Shubham Sharma * Refactor Signed-off-by: Shubham Sharma * Move the docs and add example Signed-off-by: Shubham Sharma * Fix typo Signed-off-by: Shubham Sharma * Incorporate review by @msfussell Signed-off-by: Shubham Sharma Co-authored-by: Mark Fussell --- .../kubernetes/kubernetes-volume-mounts.md | 107 ++++++++++++++++++ .../arguments-annotations-overview.md | 2 + 2 files changed, 109 insertions(+) create mode 100644 daprdocs/content/en/operations/hosting/kubernetes/kubernetes-volume-mounts.md diff --git a/daprdocs/content/en/operations/hosting/kubernetes/kubernetes-volume-mounts.md b/daprdocs/content/en/operations/hosting/kubernetes/kubernetes-volume-mounts.md new file mode 100644 index 000000000..d0b34c546 --- /dev/null +++ b/daprdocs/content/en/operations/hosting/kubernetes/kubernetes-volume-mounts.md @@ -0,0 +1,107 @@ +--- +type: docs +title: "How-to: Mount Pod volumes to the Dapr sidecar" +linkTitle: "How-to: Mount Pod volumes" +weight: 80000 +description: "Configure the Dapr sidecar to mount Pod Volumes" +--- + +## Introduction + +The Dapr sidecar can be configured to mount any Volume attached to the application Pod. These volumes can be accessed by the sidecar in _read-only_ or _read-write_ modes. If a Volume is configured to be mounted but it does not exist in the Pod, Dapr logs a warning and ignores it. +For more information on different types of Volumes, check [Volumes | Kubernetes](https://kubernetes.io/docs/concepts/storage/volumes/). + +## Configuration + +You can set the following annotations in your deployment YAML: +1. **dapr.io/volume-mounts**: for read-only volume mounts +1. **dapr.io/volume-mounts-rw**: for read-write volume mounts + +These annotations are comma separated pairs of `volume:path`. Make sure that the corresponding Volumes exist in the Pod spec. + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: myapp + namespace: default + labels: + app: myapp +spec: + replicas: 1 + selector: + matchLabels: + app: myapp + template: + metadata: + labels: + app: myapp + annotations: + dapr.io/enabled: "true" + dapr.io/app-id: "myapp" + dapr.io/app-port: "8000" + dapr.io/volume-mounts: "my-volume1:/tmp/sample1,my-volume2:/tmp/sample2" + dapr.io/volume-mounts-rw: "my-volume3:/tmp/sample3" + spec: + volumes: + - name: my-volume1 + hostPath: + path: /sample + - name: my-volume2 + persistentVolumeClaim: + claimName: pv-sample + - name: my-volume3 + emptyDir: {} +... +``` + +## Example + +### Custom secrets storage using local file secret store +Since any type of Kubernetes Volume can be attached to the sidecar, you can use the local file secret store to read secrets from a variety of places. For example, if you have a Network File Share (NFS) server running at `10.201.202.203`, with secrets stored at `/secrets/stage/secrets.json`, you can use that as a secrets storage. + +1. Configure the application pod to mount the NFS and attach it to the Dapr sidecar. +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: myapp +... +spec: + ... + template: + ... + annotations: + dapr.io/enabled: "true" + dapr.io/app-id: "myapp" + dapr.io/app-port: "8000" + dapr.io/volume-mounts: "nfs-ss-vol:/usr/secrets" + spec: + volumes: + - name: nfs-ss-vol + nfs: + server: 10.201.202.203 + path: /secrets/stage +... +``` +2. Point the local file secret store component to the attached file. +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: local-secret-store + namespace: default +spec: + type: secretstores.local.file + version: v1 + metadata: + - name: secretsFile + value: /usr/secrets/secrets.json +``` +3. Use the secrets. +``` +GET http://localhost:/v1.0/secrets/local-secret-store/my-secret +``` + +## Related links +- [Dapr Kubernetes pod annotations spec]({{< ref arguments-annotations-overview.md >}}) diff --git a/daprdocs/content/en/reference/arguments-annotations-overview.md b/daprdocs/content/en/reference/arguments-annotations-overview.md index e5ec31e8b..1e9160e96 100644 --- a/daprdocs/content/en/reference/arguments-annotations-overview.md +++ b/daprdocs/content/en/reference/arguments-annotations-overview.md @@ -57,3 +57,5 @@ This table is meant to help users understand the equivalent options for running | not supported | not supported | | `dapr.io/sidecar-readiness-probe-period-seconds` | How often (in seconds) to perform the sidecar readiness probe. Read more [here](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes). Default is `6`| | not supported | not supported | | `dapr.io/sidecar-readiness-probe-threshold` | When the sidecar readiness probe fails, Kubernetes will try N times before giving up. In this case, the Pod will be marked Unready. Read more about `failureThreshold` [here](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes). Default is `3`| | not supported | not supported | | `dapr.io/env` | List of environment variable to be injected into the sidecar. Strings consisting of key=value pairs separated by a comma.| +| not supported | not supported | | `dapr.io/volume-mounts` | List of pod volumes to be mounted to the sidecar container in read-only mode. Strings consisting of `volume:path` pairs separated by a comma. Example, `"volume-1:/tmp/mount1,volume-2:/home/root/mount2"`. | +| not supported | not supported | | `dapr.io/volume-mounts-rw` | List of pod volumes to be mounted to the sidecar container in read-write mode. Strings consisting of `volume:path` pairs separated by a comma. Example, `"volume-1:/tmp/mount1,volume-2:/home/root/mount2"`. | \ No newline at end of file