mirror of https://github.com/dapr/quickstarts.git
add hello-kubernetes multi-app run k8s template
Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
This commit is contained in:
parent
8ecc595dc2
commit
b576945a08
|
@ -1,4 +1,4 @@
|
|||
DAPR_CLI_VERSION: 1.12.0-rc.2
|
||||
DAPR_CLI_VERSION: 1.12.0-rc.3
|
||||
DAPR_RUNTIME_VERSION: 1.12.0-rc.5
|
||||
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v${DAPR_CLI_VERSION}/install/
|
||||
DAPR_DEFAULT_IMAGE_REGISTRY: ghcr
|
||||
|
|
|
@ -31,18 +31,18 @@ jobs:
|
|||
deploy:
|
||||
name: Validate tutorials on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 30
|
||||
timeout-minutes: 40
|
||||
env:
|
||||
GOVER: 1.17
|
||||
KUBERNETES_VERSION: v1.21.1
|
||||
KIND_VERSION: v0.12.0
|
||||
KIND_IMAGE_SHA: sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
|
||||
strategy:
|
||||
matrix:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- name: Check out code
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
- name: Load environment variables
|
||||
uses: artursouza/export-env-action@v2
|
||||
|
@ -90,12 +90,12 @@ jobs:
|
|||
- role: worker
|
||||
image: kindest/node:${{ env.KUBERNETES_VERSION }}@${{ env.KIND_IMAGE_SHA }}
|
||||
EOF
|
||||
|
||||
|
||||
# Log the generated kind.yaml for easy reference.
|
||||
cat kind.yaml
|
||||
|
||||
- name: Create KinD Cluster - Linux
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
uses: helm/kind-action@v1.2.0
|
||||
with:
|
||||
config: kind.yaml
|
||||
|
@ -124,7 +124,7 @@ jobs:
|
|||
run: wget -q ${{ env.DAPR_INSTALL_URL }}/install.sh -O - | /bin/bash -s ${{ env.DAPR_CLI_VERSION }}
|
||||
- name: Set up Dapr CLI - Windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: powershell -Command "\$$script=iwr -useb ${{ env.DAPR_INSTALL_URL }}/install.ps1; \$$block=[ScriptBlock]::Create(\$$script); invoke-command -ScriptBlock \$$block -ArgumentList ${{ env.DAPR_CLI_VERSION }}"
|
||||
run: powershell -Command "\$$script=iwr -useb ${{ env.DAPR_INSTALL_URL }}/install.ps1; \$$block=[ScriptBlock]::Create(\$$script); invoke-command -ScriptBlock \$$block -ArgumentList ${{ env.DAPR_CLI_VERSION }}"
|
||||
- name: Install Dapr
|
||||
run: |
|
||||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
||||
|
@ -135,7 +135,7 @@ jobs:
|
|||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm repo update
|
||||
helm install redis bitnami/redis --version 17.14.5
|
||||
dapr init -k --runtime-version=${{ env.DAPR_RUNTIME_VERSION }} --wait || kubectl get pods --all-namespaces
|
||||
dapr init -k --dev --runtime-version=${{ env.DAPR_RUNTIME_VERSION }} --wait || kubectl get pods --all-namespaces
|
||||
kubectl get nodes -o wide
|
||||
for pod in `dapr status -k | awk '/dapr/ {print $1}'`; do kubectl describe pod -l app=$pod -n dapr-system ; kubectl logs -l app=$pod -n dapr-system; done
|
||||
- name: Install utilities dependencies
|
||||
|
@ -148,11 +148,17 @@ jobs:
|
|||
pushd tutorials/hello-world
|
||||
make validate
|
||||
popd
|
||||
- name: Validate hello-kubernetes
|
||||
- name: Validate hello-kubernetes multi app run
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
pushd tutorials/hello-kubernetes
|
||||
make validate
|
||||
make validate_multi_app_run
|
||||
popd
|
||||
- name: Validate hello-kubernetes normal run
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
pushd tutorials/hello-kubernetes
|
||||
make validate_normal_run
|
||||
popd
|
||||
- name: Validate distributed-calculator
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
|
|
@ -43,3 +43,8 @@ packages
|
|||
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# Auto generated deploy dir inside .dapr directory
|
||||
**/.dapr/deploy
|
||||
# Auto generated logs dir inside .dapr directory
|
||||
**/.dapr/logs
|
||||
|
|
|
@ -7,10 +7,10 @@ This quickstart shows method invocation and state persistent capabilities of Dap
|
|||
- **Division**: Node [Express](https://expressjs.com/) application
|
||||
- **Subtraction**: [.NET Core](https://docs.microsoft.com/en-us/dotnet/core/) application
|
||||
|
||||
The front-end application consists of a server and a client written in [React](https://reactjs.org/).
|
||||
Kudos to `ahfarmer` whose [React calculator](https://github.com/ahfarmer/calculator)
|
||||
The front-end application consists of a server and a client written in [React](https://reactjs.org/).
|
||||
Kudos to `ahfarmer` whose [React calculator](https://github.com/ahfarmer/calculator)
|
||||
|
||||
The following architecture diagram illustrates the components that make up this quickstart:
|
||||
The following architecture diagram illustrates the components that make up this quickstart:
|
||||
|
||||

|
||||
|
||||
|
@ -109,7 +109,7 @@ name: "Run dotnet app"
|
|||
output_match_mode: substring
|
||||
working_dir: "./csharp/bin/Debug/netcoreapp7.0"
|
||||
background: true
|
||||
env:
|
||||
env:
|
||||
ASPNETCORE_URLS: 'http://localhost:7001'
|
||||
sleep: 5
|
||||
-->
|
||||
|
@ -175,7 +175,7 @@ working_dir: "./python"
|
|||
```bash
|
||||
#Linux/Mac OS:
|
||||
export FLASK_RUN_PORT=5001
|
||||
|
||||
|
||||
#Windows:
|
||||
set FLASK_RUN_PORT=5001
|
||||
```
|
||||
|
@ -245,7 +245,7 @@ sleep: 15
|
|||
|
||||

|
||||
|
||||
7. Open your browser's console window (using F12 key) to see the logs produced as you use the calculator. Note that each time you click a button, you see logs that indicate state persistence and the different apps that are contacted to perform the operation.
|
||||
7. Open your browser's console window (using F12 key) to see the logs produced as you use the calculator. Note that each time you click a button, you see logs that indicate state persistence and the different apps that are contacted to perform the operation.
|
||||
|
||||
<!-- STEP
|
||||
name: Pause for manual validation
|
||||
|
@ -291,7 +291,7 @@ name: "Curl test"
|
|||
```
|
||||
|
||||
```bash
|
||||
curl -s http://localhost:8080/state
|
||||
curl -s http://localhost:8080/state
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
@ -302,7 +302,7 @@ name: "Curl test"
|
|||
18
|
||||
1.5294117647058822
|
||||
1768
|
||||
|
||||
|
||||
{"operation":null,"total":"54","next":null}
|
||||
```
|
||||
|
||||
|
@ -328,11 +328,11 @@ name: Cleanup local
|
|||
```bash
|
||||
dapr stop --app-id subtractapp
|
||||
```
|
||||
|
||||
|
||||
```bash
|
||||
dapr stop --app-id divideapp
|
||||
```
|
||||
|
||||
|
||||
```bash
|
||||
dapr stop --app-id multiplyapp
|
||||
```
|
||||
|
@ -359,14 +359,14 @@ working_dir: "./node"
|
|||
1. Navigate to the deploy directory in this quickstart directory: `cd deploy`
|
||||
> **Note**: `appconfig.yaml` is not used directly for this quickstart but is present for the [observability quickstart](../observability).
|
||||
2. Follow [these instructions](https://docs.dapr.io/getting-started/tutorials/configure-state-pubsub/#step-1-create-a-redis-store) to create and configure a Redis store
|
||||
3. Deploy all of your resources:
|
||||
|
||||
3. Deploy all of your resources:
|
||||
|
||||
<!-- Changing appconfig to configured as validate.yaml GH WF, inits Dapr using dev mode.-->
|
||||
<!-- STEP
|
||||
name: "Deploy Kubernetes"
|
||||
working_dir: "./deploy"
|
||||
expected_stdout_lines:
|
||||
- "configuration.dapr.io/appconfig created"
|
||||
- "configuration.dapr.io/appconfig configured"
|
||||
- "deployment.apps/subtractapp created"
|
||||
- "deployment.apps/addapp created"
|
||||
- "deployment.apps/divideapp created"
|
||||
|
@ -376,9 +376,9 @@ expected_stdout_lines:
|
|||
- "component.dapr.io/statestore created"
|
||||
-->
|
||||
|
||||
```bash
|
||||
```bash
|
||||
kubectl apply -f .
|
||||
```
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
|
@ -462,7 +462,7 @@ This will make your service available on http://localhost:8000. Navigate to this
|
|||
|
||||
> **Optional**: If you are using a public cloud provider, you can substitue your EXTERNAL-IP address instead of port forwarding. You can find it with:
|
||||
|
||||
```bash
|
||||
```bash
|
||||
kubectl get svc
|
||||
```
|
||||
|
||||
|
@ -495,21 +495,21 @@ manual_pause_message: "Calculator APP running on http://localhost:8000. Please o
|
|||
|
||||

|
||||
|
||||
6. Open your browser's console window (using F12 key) to see the logs produced as you use the calculator. Note that each time you click a button, you see logs that indicate state persistence:
|
||||
6. Open your browser's console window (using F12 key) to see the logs produced as you use the calculator. Note that each time you click a button, you see logs that indicate state persistence:
|
||||
|
||||
```js
|
||||
Persisting State:
|
||||
{total: "21", next: "2", operation: "x"}
|
||||
```
|
||||
|
||||
`total`, `next`, and `operation` reflect the three pieces of state a calculator needs to operate. The app persists these to a Redis store (see [Simplified State Management](#simplified-state-management) section below). By persisting these, you can refresh the page or take down the front-end pod and still jump right back where you were. Try it! Enter something into the calculator and refresh the page. The calculator should have retained the state, and the console should read:
|
||||
`total`, `next`, and `operation` reflect the three pieces of state a calculator needs to operate. The app persists these to a Redis store (see [Simplified State Management](#simplified-state-management) section below). By persisting these, you can refresh the page or take down the front-end pod and still jump right back where you were. Try it! Enter something into the calculator and refresh the page. The calculator should have retained the state, and the console should read:
|
||||
|
||||
```js
|
||||
Rehydrating State:
|
||||
{total: "21", next: "2", operation: "x"}
|
||||
```
|
||||
|
||||
Also note that each time you enter a full equation (e.g. "126 ÷ 3 =") the logs indicate that a call is made to the service:
|
||||
Also note that each time you enter a full equation (e.g. "126 ÷ 3 =") the logs indicate that a call is made to the service:
|
||||
|
||||
```js
|
||||
Calling divide service
|
||||
|
@ -563,7 +563,7 @@ curl -s http://localhost:8000/persist -H Content-Type:application/json --data @p
|
|||
```
|
||||
|
||||
```bash
|
||||
curl -s http://localhost:8000/state
|
||||
curl -s http://localhost:8000/state
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
@ -575,7 +575,7 @@ You should get the following output:
|
|||
18
|
||||
1.5294117647058822
|
||||
1768
|
||||
|
||||
|
||||
{"operation":null,"total":"54","next":null}
|
||||
```
|
||||
|
||||
|
@ -624,13 +624,13 @@ const daprUrl = `http://localhost:${daprPort}/v1.0/invoke`;
|
|||
|
||||
app.post('/calculate/add', async (req, res) => {
|
||||
const appResponse = await axios.post(`${daprUrl}/addapp/method/add`, req.body);
|
||||
return res.send(`${appResponse.data}`);
|
||||
return res.send(`${appResponse.data}`);
|
||||
});
|
||||
|
||||
|
||||
app.post('/calculate/subtract', async (req, res) => {
|
||||
const appResponse = await axios.post(`${daprUrl}/subtractapp/method/subtract`, req.body);
|
||||
return res.send(`${appResponse.data}`);
|
||||
return res.send(`${appResponse.data}`);
|
||||
});
|
||||
...
|
||||
```
|
||||
|
@ -643,20 +643,20 @@ Learn more about Dapr [service invocation](https://docs.dapr.io/developing-appli
|
|||
|
||||
Dapr sidecars provide [state management](https://docs.dapr.io/developing-applications/building-blocks/state-management/). In this quickstart, the calculator's state is persisted each time a new button is clicked. This means a user can refresh the page, close the page or even take down the `calculator-front-end` pod, and still retain the same state when they next open it. Dapr adds a layer of indirection so that the app doesn't need to know where it's persisting state. It doesn't have to keep track of keys, handle retry logic or worry about state provider specific configuration. All it has to do is GET or POST against its Dapr sidecar's state endpoint: `http://localhost:3500/v1.0/state/${stateStoreName}`.
|
||||
|
||||
Take a look at `server.js` in the `react-calculator` directory. Note that it exposes two state endpoints for the React client to get and set state: the GET `/state` endpoint and the POST `/persist` endpoint. Both forward client calls to the Dapr state endpoint:
|
||||
Take a look at `server.js` in the `react-calculator` directory. Note that it exposes two state endpoints for the React client to get and set state: the GET `/state` endpoint and the POST `/persist` endpoint. Both forward client calls to the Dapr state endpoint:
|
||||
|
||||
```js
|
||||
const stateUrl = `http://localhost:${daprPort}/v1.0/state/${stateStoreName}`;
|
||||
```
|
||||
|
||||
Our client persists state by simply POSTing JSON key-value pairs (see `react-calculator/client/src/component/App.js`):
|
||||
Our client persists state by simply POSTing JSON key-value pairs (see `react-calculator/client/src/component/App.js`):
|
||||
|
||||
```js
|
||||
const state = [{
|
||||
key: "calculatorState",
|
||||
value
|
||||
const state = [{
|
||||
key: "calculatorState",
|
||||
value
|
||||
}];
|
||||
|
||||
|
||||
fetch("/persist", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(state),
|
||||
|
|
|
@ -20,11 +20,116 @@ cd quickstarts/tutorials/hello-kubernetes
|
|||
|
||||
> **Note**: See https://github.com/dapr/quickstarts#supported-dapr-runtime-version for supported tags. Use `git clone https://github.com/dapr/quickstarts.git` when using the edge version of dapr runtime.
|
||||
|
||||
## Step 1 - Setup Dapr on your Kubernetes cluster
|
||||
|
||||
The first thing you need is an RBAC enabled Kubernetes cluster. This could be running on your machine using Minikube, or it could be a fully-fledged cluster in Azure using [AKS](https://azure.microsoft.com/en-us/services/kubernetes-service/).
|
||||
|
||||
Once you have a cluster, follow the steps below to deploy Dapr to it. For more details, see [Deploy Dapr on a Kubernetes cluster](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/).
|
||||
## Using Dapr Mutli-app run
|
||||
|
||||
### Step 1 - Setup Dapr dev mode on your Kubernetes cluster
|
||||
|
||||
Follow the steps below to deploy Dapr to Kubernetes. For more details, see [Deploy Dapr on a Kubernetes cluster](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/).
|
||||
|
||||
> Please note, any previous Dapr installations in the Kubernetes cluster need to be uninstalled first.
|
||||
> Please note, the CLI will install to the dapr-system namespace by default. If this namespace does not exist, the CLI will create it.
|
||||
> If you need to deploy to a different namespace, you can use `-n mynamespace`.
|
||||
> Please note, the CLI will install `dapr-dev-redis` and `dapr-dev-zipkin` in the `default` namespace.
|
||||
> Please note, the `statestore`, `pubsub` and `appconfig` default components and configuration will be applied in the `default` Kubernetes namespace only if they do not exist.
|
||||
|
||||
```bash
|
||||
dapr init -k --dev
|
||||
```
|
||||
|
||||
Expected output
|
||||
```
|
||||
⌛ Making the jump to hyperspace...
|
||||
ℹ️ Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr-kubernetes/#install-with-helm-advanced
|
||||
|
||||
ℹ️ Container images will be pulled from Docker Hub
|
||||
✅ Deploying the Dapr control plane with latest version to your cluster...
|
||||
✅ Deploying the Dapr dashboard with latest version to your cluster...
|
||||
✅ Deploying the Dapr Redis with latest version to your cluster...
|
||||
✅ Deploying the Dapr Zipkin with latest version to your cluster...
|
||||
ℹ️ Applying "statestore" component to Kubernetes "default" namespace.
|
||||
ℹ️ Applying "pubsub" component to Kubernetes "default" namespace.
|
||||
ℹ️ Applying "appconfig" zipkin configuration to Kubernetes "default" namespace.
|
||||
✅ Success! Dapr has been installed to namespace dapr-system. To verify, run `dapr status -k' in your terminal. To get started, go here: https://aka.ms/dapr-getting-started
|
||||
```
|
||||
|
||||
### Step 2 - Run the Multi-app run template to deploy both the Node.js and Python apps
|
||||
|
||||
To run both the Node.js and Python apps, run the following command from the `hello-kubernetes` directory:
|
||||
<!-- STEP
|
||||
name: "Run hello-kubernetes multi-app run template"
|
||||
tags:
|
||||
- multi-app
|
||||
timeout_seconds: 60
|
||||
expected_return_code:
|
||||
expected_stdout_lines:
|
||||
- 'Deploying app "nodeapp" to Kubernetes'
|
||||
- 'Deploying app "pythonapp" to Kubernetes'
|
||||
- '== APP - nodeapp == Got a new order! Order ID: 12'
|
||||
- '== APP - nodeapp == Successfully persisted state for Order ID: 12'
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
match_order: none
|
||||
-->
|
||||
```bash
|
||||
dapr run -k -f dapr.yaml
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
Expected output
|
||||
```
|
||||
ℹ️ This is a preview feature and subject to change in future releases.
|
||||
ℹ️ Validating config and starting app "nodeapp"
|
||||
ℹ️ Deploying app "nodeapp" to Kubernetes
|
||||
ℹ️ Deploying service YAML "/path/quickstarts/tutorials/hello-kubernetes/node/.dapr/deploy/service.yaml" to Kubernetes
|
||||
ℹ️ Deploying deployment YAML "/path/quickstarts/tutorials/hello-kubernetes/node/.dapr/deploy/deployment.yaml" to Kubernetes
|
||||
ℹ️ Streaming logs for containers in pod "nodeapp-6dcddb44f5-q5gnr"
|
||||
ℹ️ Writing log files to directory : /path/quickstarts/tutorials/hello-kubernetes/node/.dapr/logs
|
||||
ℹ️ Validating config and starting app "pythonapp"
|
||||
ℹ️ Deploying app "pythonapp" to Kubernetes
|
||||
ℹ️ Deploying deployment YAML "/path/quickstarts/tutorials/hello-kubernetes/python/.dapr/deploy/deployment.yaml" to Kubernetes
|
||||
== APP - nodeapp == Node App listening on port 3000!
|
||||
ℹ️ Streaming logs for containers in pod "pythonapp-7479cdcb7b-z827w"
|
||||
ℹ️ Writing log files to directory : /path/quickstarts/tutorials/hello-kubernetes/python/.dapr/logs
|
||||
ℹ️ Starting to monitor Kubernetes pods for deletion.
|
||||
== APP - nodeapp == Got a new order! Order ID: 2
|
||||
== APP - nodeapp == Successfully persisted state for Order ID: 2
|
||||
== APP - nodeapp == Got a new order! Order ID: 3
|
||||
== APP - nodeapp == Successfully persisted state for Order ID: 3
|
||||
== APP - nodeapp == Got a new order! Order ID: 4
|
||||
== APP - nodeapp == Successfully persisted state for Order ID: 4
|
||||
== APP - nodeapp == Got a new order! Order ID: 5
|
||||
== APP - nodeapp == Successfully persisted state for Order ID: 5
|
||||
```
|
||||
|
||||
Use `Ctrl+C` to stop the apps. Or you can run the following command to stop the apps:
|
||||
<!-- STEP
|
||||
name: "Stop hello-kubernetes multi-app run template"
|
||||
tags:
|
||||
- multi-app
|
||||
timeout_seconds: 60
|
||||
expected_return_code:
|
||||
expected_stdout_lines:
|
||||
expected_stderr_lines:
|
||||
-->
|
||||
<!-- Properly stop multi-app run template if not already stopped.-->
|
||||
|
||||
```bash
|
||||
dapr stop -k -f dapr.yaml
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
This spins down the Kubernetes resources that were deployed in the previous step.
|
||||
|
||||
## Using the `kubectl` CLI
|
||||
### Step 1 - Setup Dapr on your Kubernetes cluster
|
||||
|
||||
> Note: This step can be skipped if already done above.
|
||||
|
||||
Follow the steps below to deploy Dapr to Kubernetes. For more details, see [Deploy Dapr on a Kubernetes cluster](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/).
|
||||
|
||||
> Please note, the CLI will install to the dapr-system namespace by default. If this namespace does not exist, the CLI will create it.
|
||||
> If you need to deploy to a different namespace, you can use `-n mynamespace`.
|
||||
|
@ -45,8 +150,11 @@ Sample output:
|
|||
|
||||
> Without the `--wait` flag the Dapr CLI will exit as soon as the kubernetes deployments are created. Kubernetes deployments are asyncronous by default, so we use `--wait` here to make sure the dapr control plane is completely deployed and running before continuing.
|
||||
|
||||
<!-- Introducing sleep here to first let the previous execution complete -->
|
||||
<!-- STEP
|
||||
name: Check dapr status
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -66,7 +174,7 @@ You will see output like the following. All services should show `True` in the H
|
|||
dapr-sidecar-injector dapr-system True Running 1 1.0.1 13s 2021-03-08 11:00.21
|
||||
```
|
||||
|
||||
## Step 2 - Create and configure a state store
|
||||
### Step 2 - Create and configure a state store
|
||||
|
||||
Dapr can use a number of different state stores (Redis, CosmosDB, DynamoDB, Cassandra, etc) to persist and retrieve state. This demo will use Redis.
|
||||
|
||||
|
@ -75,11 +183,14 @@ Dapr can use a number of different state stores (Redis, CosmosDB, DynamoDB, Cass
|
|||
> **Note:** the `redis.yaml` file provided in this quickstart will work securely out-of-the-box with a Redis installed with `helm install bitnami/redis`. If you have your own Redis setup, replace the `redisHost` value with your own Redis master address, and the redisPassword with your own Secret. You can learn more [here](https://docs.dapr.io/operations/components/component-secrets/).
|
||||
3. Apply the `redis.yaml` file and observe that your state store was successfully configured!
|
||||
|
||||
<!-- As part of previous dev-init, expecting that the state store component is already there for hello-kubernetes run. At the end of this run, it will be deleted.-->
|
||||
<!-- STEP
|
||||
name: Deploy redis config
|
||||
sleep: 1
|
||||
expected_stdout_lines:
|
||||
- "component.dapr.io/statestore created"
|
||||
- "component.dapr.io/statestore configured"
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -92,7 +203,9 @@ kubectl apply -f ./deploy/redis.yaml
|
|||
component.dapr.io/statestore created
|
||||
```
|
||||
|
||||
## Step 3 - Deploy the Node.js app with the Dapr sidecar
|
||||
> Note: If you installed Dapr in the Dev mode in Kubernetes, then the statestore component will be created automatically in the `default` namespace. The above commmand will output `component.dapr.io/statestore configured` instead of `component.dapr.io/statestore created`.
|
||||
|
||||
### Step 3 - Deploy the Node.js app with the Dapr sidecar
|
||||
|
||||
<!-- STEP
|
||||
name: Deploy Node App
|
||||
|
@ -101,6 +214,8 @@ expected_stdout_lines:
|
|||
- "service/nodeapp created"
|
||||
- "deployment.apps/nodeapp created"
|
||||
- 'deployment "nodeapp" successfully rolled out'
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -133,6 +248,8 @@ background: true
|
|||
sleep: 2
|
||||
timeout_seconds: 10
|
||||
expected_return_code:
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -149,7 +266,7 @@ This will make your service available on http://localhost:8080.
|
|||
kubectl get svc nodeapp
|
||||
```
|
||||
|
||||
## Step 4 - Verify Service
|
||||
### Step 4 - Verify Service
|
||||
|
||||
To call the service that you set up port forwarding to, from a command prompt run:
|
||||
|
||||
|
@ -157,6 +274,8 @@ To call the service that you set up port forwarding to, from a command prompt ru
|
|||
name: Curl Test
|
||||
expected_stdout_lines:
|
||||
- '{"DAPR_HTTP_PORT":"3500","DAPR_GRPC_PORT":"50001"}'
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -177,6 +296,8 @@ Next submit an order to the app
|
|||
name: neworder Test
|
||||
expected_stdout_lines:
|
||||
- ''
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -194,6 +315,8 @@ Confirm the order was persisted by requesting it from the app
|
|||
name: order Test
|
||||
expected_stdout_lines:
|
||||
- '{"orderId":"42"}'
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -214,7 +337,7 @@ Expected output:
|
|||
dapr dashboard -k -p 9999
|
||||
```
|
||||
|
||||
## Step 5 - Deploy the Python app with the Dapr sidecar
|
||||
### Step 5 - Deploy the Python app with the Dapr sidecar
|
||||
|
||||
Next, take a quick look at the Python app. Navigate to the Python app in the kubernetes quickstart: `cd quickstarts/tutorials/hello-kubernetes/python` and open `app.py`.
|
||||
|
||||
|
@ -240,6 +363,8 @@ sleep: 11
|
|||
expected_stdout_lines:
|
||||
- deployment.apps/pythonapp created
|
||||
- 'deployment "pythonapp" successfully rolled out'
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
Deploy the Python app to your Kubernetes cluster:
|
||||
|
@ -256,7 +381,7 @@ kubectl rollout status deploy/pythonapp
|
|||
|
||||
<!-- END_STEP -->
|
||||
|
||||
## Step 6 - Observe messages
|
||||
### Step 6 - Observe messages
|
||||
|
||||
Now that the Node.js and Python applications are deployed, watch messages come through:
|
||||
|
||||
|
@ -272,6 +397,8 @@ expected_stderr_lines:
|
|||
output_match_mode: substring
|
||||
match_order: none
|
||||
name: Read nodeapp logs
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -291,7 +418,7 @@ Got a new order! Order ID: 3
|
|||
Successfully persisted state for Order ID: 3
|
||||
```
|
||||
|
||||
## Step 7 - Observe API call logs
|
||||
### Step 7 - Observe API call logs
|
||||
|
||||
Now that the Node.js and Python applications are deployed, watch API call logs come through:
|
||||
|
||||
|
@ -303,6 +430,8 @@ expected_stdout_lines:
|
|||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
name: Read nodeapp logs
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -326,6 +455,8 @@ expected_stdout_lines:
|
|||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
name: Read pythonapp logs
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
|
@ -338,7 +469,7 @@ time="2022-04-27T02:47:49.972688145Z" level=info method="POST /neworder" app_id=
|
|||
time="2022-04-27T02:47:50.984994545Z" level=info method="POST /neworder" app_id=pythonapp instance=pythonapp-545df48d55-jvj52 scope=dapr.runtime.http-info type=log ver=1.7.2
|
||||
```
|
||||
|
||||
## Step 8 - Confirm successful persistence
|
||||
### Step 8 - Confirm successful persistence
|
||||
|
||||
Call the Node.js app's order endpoint to get the latest order. Grab the external IP address that you saved before and, append "/order" and perform a GET request against it (enter it into your browser, use Postman, or curl it!):
|
||||
|
||||
|
@ -349,7 +480,7 @@ curl $NODE_APP/order
|
|||
|
||||
You should see the latest JSON in response!
|
||||
|
||||
## Step 9 - Cleanup
|
||||
### Step 9 - Cleanup
|
||||
|
||||
Once you're done, you can spin down your Kubernetes resources by navigating to the `./deploy` directory and running:
|
||||
|
||||
|
@ -364,15 +495,16 @@ expected_stdout_lines:
|
|||
- component.dapr.io "statestore" deleted
|
||||
output_match_mode: substring
|
||||
match_order: none
|
||||
tags:
|
||||
- normal-run
|
||||
-->
|
||||
|
||||
```bash
|
||||
kubectl delete -f .
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
This will spin down each resource defined by the .yaml files in the `deploy` directory, including the state component.
|
||||
This will spin down each resource defined by the `.yaml` files in the `deploy` directory, including the state component.
|
||||
|
||||
## Deploying your code
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
version: 1
|
||||
apps:
|
||||
- appDirPath: ./node
|
||||
appID: nodeapp
|
||||
appPort: 3000
|
||||
containerImage: ghcr.io/dapr/samples/hello-k8s-node:latest
|
||||
createService: true
|
||||
- appDirPath: ./python
|
||||
appID: pythonapp
|
||||
containerImage: ghcr.io/dapr/samples/hello-k8s-python:latest
|
|
@ -1,5 +1,11 @@
|
|||
|
||||
MM_SHELL ?= bash -c
|
||||
|
||||
|
||||
validate:
|
||||
mm.py -l -s "${MM_SHELL}" README.md
|
||||
mm.py -l -s "${MM_SHELL}" README.md
|
||||
|
||||
validate_normal_run:
|
||||
mm.py -t normal-run -l -s "${MM_SHELL}" README.md
|
||||
|
||||
validate_multi_app_run:
|
||||
mm.py -t multi-app -s "${MM_SHELL}" README.md
|
Loading…
Reference in New Issue