From a24bb6aa97280bd80325de37bd46fee4b440d848 Mon Sep 17 00:00:00 2001 From: Aaron Crawfis Date: Tue, 19 Jan 2021 12:55:37 -0800 Subject: [PATCH] Add components step --- .../getting-started/configure-state-pubsub.md | 2 +- .../en/getting-started/get-started-api.md | 8 +-- .../getting-started/get-started-component.md | 66 +++++++++++++++++++ .../install-dapr-kubernetes.md | 2 +- .../getting-started/install-dapr-selfhost.md | 4 +- 5 files changed, 75 insertions(+), 7 deletions(-) diff --git a/daprdocs/content/en/getting-started/configure-state-pubsub.md b/daprdocs/content/en/getting-started/configure-state-pubsub.md index bc64f2813..c3ee15a87 100644 --- a/daprdocs/content/en/getting-started/configure-state-pubsub.md +++ b/daprdocs/content/en/getting-started/configure-state-pubsub.md @@ -1,7 +1,7 @@ --- type: docs title: "How-To: Configure state store and pub/sub message broker" -linkTitle: "Configure state & pub/sub" +linkTitle: "(optional) Configure state & pub/sub" weight: 80 description: "Configure state store and pub/sub message broker components for Dapr" aliases: diff --git a/daprdocs/content/en/getting-started/get-started-api.md b/daprdocs/content/en/getting-started/get-started-api.md index ef3c7f075..1ace6fb54 100644 --- a/daprdocs/content/en/getting-started/get-started-api.md +++ b/daprdocs/content/en/getting-started/get-started-api.md @@ -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). -### 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. @@ -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 ``` -### Step 2: Save state +## Step 2: Save state In a separate terminal run: @@ -40,7 +40,7 @@ Invoke-RestMethod -Method Post -ContentType 'application/json' -Body '[{ "key": {{< /tabs >}} -### Step 2: Get state +## Step 2: Get state 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 >}} -### 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: diff --git a/daprdocs/content/en/getting-started/get-started-component.md b/daprdocs/content/en/getting-started/get-started-component.md index 861af2575..73ed2e9a5 100644 --- a/daprdocs/content/en/getting-started/get-started-component.md +++ b/daprdocs/content/en/getting-started/get-started-component.md @@ -5,5 +5,71 @@ linkTitle: "Define a component" 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: /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 %}} Next step: Explore Dapr quickstarts >> diff --git a/daprdocs/content/en/getting-started/install-dapr-kubernetes.md b/daprdocs/content/en/getting-started/install-dapr-kubernetes.md index 591626cd0..523de1e0b 100644 --- a/daprdocs/content/en/getting-started/install-dapr-kubernetes.md +++ b/daprdocs/content/en/getting-started/install-dapr-kubernetes.md @@ -1,7 +1,7 @@ --- type: docs title: "How-To: Install Dapr into a Kubernetes cluster" -linkTitle: "Init Dapr on Kubernetes" +linkTitle: "(optional) Init Dapr on Kubernetes" weight: 70 description: "Install Dapr in a Kubernetes cluster" --- diff --git a/daprdocs/content/en/getting-started/install-dapr-selfhost.md b/daprdocs/content/en/getting-started/install-dapr-selfhost.md index 3df674abf..b750264f4 100644 --- a/daprdocs/content/en/getting-started/install-dapr-selfhost.md +++ b/daprdocs/content/en/getting-started/install-dapr-selfhost.md @@ -105,7 +105,9 @@ Open `%USERPROFILE%\.dapr\` in file explorer: ```powershell explorer "%USERPROFILE%\.dapr\" ``` - + +You will see the Dapr config, Dapr binaries directory, and the default components directory for Dapr: + {{% /codetab %}}