Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/outbound path for health checks #4043

Merged
merged 21 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
42fdb2b
initial add, need to create diagram to replace placeholder
hhunter-ms Feb 21, 2024
9a5172f
Merge branch 'v1.13' into issue_3704
hhunter-ms Feb 21, 2024
2fb2ed3
update diagram
hhunter-ms Feb 22, 2024
86dfaa6
Merge branch 'issue_3704' of https://github.com/hhunter-ms/docs into …
hhunter-ms Feb 22, 2024
4abce50
add diagram
hhunter-ms Feb 26, 2024
e6cc7fe
Merge branch 'v1.13' into issue_3704
hhunter-ms Feb 28, 2024
23b530c
Update sidecar-health.md
msfussell Feb 29, 2024
3f24031
Update health_api.md
msfussell Feb 29, 2024
633b052
Merge branch 'v1.13' into issue_3704
hhunter-ms Feb 29, 2024
103ea58
updates per mark
hhunter-ms Mar 1, 2024
e5f9dc0
Merge branch 'issue_3704' of https://github.com/hhunter-ms/docs into …
hhunter-ms Mar 1, 2024
e176899
edit and add cross-linking
hhunter-ms Mar 1, 2024
25739a0
Merge branch 'v1.13' into issue_3704
hhunter-ms Mar 1, 2024
cf4a0c2
Merge branch 'v1.13' into issue_3704
msfussell Mar 1, 2024
d948964
mark review
hhunter-ms Mar 4, 2024
d5dde4d
Merge branch 'issue_3704' of https://github.com/hhunter-ms/docs into …
hhunter-ms Mar 4, 2024
735029f
Merge branch 'v1.13' into issue_3704
hhunter-ms Mar 4, 2024
c1a840a
Merge branch 'v1.13' into issue_3704
hhunter-ms Mar 4, 2024
50fa51a
Merge branch 'v1.13' into issue_3704
msfussell Mar 4, 2024
e4c904b
link to js code
hhunter-ms Mar 4, 2024
c518c13
Merge branch 'issue_3704' of https://github.com/hhunter-ms/docs into …
hhunter-ms Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,47 @@ description: Dapr sidecar health checks

Dapr provides a way to determine its health using an [HTTP `/healthz` endpoint]({{< ref health_api.md >}}). With this endpoint, the *daprd* process, or sidecar, can be:

- Probed for its health
- Determined for readiness and liveness
- Probed for its overall health
- Probed for Dapr sidecar readiness during initialization
- Determined for readiness and liveness with Kubernetes

In this guide, you learn how the Dapr `/healthz` endpoint integrate with health probes from the application hosting platform (for example, Kubernetes).

When deploying Dapr to a hosting platform like Kubernetes, the Dapr health endpoint is automatically configured for you.
In this guide, you learn how the Dapr `/healthz` endpoint integrate with health probes from the application hosting platform (for example, Kubernetes) as well as the Dapr SDKs.
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

{{% alert title="Note" color="primary" %}}
Dapr actors also have a health API endpoint where Dapr probes the application for a response to a signal from Dapr that the actor application is healthy and running. See [actor health API]({{< ref "actors_api.md#health-check" >}}).
{{% /alert %}}

The following diagram shows the steps when a Dapr sidecar starts, the healthz endpoint and when the App channel is initialized.
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

<img src="/images/healthz-outbound.png" width="800" alt="Diagram of Dapr checking oubound health connections." />

## Outbound health endpoint

As shown by the red boundary lines in the diagram above, the `v1.0/healthz/` endpoint is used to wait for when:
- All components are initialized;
- The Dapr HTTP port is available; _and,_
- The app channel is initialized.

This is used to check the complete initialization of the Dapr sidecar and its health.

hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
On the other hand, as shown by the green boundary lines in the diagram above, the `v1.0/healthz/outbound` endpoint returns successfully when:
- All the components are initialized;
- The Dapr HTTP port is available; _but,_
- The app channel is not yet established.

In the Dapr SDKs, the `waitForSidecar`/`wait_until_ready` method (depending on [which SDK you use]({{< ref "#sdks-supporting-outbound-health-endpoint" >}})) is used for this specific check with the `v1.0/healthz/outbound` endpoint. Using this behavior, instead of waiting for the app channel to be available (see: red boundary lines) with the `v1.0/healthz/` endpoint, Dapr waits for a successful response from `v1.0/healthz/outbound`. This approach enables your application to perform calls on the Dapr sidecar APIs before the app channel is initalized - for example, reading secrets with the secrets API.

If you are using the `waitForSidecar`/`wait_until_ready` method on the SDKs, then the correct initialization is performed. Otherwise, you can call the `v1.0/healthz/outbound` endpoint during initalization, and if successesful, you can call the Dapr sidecar APIs.

### SDKs supporting outbound health endpoint
Currently, the `v1.0/healthz/outbound` endpoint is supported in the:
- [.NET SDK](https://github.com/dapr/dotnet-sdk/blob/17f849b17505b9a61be1e7bd3e69586718b9fdd3/src/Dapr.Client/DaprClientGrpc.cs#L1758-L1785)
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
- [Java SDK](https://github.com/dapr/java-sdk/blob/2f5947392a33bc7911e6669601ddb9e8b59b58fe/sdk/src/main/java/io/dapr/client/DaprClientHttp.java#L143-L165)
- [Python SDK](https://github.com/dapr/python-sdk/blob/0b7aafdab1d4fade424b1b6c9569329ad10bb516/dapr/clients/http/client.py#L52)


## Health endpoint: Integration with Kubernetes
When deploying Dapr to a hosting platform like Kubernetes, the Dapr health endpoint is automatically configured for you.

Kubernetes uses *readiness* and *liveness* probes to determines the health of the container.

Expand Down
64 changes: 55 additions & 9 deletions daprdocs/content/en/reference/api/health_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,80 @@ description: "Detailed documentation on the health API"
weight: 1000
---

Dapr provides health checking probes that can be used as readiness or liveness of Dapr.
Dapr provides health checking probes that can be used as readiness or liveness of Dapr and for initialization readiness from SDKs.

## Get Dapr health state

Gets the health state for Dapr.
Gets the health state for Dapr by either:
- Check for sidecar health
- Check for the sidecar health, including component readiness, used during initialization.

### HTTP Request
### Wait for Dapr HTTP port to become available

Wait for all components to be initialized, the Dapr HTTP port to be available _and_ the app channel is initialized. For example, this endpoint is used with Kubernetes liveness probes.

#### HTTP Request

```
GET http://localhost:<daprPort>/v1.0/healthz
```

### HTTP Response Codes
#### HTTP Response Codes

Code | Description
---- | -----------
204 | dapr is healthy
500 | dapr is not healthy
204 | Dapr is healthy
500 | Dapr is not healthy

### URL Parameters
#### URL Parameters

Parameter | Description
--------- | -----------
daprPort | The Dapr port.
daprPort | The Dapr port

### Examples
#### Examples

```shell
curl -i http://localhost:3500/v1.0/healthz
```

### Wait for specific health check against `/outbound` path

Wait for all components to be initialized, the Dapr HTTP port to be available, however the app channel is not yet established. This endpoint enables your application to perform calls on the Dapr sidecar APIs before the app channel is initalized, for example reading secrets with the secrets API. For example used in the Dapr SDKs `waitForSidecar` method (for example .NET and Java SDKs) to check sidecar is initialized correctly ready for any calls.

For example, the [Java SDK](https://docs.dapr.io/developing-applications/sdks/java/java-client/#wait-for-sidecar) and [the .NET SDK](https://github.com/dapr/dotnet-sdk/blob/17f849b17505b9a61be1e7bd3e69586718b9fdd3/src/Dapr.Client/DaprClientGrpc.cs#L1758-L1785) uses this endpoint for initialization.
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

Currently supported in the:
- [.NET SDK](https://github.com/dapr/dotnet-sdk/blob/17f849b17505b9a61be1e7bd3e69586718b9fdd3/src/Dapr.Client/DaprClientGrpc.cs#L1758-L1785)
- [Java SDK](https://github.com/dapr/java-sdk/blob/2f5947392a33bc7911e6669601ddb9e8b59b58fe/sdk/src/main/java/io/dapr/client/DaprClientHttp.java#L143-L165)
- [Python SDK](https://github.com/dapr/python-sdk/blob/0b7aafdab1d4fade424b1b6c9569329ad10bb516/dapr/clients/http/client.py#L52)

#### HTTP Request

```
GET http://localhost:<daprPort>/v1.0/healthz/outbound
```

#### HTTP Response Codes

Code | Description
---- | -----------
204 | Dapr is healthy
500 | Dapr is not healthy

#### URL Parameters

Parameter | Description
--------- | -----------
daprPort | The Dapr port

#### Examples

```shell
curl -i http://localhost:3500/v1.0/healthz/outbound
```

## Related articles

- [Sidecar health]({{< ref "sidecar-health.md" >}})
- [App health]({{< ref "app-health.md" >}})
1 change: 1 addition & 0 deletions daprdocs/content/en/reference/environment/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ The following table lists the environment variables used by the Dapr runtime, CL
| DAPR_COMPONENTS_SOCKETS_EXTENSION | .NET and Java pluggable component SDKs | A per-SDK configuration that indicates the default file extension applied to socket files created by the SDKs. Not a Dapr-enforced behavior. |
| DAPR_PLACEMENT_METADATA_ENABLED | Dapr placement | Enable an endpoint for the Placement service that exposes placement table information on actor usage. Set to `true` to enable in self-hosted mode. [Learn more about the Placement API]({{< ref placement_api.md >}}) |
| DAPR_HOST_IP | Dapr sidecar | The host's chosen IP address. If not specified, will loop over the network interfaces and select the first non-loopback address it finds.|
| DAPR_HEALTH_TIMEOUT | SDKs | Sets the time on the "wait for sidecar" availability. Overrides the default timeout setting of 60 seconds. |
Binary file added daprdocs/static/images/healthz-outbound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading