Adds documentation for gRPC health checks.

This commit is contained in:
James Phillips 2018-02-02 17:53:49 -08:00
parent 5f31c8d8d3
commit 49772f93bb
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11

View File

@ -15,7 +15,7 @@ service. If not associated with a service, the check monitors the health of the
A check is defined in a configuration file or added at runtime over the HTTP interface. Checks A check is defined in a configuration file or added at runtime over the HTTP interface. Checks
created via the HTTP interface persist with that node. created via the HTTP interface persist with that node.
There are five different kinds of checks: There are several different kinds of checks:
* Script + Interval - These checks depend on invoking an external application * Script + Interval - These checks depend on invoking an external application
that performs the health check, exits with an appropriate exit code, and potentially that performs the health check, exits with an appropriate exit code, and potentially
@ -44,7 +44,7 @@ There are five different kinds of checks:
10 seconds. It is possible to configure a custom HTTP check timeout value by 10 seconds. It is possible to configure a custom HTTP check timeout value by
specifying the `timeout` field in the check definition. The output of the specifying the `timeout` field in the check definition. The output of the
check is limited to roughly 4KB. Responses larger than this will be truncated. check is limited to roughly 4KB. Responses larger than this will be truncated.
HTTP checks also support SSL. By default, a valid SSL certificate is expected. HTTP checks also support TLS. By default, a valid TLS certificate is expected.
Certificate verification can be turned off by setting the `tls_skip_verify` Certificate verification can be turned off by setting the `tls_skip_verify`
field to `true` in the check definition. field to `true` in the check definition.
@ -91,6 +91,16 @@ There are five different kinds of checks:
must be configured with [`enable_script_checks`](/docs/agent/options.html#_enable_script_checks) must be configured with [`enable_script_checks`](/docs/agent/options.html#_enable_script_checks)
set to `true` in order to enable Docker health checks. set to `true` in order to enable Docker health checks.
* gRPC + Interval - These checks are intended for applications that support the standard
[gRPC health checking protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md).
The state of the check will be updated at the given interval by probing the configured
endpoint. By default, gRPC checks will be configured with a default timeout of 10 seconds.
It is possible to configure a custom timeout value by specifying the `timeout` field in
the check definition. gRPC checks will default to not using TLS, but TLS can be enabled by
setting `grpc_use_tls` in the check definition. If TLS is enabled, then by default, a valid
TLS certificate is expected. Certificate verification can be turned off by setting the
`tls_skip_verify` field to `true` in the check definition.
## Check Definition ## Check Definition
A script check: A script check:
@ -166,6 +176,20 @@ A Docker check:
} }
``` ```
A gRPC check:
```javascript
{
"check": {
"id": "mem-util",
"name": "Service health status",
"grpc": "127.0.0.1:12345",
"grpc_use_tls": true,
"interval": "10s"
}
}
```
Each type of definition must include a `name` and may optionally provide an Each type of definition must include a `name` and may optionally provide an
`id` and `notes` field. The `id` must be unique per _agent_ otherwise only the `id` and `notes` field. The `id` must be unique per _agent_ otherwise only the
last defined check with that `id` will be registered. If the `id` is not set last defined check with that `id` will be registered. If the `id` is not set
@ -187,8 +211,8 @@ Checks may also contain a `token` field to provide an ACL token. This token is
used for any interaction with the catalog for the check, including used for any interaction with the catalog for the check, including
[anti-entropy syncs](/docs/internals/anti-entropy.html) and deregistration. [anti-entropy syncs](/docs/internals/anti-entropy.html) and deregistration.
Script, TCP, Docker and HTTP checks must include an `interval` field. This field is Script, TCP, HTTP, Docker, and gRPC checks must include an `interval` field. This
parsed by Go's `time` package, and has the following field is parsed by Go's `time` package, and has the following
[formatting specification](https://golang.org/pkg/time/#ParseDuration): [formatting specification](https://golang.org/pkg/time/#ParseDuration):
> A duration string is a possibly signed sequence of decimal numbers, each with > A duration string is a possibly signed sequence of decimal numbers, each with
> optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". > optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m".
@ -206,8 +230,8 @@ any expected recoverable outage for the given service.
To configure a check, either provide it as a `-config-file` option to the To configure a check, either provide it as a `-config-file` option to the
agent or place it inside the `-config-dir` of the agent. The file must agent or place it inside the `-config-dir` of the agent. The file must
end in the ".json" extension to be loaded by Consul. Check definitions can end in a ".json" or ".hcl" extension to be loaded by Consul. Check definitions
also be updated by sending a `SIGHUP` to the agent. Alternatively, the can also be updated by sending a `SIGHUP` to the agent. Alternatively, the
check can be registered dynamically using the [HTTP API](/api/index.html). check can be registered dynamically using the [HTTP API](/api/index.html).
## Check Scripts ## Check Scripts