From b576945a08c4c99e55c0e18b44e25c6f8e8c8f5f Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:59:43 +0530 Subject: [PATCH 1/2] add hello-kubernetes multi-app run k8s template Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- .github/env/global.env | 2 +- .github/workflows/validate.yaml | 24 ++-- .gitignore | 5 + tutorials/distributed-calculator/README.md | 58 ++++---- tutorials/hello-kubernetes/README.md | 160 +++++++++++++++++++-- tutorials/hello-kubernetes/dapr.yaml | 10 ++ tutorials/validate.mk | 10 +- 7 files changed, 214 insertions(+), 55 deletions(-) create mode 100644 tutorials/hello-kubernetes/dapr.yaml diff --git a/.github/env/global.env b/.github/env/global.env index 164fda528..bbc9a841f 100644 --- a/.github/env/global.env +++ b/.github/env/global.env @@ -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 diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 913457e0b..c3a570850 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -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' diff --git a/.gitignore b/.gitignore index cf9383703..732a675d4 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/tutorials/distributed-calculator/README.md b/tutorials/distributed-calculator/README.md index 39a7900f9..87cf8f535 100644 --- a/tutorials/distributed-calculator/README.md +++ b/tutorials/distributed-calculator/README.md @@ -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: ![Architecture Diagram](./img/Architecture_Diagram.png) @@ -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 ![Calculator Screenshot](./img/calculator-screenshot.JPG) -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. @@ -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: + -```bash +```bash kubectl apply -f . -``` +``` @@ -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 ![Calculator Screenshot](./img/calculator-screenshot.JPG) -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 ``` @@ -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), diff --git a/tutorials/hello-kubernetes/README.md b/tutorials/hello-kubernetes/README.md index fb324c59c..0a2c473d8 100644 --- a/tutorials/hello-kubernetes/README.md +++ b/tutorials/hello-kubernetes/README.md @@ -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: + +```bash +dapr run -k -f dapr.yaml +``` + + + +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: + + + +```bash +dapr stop -k -f dapr.yaml +``` + + + +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. + ```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! + ```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 ```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 -## 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 . ``` - -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 diff --git a/tutorials/hello-kubernetes/dapr.yaml b/tutorials/hello-kubernetes/dapr.yaml new file mode 100644 index 000000000..dcf9ee929 --- /dev/null +++ b/tutorials/hello-kubernetes/dapr.yaml @@ -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 \ No newline at end of file diff --git a/tutorials/validate.mk b/tutorials/validate.mk index 8cd78d9bf..dd873b24a 100644 --- a/tutorials/validate.mk +++ b/tutorials/validate.mk @@ -1,5 +1,11 @@ - MM_SHELL ?= bash -c + validate: - mm.py -l -s "${MM_SHELL}" README.md \ No newline at end of file + 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 \ No newline at end of file From a66386e22d2d0d73ca61eb7ec4113e92f36a125b Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Tue, 3 Oct 2023 20:09:57 +0530 Subject: [PATCH 2/2] address review comments. Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- tutorials/distributed-calculator/README.md | 7 +++++++ tutorials/hello-kubernetes/README.md | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tutorials/distributed-calculator/README.md b/tutorials/distributed-calculator/README.md index 87cf8f535..5cc6be682 100644 --- a/tutorials/distributed-calculator/README.md +++ b/tutorials/distributed-calculator/README.md @@ -382,6 +382,13 @@ kubectl apply -f . + > **Note**: If you had previously installed, dapr using the `dapr init -k --dev` command, the `appconfig` previously installed, would have changed with the above command to point to a different zipkin collector. To point it back to the zipkin collector installed during `dapr init -k --dev`, replace the `endpointAddress` in `appconfig.yaml` with the following: + `endpointAddress: "http://dapr-dev-zipkin.default.svc.cluster.local:9411/api/v2/spans"` + and run the following command: + ```bash + kubectl apply -f appconfig.yaml + ``` + > **Note**: Services could also be deployed one-by-one by specifying the .yaml file: `kubectl apply -f go-adder.yaml`. Each of the services will spin up a pod with two containers: one for your service and one for the Dapr sidecar. It will also configure a service for each sidecar and an external IP for the front-end, which allows us to connect to it externally. diff --git a/tutorials/hello-kubernetes/README.md b/tutorials/hello-kubernetes/README.md index 0a2c473d8..7241d0ae2 100644 --- a/tutorials/hello-kubernetes/README.md +++ b/tutorials/hello-kubernetes/README.md @@ -22,23 +22,22 @@ cd quickstarts/tutorials/hello-kubernetes 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/). -## Using Dapr Mutli-app run +## Using Dapr Multi-app run with Dapr `dev` mode deployment ### 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/). +Follow the steps below to deploy Dapr to Kubernetes using the `--dev` flag. For more details, see [Deploy Dapr on a Kubernetes cluster](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/). + + > **Note**: Any previous Dapr installations in the Kubernetes cluster need to be uninstalled first. You can use `dapr uninstall -k ` to remove Dapr + +With the `dapr init -k --dev` command, the CLI will also install he Redis and Zipkin containers `dapr-dev-redis` and `dapr-dev-zipkin` in the `default` namespace apart from the `Dapr` control plane in `dapr-system` namespace. The `statestore`, `pubsub` and `appconfig` default components and configuration are applied in the `default` Kubernetes namespace if they do not exist. You can use `dapr components -k` and `dapr configurations -k`to see these. -> 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 +Expected output in a fresh Kubernetes cluster without Dapr installed: ``` ⌛ 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 @@ -127,7 +126,7 @@ 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. + > **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/). @@ -203,7 +202,7 @@ kubectl apply -f ./deploy/redis.yaml component.dapr.io/statestore created ``` -> 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`. + > **Note**: If you installed Dapr using the `--dev` flag 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`. If the `--dev` flag was used for Dapr init, and you want to use the `dapr-dev-redis` deployment as state store, replace the `redisHost` value inside `./deploy/redis.yaml` with `dapr-dev-redis-master:6379` and also the `secretKeyRef`, `name` with `dapr-dev-redis`. Then run the command `kubectl apply -f ./deploy/redis.yaml`, to apply the file again. This will create a `statestore` Dapr component pointing to `dapr-dev-redis` deployment. ### Step 3 - Deploy the Node.js app with the Dapr sidecar @@ -506,6 +505,8 @@ kubectl delete -f . This will spin down each resource defined by the `.yaml` files in the `deploy` directory, including the state component. + > **Note**: This will also delete the state store component. If the `--dev` flag was used for Dapr init, and you want to use the `dapr-dev-redis` deployment as state store, replace the `redisHost` value inside `./deploy/redis.yaml` with `dapr-dev-redis-master:6379` and also the `secretKeyRef`, `name` with `dapr-dev-redis`. Then run the command `kubectl apply -f ./deploy/redis.yaml`, to apply the file again. This will create a `statestore` Dapr component pointing to `dapr-dev-redis` deployment. + ## Deploying your code Now that you're successfully working with Dapr, you probably want to update the code to fit your scenario. The Node.js and Python apps that make up this quickstart are deployed from container images hosted on a private [Azure Container Registry](https://azure.microsoft.com/en-us/services/container-registry/). To create new images with updated code, you'll first need to install docker on your machine. Next, follow these steps: