feat(controller): Add health endpoint (#1882)

* feat(controller): New health service and server

This change also implements a new listener purpose, `ops`.

`ops` (short for operations) is a new listener purpose that is
responsible for serving Boundary's operations endpoints, like health
and possibly metrics.

At Startup: `ops` listeners get configured as late as possible to catch
any errors with the startup process;

At Shutdown: If the health endpoint has been set-up, we introduce a
configurable delay in the process. This is to enable the health endpoint
to report unhealthy for that amount of time. `ops` listeners are also
the last listeners to be shutdown.
This commit is contained in:
Hugo authored and GitHub committed 2022-03-28 17:16:39 +01:00
1 parent 63d3481031
commit 244237cd2f
25 files changed
+2034 -23

No files matched your search

@@ -61,15 +61,23 @@ description will be read.
- `auth_token_time_to_live` - Maximum time to live (TTL) for all auth tokens globally (pertains
to all tokens from all auth methods). Valid time units are anything specified by Golang's
[ParseDuration()](https://golang.org/pkg/time/#ParseDuration) method. Default is 7 days.
- `auth_token_time_to_stale` - Maximum time of inactivity for all auth tokens globally (pertains
to all tokens from all auth methods). Valid time units are anything specified by Golang's
[ParseDuration()](https://golang.org/pkg/time/#ParseDuration) method. Default is 1 day.
- `graceful_shutdown_wait_duration` - Amount of time Boundary will wait before initiating the shutdown procedure,
after receiving a shutdown signal. In this state, Boundary still processes requests as normal but replies
with `503 Service Unavailable` to any health requests. This is designed to allow an operator to configure
load-balancers to preemptively stop new traffic to a Boundary instance that is going away. Valid time units
are anything specified by Go's [ParseDuration()](https://golang.org/pkg/time/#ParseDuration) method. Only
used when an `ops` listener is set and the Controller is present. Default is 0 seconds.
## KMS Configuration
The controller requires two KMS stanzas for `root` and `worker-auth` purposes:
```kms
```hcl
# Root KMS configuration block: this is the root key for Boundary
# Use a production KMS such as AWS KMS in production installs
kms "aead" {
@@ -130,6 +138,9 @@ controller {
name = "demo-controller-1"
description = "A controller for a demo!"
# After receiving a shutdown signal, Boundary will wait 10s before initiating the shutdown process.
graceful_shutdown_wait_duration = "10s"
# Database URL for postgres. This can be a direct "postgres://"
# URL, or it can be "file://" to read the contents of a file to
# supply the url, or "env://" to name an environment variable
@@ -162,6 +173,16 @@ listener "tcp" {
purpose = "cluster"
}
listener "tcp" {
# Should be the address of the NIC where your external systems'
# (eg: Load-Balancer) will connect on.
address = "10.0.0.1"
# The purpose of this listener block
purpose = "ops"
tls_disable = false
}
# Root KMS configuration block: this is the root key for Boundary
# Use a production KMS such as AWS KMS in production installs
kms "aead" {