-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jasonviviano <[email protected]>
- Loading branch information
1 parent
55fb874
commit c3b6de8
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/" >}}) |
26 changes: 26 additions & 0 deletions
26
docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/snippets/app-sidecar.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
] | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
docs/content/guides/author-apps/dapr/how-to-dapr-sidecar/snippets/app.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
} | ||
} | ||
} |