diff --git a/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/index.md b/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/index.md new file mode 100644 index 000000000..ff5f99d8e --- /dev/null +++ b/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/index.md @@ -0,0 +1,59 @@ +--- +type: docs +title: "How-To: Add a Dapr sidecar to Radius" +linkTitle: "Add a Dapr sidecar to Radius" +description: "Easily leverage a Dapr sidecar blocks in your application for code and infrastructure portability" +weight: 100 +categories: "How-To" +tags: ["Dapr"] +--- + +This how-to guide will provide an overview of how to: + +- Leverage a [Dapr sidecar](https://docs.dapr.io/concepts/dapr-services/sidecar/) with your Radius Application + +## Prerequisites + +- [rad CLI]({{< ref getting-started >}}) +- [Radius initialized with `rad init`]({{< ref howto-environment >}}) +- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) +- [Dapr](https://docs.dapr.io/getting-started/install-dapr-cli/) + +## Step 1: Define a container + +Begin by creating a file named `app.bicep` with a Radius [container]({{< ref "guides/author-apps/containers" >}}): + +{{< rad file="snippets/app.bicep" embed=true >}} + +## Step 2: Define the Dapr sidecar extension + +Make sure your current Dapr sidecar process is running inside a Kubernetes cluster: + + ``` + daprd --app-id myapp + ``` + +You'll need the following information `appId`, `appPort` and any additional `config` properties can be defined inside of your Radius container definition. + +{{< rad file="snippets/app-sidecar.bicep" embed=true >}} + +## Step 3: Deploy the Radius Application + +1. Deploy and run your app: + + ```bash + rad run ./app.bicep -a demo + ``` + +## Cleanup + +Run the following command to [delete]({{< ref "guides/deploy-apps/howto-delete" >}}) your app and container: + + ```bash + rad app delete demo + ``` + +## Further reading + +- [Dapr in Radius containers]({{< ref "guides/author-apps/containers/overview#kubernetes" >}}) +- [Dapr sidecar schema]({{< ref "reference/resource-schema/dapr-schema/extension/" >}}) \ No newline at end of file diff --git a/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/snippets/app-sidecar.bicep b/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/snippets/app-sidecar.bicep new file mode 100644 index 000000000..7d321f06a --- /dev/null +++ b/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/snippets/app-sidecar.bicep @@ -0,0 +1,26 @@ +import radius as radius + +@description('Specifies the environment for resources.') +param environment string + +resource app 'Applications.Core/applications@2023-10-01-preview' = { + name: 'demo' + properties: { + environment: environment + } +} + +resource demo 'Applications.Core/containers@2023-10-01-preview' = { + name: 'demo' + properties: { + application: app.id + container: {...} + extensions: [ + { + kind: 'daprSidecar' + appId: 'demo' + appPort: 3000 + } + ] + } +} diff --git a/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/snippets/app.bicep b/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/snippets/app.bicep new file mode 100644 index 000000000..cf50f3d4b --- /dev/null +++ b/docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/snippets/app.bicep @@ -0,0 +1,26 @@ +import radius as radius + +@description('Specifies the environment for resources.') +param environment string + +resource app 'Applications.Core/applications@2023-10-01-preview' = { + name: 'demo' + properties: { + environment: environment + } +} + +resource demo 'Applications.Core/containers@2023-10-01-preview' = { + name: 'demo' + properties: { + application: app.id + container: { + image: 'ghcr.io/radius-project/samples/demo:latest' + ports: { + web: { + containerPort: 3000 + } + } + } + } +}