Add components step

This commit is contained in:
Aaron Crawfis 2021-01-19 12:55:37 -08:00
parent d8820e30ad
commit a24bb6aa97
5 changed files with 75 additions and 7 deletions

View File

@ -1,7 +1,7 @@
--- ---
type: docs type: docs
title: "How-To: Configure state store and pub/sub message broker" title: "How-To: Configure state store and pub/sub message broker"
linkTitle: "Configure state & pub/sub" linkTitle: "(optional) Configure state & pub/sub"
weight: 80 weight: 80
description: "Configure state store and pub/sub message broker components for Dapr" description: "Configure state store and pub/sub message broker components for Dapr"
aliases: aliases:

View File

@ -9,7 +9,7 @@ After running the `dapr init` command in the previous step, your local environme
You will now run the sidecar and call the API directly (simulating what an application would do). You will now run the sidecar and call the API directly (simulating what an application would do).
### Step 1: Run the Dapr sidecar ## Step 1: Run the Dapr sidecar
One the most useful Dapr CLI commands is [`dapr run`]({{< ref dapr-run.md >}}). This command launches an application together with a sidecar. For the purpose of this tutorial you'll run the sidecar without an application. One the most useful Dapr CLI commands is [`dapr run`]({{< ref dapr-run.md >}}). This command launches an application together with a sidecar. For the purpose of this tutorial you'll run the sidecar without an application.
@ -19,7 +19,7 @@ Run the following command to launch a Dapr sidecar that will listen on port 3500
dapr run --app-id myapp --dapr-http-port 3500 dapr run --app-id myapp --dapr-http-port 3500
``` ```
### Step 2: Save state ## Step 2: Save state
In a separate terminal run: In a separate terminal run:
@ -40,7 +40,7 @@ Invoke-RestMethod -Method Post -ContentType 'application/json' -Body '[{ "key":
{{< /tabs >}} {{< /tabs >}}
### Step 2: Get state ## Step 2: Get state
Now get the state you just stored using a key with the state management API: Now get the state you just stored using a key with the state management API:
@ -62,7 +62,7 @@ Invoke-RestMethod -Uri 'http://localhost:3500/v1.0/state/statestore/name'
{{< /tabs >}} {{< /tabs >}}
### Step 3: See how the state is stored in Redis ## Step 3: See how the state is stored in Redis
You can look in the Redis container and verify Dapr is using it as a state store. Run the following to use the Redis CLI: You can look in the Redis container and verify Dapr is using it as a state store. Run the following to use the Redis CLI:

View File

@ -5,5 +5,71 @@ linkTitle: "Define a component"
weight: 40 weight: 40
--- ---
After familiarizing yourself with the Dapr HTTP API and state building block in the previous step, you will now create your first Dapr component to try out the [secrets building block]({{< ref secrets >}}).
In this guide you will:
- Create a local json secret store
- Register the secret store with Dapr using a component
- Obtain the secret using the Dapr HTTP API
## Step 1: Create a json secret store
While Dapr supports [many types of secret stores]({{< ref supported-secret-stores >}}), the easiest way to get started is a local json file with your secret.
Begin by saving the following json contents into a file named `mysecrets.json`:
```json
{
"my-secret" : "I'm Batman"
}
```
## Step 2: Create a secret store Dapr component
Within your default Dapr components directory create a file named `localSecretStore.yaml` with the following contents:
- Linux/MacOS: `$HOME/.dapr/components`
- Windows: `%USERPROFILE%\.dapr\components`
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: my-secret-store
namespace: default
spec:
type: secretstores.local.file
version: v1
metadata:
- name: secretsFile
value: <PATH TO SECRETS FILE>/secrets.json
- name: nestedSeparator
value: ":"
```
## Step 3: Run the Dapr sidecar
Run the following command to launch a Dapr sidecar that will listen on port 3500 for a blank application named myapp:
```bash
dapr run --app-id myapp --dapr-http-port 3500
```
## Step 4: Get a secret
In a separate terminal run:
{{< tabs "HTTP API (Bash)" "HTTP API (PowerShell)">}}
{{% codetab %}}
```bash
curl http://localhost:3500/v1.0/secrets/my-secret-store/my-secret
```
{{% /codetab %}}
{{% codetab %}}
```powershell
Invoke-RestMethod -Uri 'http://localhost:3500/v1.0/secrets/my-secret-store/my-secret'
```
{{% /codetab %}}
<a class="btn btn-primary" href="{{< ref quickstarts.md >}}" role="button">Next step: Explore Dapr quickstarts >></a> <a class="btn btn-primary" href="{{< ref quickstarts.md >}}" role="button">Next step: Explore Dapr quickstarts >></a>

View File

@ -1,7 +1,7 @@
--- ---
type: docs type: docs
title: "How-To: Install Dapr into a Kubernetes cluster" title: "How-To: Install Dapr into a Kubernetes cluster"
linkTitle: "Init Dapr on Kubernetes" linkTitle: "(optional) Init Dapr on Kubernetes"
weight: 70 weight: 70
description: "Install Dapr in a Kubernetes cluster" description: "Install Dapr in a Kubernetes cluster"
--- ---

View File

@ -105,7 +105,9 @@ Open `%USERPROFILE%\.dapr\` in file explorer:
```powershell ```powershell
explorer "%USERPROFILE%\.dapr\" explorer "%USERPROFILE%\.dapr\"
``` ```
You will see the Dapr config, Dapr binaries directory, and the default components directory for Dapr:
<img src="/images/install-dapr-selfhost-windows.png" width=500> <img src="/images/install-dapr-selfhost-windows.png" width=500>
{{% /codetab %}} {{% /codetab %}}