You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: daprdocs/content/en/developing-applications/local-development/multi-app-dapr-run/multi-app-overview.md
+90-13Lines changed: 90 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,23 +7,24 @@ description: Run multiple applications with one CLI command
7
7
---
8
8
9
9
{{% alert title="Note" color="primary" %}}
10
-
Multi-App Run is currently a preview feature only supported in Linux/MacOS.
10
+
Multi-App Run for **Kubernetes**is currently a preview feature.
11
11
{{% /alert %}}
12
12
13
-
Let's say you want to run several applications locally to test them together, similar to a production scenario. With a local Kubernetes cluster, you'd be able to do this with helm/deployment YAML files. You'd also have to build them as containers and set up Kubernetes, which can add some complexity.
13
+
Let's say you want to run several applications locally to test them together, similar to a production scenario. Multi-App Run allows you to start and stop a set of applications simultaneously, either:
14
+
- Locally/self-hosted with processes, or
15
+
- By building container images and deploying to a Kubernetes cluster
16
+
- You can use a local Kubernetes cluster (KiND) or one deploy to a Cloud (AKS, EKS, and GKE).
14
17
15
-
Instead, you simply want to run them as local executables in self-hosted mode. However, self-hosted mode requires you to:
18
+
The Multi-App Run template file describes how to start multiple applications as if you had run many separate CLI `run` commands. By default, this template file is called `dapr.yaml`.
16
19
17
-
- Run multiple `dapr run` commands
18
-
- Keep track of all ports opened (you cannot have duplicate ports for different applications).
19
-
- Remember the resources folders and configuration files that each application refers to.
20
-
- Recall all of the additional flags you used to tweak the `dapr run` command behavior (`--app-health-check-path`, `--dapr-grpc-port`, `--unix-domain-socket`, etc.)
20
+
{{< tabs Self-hosted Kubernetes>}}
21
21
22
-
With Multi-App Run, you can start multiple applications in self-hosted mode using a single `dapr run -f` command using a template file. The template file describes how to start multiple applications as if you had run many separate CLI `run`commands. By default, this template file is called `dapr.yaml`.
22
+
{{% codetab %}}
23
+
<!--selfhosted-->
23
24
24
25
## Multi-App Run template file
25
26
26
-
When you execute `dapr run -f .`, it uses the multi-app template file (named `dapr.yaml`) present in the current directory to run all the applications.
27
+
When you execute `dapr run -f .`, it starts the multi-app template file (named `dapr.yaml`) present in the current directory to run all the applications.
27
28
28
29
You can name template file with preferred name other than the default. For example `dapr run -f ./<your-preferred-file-name>.yaml`.
29
30
@@ -71,9 +72,9 @@ The run template provides two log destination fields for each application and it
71
72
72
73
1. `appLogDestination` : This field configures the log destination for the application. The possible values are `console`, `file` and `fileAndConsole`. The default value is `fileAndConsole` where application logs are written to both console and to a file by default.
73
74
74
-
2. `daprdLogDestination` : This field configures the log destination for the `daprd` process. The possible values are `console`, `file` and `fileAndConsole`. The default value is `file` where the `daprd` logs are written to a file by default.
75
+
1. `daprdLogDestination` : This field configures the log destination for the `daprd` process. The possible values are `console`, `file` and `fileAndConsole`. The default value is `file` where the `daprd` logs are written to a file by default.
75
76
76
-
#### Log file format
77
+
### Log file format
77
78
78
79
Logs for application and `daprd` are captured in separate files. These log files are created automatically under `.dapr/logs` directory under each application directory (`appDirPath` in the template). These log file names follow the pattern seen below:
79
80
@@ -82,14 +83,90 @@ Logs for application and `daprd` are captured in separate files. These log files
82
83
83
84
Even if you've decided to rename your resources folder to something other than `.dapr`, the log files are written only to the `.dapr/logs` folder (created in the application directory).
84
85
85
-
86
86
## Watch the demo
87
87
88
88
Watch [this video for an overview on Multi-App Run](https://youtu.be/s1p9MNl4VGo?t=2456):
When you execute `dapr run -k -f .` or `dapr run -k -f dapr.yaml`, the applications defined in the `dapr.yaml` Multi-App Run template file starts in Kubernetes default namespace.
100
+
101
+
> **Note:** Currently, the Multi-App Run template can only start applications in the default Kubernetes namespace.
102
+
103
+
The necessary default service and deployment definitions for Kubernetes are generated within the `.dapr/deploy` folder for each app in the `dapr.yaml` template.
104
+
105
+
If the `createService` field is set to `true` in the `dapr.yaml` template for an app, then the `service.yaml` file is generated in the `.dapr/deploy` folder of the app.
106
+
107
+
Otherwise, only the `deployment.yaml` file is generated for each app that has the `containerImage` field set.
108
+
109
+
The files `service.yaml` and `deployment.yaml` are used to deploy the applications in `default` namespace in Kubernetes. This feature is specifically targeted only for running multiple apps in a dev/test environment in Kubernetes.
110
+
111
+
You can name the template file with any preferred name other than the default. For example:
112
+
113
+
```bash
114
+
dapr run -k -f ./<your-preferred-file-name>.yaml
115
+
```
116
+
117
+
The following example includes some of the template properties you can customize for your applications. In the example, you can simultaneously launch 2 applications with app IDs of `nodeapp` and `pythonapp`.
> - If the `containerImage` field is not specified, `dapr run -k -f` produces an error.
137
+
> - The `createService` field defines a basic service in Kubernetes (ClusterIP or LoadBalancer) that targets the `--app-port` specified in the template. If `createService` isn't specified, the application is not accessible from outside the cluster.
138
+
139
+
For a more in-depth example and explanation of the template properties, see [Multi-app template]({{< ref multi-app-template.md >}}).
140
+
141
+
## Logs
142
+
143
+
The run template provides two log destination fields for each application and its associated daprd process:
144
+
145
+
1. `appLogDestination` : This field configures the log destination for the application. The possible values are `console`, `file` and `fileAndConsole`. The default value is `fileAndConsole` where application logs are written to both console and to a file by default.
146
+
147
+
2. `daprdLogDestination` : This field configures the log destination for the `daprd` process. The possible values are `console`, `file` and `fileAndConsole`. The default value is `file` where the `daprd` logs are written to a file by default.
148
+
149
+
### Log file format
150
+
151
+
Logs for application and `daprd` are captured in separate files. These log files are created automatically under `.dapr/logs` directory under each application directory (`appDirPath` in the template). These log file names follow the pattern seen below:
152
+
153
+
- `<appID>_app_<timestamp>.log`(file name format for `app` log)
154
+
- `<appID>_daprd_<timestamp>.log`(file name format for `daprd` log)
155
+
156
+
Even if you've decided to rename your resources folder to something other than `.dapr`, the log files are written only to the `.dapr/logs` folder (created in the application directory).
157
+
158
+
## Watch the demo
159
+
160
+
Watch [this video for an overview on Multi-App Run in Kubernetes](https://youtu.be/nWatANwaAik?si=O8XR-TUaiY0gclgO&t=1024):
- [Learn the Multi-App Run template file structure and its properties]({{< ref multi-app-template.md >}})
95
-
- [Try out the Multi-App Run template with the Service Invocation quickstart]({{< ref serviceinvocation-quickstart.md >}})
171
+
- [Try out the self-hosted Multi-App Run template with the Service Invocation quickstart]({{< ref serviceinvocation-quickstart.md >}})
172
+
- [Try out the Kubernetes Multi-App Run template with the `hello-kubernetes` tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/hello-kubernetes)
The Multi-App Run template file can include the following properties. Below is an example template showing two applications that are configured with some of the properties.
69
128
129
+
{{< tabs Self-hosted Kubernetes>}}
130
+
131
+
{{% codetab %}}
132
+
<!--selfhosted-->
133
+
70
134
```yaml
71
135
version: 1
72
136
common: # optional section for variables shared across apps
@@ -96,19 +160,61 @@ apps:
96
160
command: ["./backend"]
97
161
```
98
162
99
-
{{% alert title="Important" color="warning" %}}
100
163
The following rules apply for all the paths present in the template file:
101
164
- If the path is absolute, it is used as is.
102
-
- All relative paths under comman section should be provided relative to the template file path.
165
+
- All relative paths under command section should be provided relative to the template file path.
103
166
- `appDirPath` under apps section should be provided relative to the template file path.
104
-
- All relative paths under app section should be provided relative to the appDirPath.
167
+
- All relative paths under app section should be provided relative to the `appDirPath`.
105
168
106
-
{{% /alert %}}
169
+
{{% /codetab %}}
170
+
171
+
{{% codetab %}}
172
+
<!--kubernetes-->
173
+
174
+
```yaml
175
+
version: 1
176
+
common: # optional section for variables shared across apps
177
+
env: # any environment variable shared across apps
178
+
DEBUG: true
179
+
apps:
180
+
- appID: webapp # optional
181
+
appDirPath: .dapr/webapp/ # REQUIRED
182
+
appChannelAddress: 127.0.0.1 # network address where the app listens on. (optional) can be left to default value by convention.
183
+
appProtocol: http
184
+
appPort: 8080
185
+
appHealthCheckPath: "/healthz"
186
+
appLogDestination: file # (optional), can be file, console or fileAndConsole. default is fileAndConsole.
187
+
daprdLogDestination: file # (optional), can be file, console or fileAndConsole. default is file.
188
+
containerImage: ghcr.io/dapr/samples/hello-k8s-node:latest # (optional) URI of the container image to be used when deploying to Kubernetes dev/test environment.
189
+
createService: true # (optional) Create a Kubernetes service for the application when deploying to dev/test environment.
190
+
- appID: backend # optional
191
+
appDirPath: .dapr/backend/ # REQUIRED
192
+
appProtocol: grpc
193
+
appPort: 3000
194
+
unixDomainSocket: "/tmp/test-socket"
195
+
env:
196
+
- DEBUG: false
197
+
```
198
+
199
+
The following rules apply for all the paths present in the template file:
200
+
- If the path is absolute, it is used as is.
201
+
- `appDirPath`under apps section should be provided relative to the template file path.
202
+
- All relative paths under app section should be provided relative to the `appDirPath`.
203
+
204
+
{{% /codetab %}}
205
+
206
+
{{< /tabs >}}
107
207
108
208
## Template properties
109
209
210
+
{{< tabs Self-hosted Kubernetes>}}
211
+
212
+
{{% codetab %}}
213
+
<!--selfhosted-->
214
+
110
215
The properties for the Multi-App Run template align with the `dapr run` CLI flags, [listed in the CLI reference documentation]({{< ref "dapr-run.md#flags" >}}).
@@ -146,8 +252,66 @@ The properties for the Multi-App Run template align with the `dapr run` CLI flag
146
252
| `appLogDestination` | N | Log destination for outputting app logs; Its value can be file, console or fileAndConsole. Default is fileAndConsole | `file`, `console`, `fileAndConsole` |
147
253
| `daprdLogDestination` | N | Log destination for outputting daprd logs; Its value can be file, console or fileAndConsole. Default is file | `file`, `console`, `fileAndConsole` |
148
254
255
+
{{< /table >}}
256
+
149
257
## Next steps
150
258
151
259
Watch [this video for an overview on Multi-App Run](https://youtu.be/s1p9MNl4VGo?t=2456):
The properties for the Multi-App Run template align with the `dapr run -k` CLI flags, [listed in the CLI reference documentation]({{< ref "dapr-run.md#flags" >}}).
| `appDirPath` | Y | Path to the your application code | `./webapp/`, `./backend/` |
274
+
| `appID` | N | Application's app ID. If not provided, will be derived from `appDirPath` | `webapp`, `backend` |
275
+
| `appChannelAddress` | N | The network address the application listens on. Can be left to the default value by convention. | `127.0.0.1` | `localhost` |
276
+
| `appProtocol` | N | The protocol Dapr uses to talk to the application. | `http`, `grpc` |
277
+
| `appPort` | N | The port your application is listening on | `8080`, `3000` |
278
+
| `daprHTTPPort` | N | Dapr HTTP port | |
279
+
| `daprGRPCPort` | N | Dapr GRPC port | |
280
+
| `daprInternalGRPCPort` | N | gRPC port for the Dapr Internal API to listen on; used when parsing the value from a local DNS component | |
281
+
| `metricsPort` | N | The port that Dapr sends its metrics information to | |
282
+
| `unixDomainSocket` | N | Path to a unix domain socket dir mount. If specified, communication with the Dapr sidecar uses unix domain sockets for lower latency and greater throughput when compared to using TCP ports. Not available on Windows. | `/tmp/test-socket` |
283
+
| `profilePort` | N | The port for the profile server to listen on | |
284
+
| `enableProfiling` | N | Enable profiling via an HTTP endpoint | |
285
+
| `apiListenAddresses` | N | Dapr API listen addresses | |
286
+
| `logLevel` | N | The log verbosity. | |
287
+
| `appMaxConcurrency` | N | The concurrency level of the application; default is unlimited | |
288
+
| `placementHostAddress` | N | | |
289
+
| `appSSL` | N | Enable https when Dapr invokes the application | |
290
+
| `daprHTTPMaxRequestSize` | N | Max size of the request body in MB. | |
291
+
| `daprHTTPReadBufferSize` | N | Max size of the HTTP read buffer in KB. This also limits the maximum size of HTTP headers. The default 4 KB | |
292
+
| `enableAppHealthCheck` | N | Enable the app health check on the application | `true`, `false` |
293
+
| `appHealthCheckPath` | N | Path to the health check file | `/healthz` |
294
+
| `appHealthProbeInterval` | N | Interval to probe for the health of the app in seconds
295
+
| |
296
+
| `appHealthProbeTimeout` | N | Timeout for app health probes in milliseconds | |
297
+
| `appHealthThreshold` | N | Number of consecutive failures for the app to be considered unhealthy | |
298
+
| `enableApiLogging` | N | Enable the logging of all API calls from application to Dapr | |
299
+
| `env` | N | Map to environment variable; environment variables applied per application will overwrite environment variables shared across applications | `DEBUG`, `DAPR_HOST_ADD` |
300
+
| `appLogDestination` | N | Log destination for outputting app logs; Its value can be file, console or fileAndConsole. Default is fileAndConsole | `file`, `console`, `fileAndConsole` |
301
+
| `daprdLogDestination` | N | Log destination for outputting daprd logs; Its value can be file, console or fileAndConsole. Default is file | `file`, `console`, `fileAndConsole` |
302
+
| `containerImage`| N | URI of the container image to be used when deploying to Kubernetes dev/test environment. | `ghcr.io/dapr/samples/hello-k8s-python:latest`
303
+
| `createService`| N | Create a Kubernetes service for the application when deploying to dev/test environment. | `true`, `false` |
304
+
305
+
{{< /table >}}
306
+
307
+
## Next steps
308
+
309
+
Watch [this video for an overview on Multi-App Run in Kubernetes](https://youtu.be/nWatANwaAik?si=O8XR-TUaiY0gclgO&t=1024):
0 commit comments