This project serves as an adapter for services that send status information through the systemd
NOTIFY_SOCKET
Unix domain socket. It is designed to be run as a sidecar inside of a Kubernetes Pod
resource.
It serves the following endpoints:
/healthz
: Whether the adapter is ready to serve requests. This can be used as the startup probe for the sidecar container.503
: The adapter is not ready to receive messages200
: The adapter is ready to receive messages
/livez
: Whether the service is live. This can be used as the liveness probe for thePod
.503
: The service is not live200
: The service is live
/readyz
: Whether the service is ready. This can be used as the readiness probe for thePod
.503
: The service is not ready200
: The service is ready
Additionally, each endpoint returns a JSON response in the following format:
{
timestamp: "1970-01-01T00:00:00+00:00", // An RFC 3339 timestamp
healthz: true, // The value of the `/healthz` endpoint
livez: true, // The value of the `/healthz` endpoint
readyz: true, // The value of the `/readyz` endpoint
}
-
NOTIFY_SOCKET
default
/var/run/adapter/adapter.sock
The path of the socket to create
-
ADAPTER_PORT
default
8089
The port for the HTTP server to listen to
-
ADAPTER_ECHO
default
true
- If
true
, the adapter will reserialze all messages to standard output - If
false
, there is no standard output
- If
-
ADAPTER_LOG
default
true
- If
true
, the adapter will log JSONL records to standard error - If
false
, there is no standard error
- If
-
ADAPTER_CHANNEL_SIZE
default
32
The channel size to use for internal message-passing
-
ADAPTER_INITIAL_LIVEZ
default
false
- If
true
,/livez
will return that the service is live until a status change occurs - If
false
,/livez
will return that the service is not live until a status change occurs
- If
-
ADAPTER_INITIAL_READYZ
default
false
- If
true
,/readyz
will return that the service is ready until a status change occurs - If
false
,/readyz
will return that the service is not ready until a status change occurs
- If
-
ADAPTER_ALLOW_MESSAGE_WATCHDOG_USEC
default
true
- If
true
, the adapter will processWATCHDOG_USEC
messages and override the current configuration ofADAPTER_UNIT_WATCHDOG_SEC
(in microseconds). - If
false
, the adapter ignoresWATCHDOG_USEC
messages.
- If
-
ADAPTER_ALLOW_MESSAGE_EXTEND_TIMEOUT_USEC
default
true
- If
true
, the adapter will processEXTEND_TIMEOUT_USEC
messages and extend the startup timeout configured byADAPTER_UNIT_TIMEOUT_START_SEC
by the specified number of microseconds. - If
false
, the adapter ignoresEXTEND_TIMEOUT_USEC
messages.
- If
How /livez
and /readyz
react to adapter events is configurable. If multiple messages are processed at the same time, false
reactions have priority over true
reactions.
-
ADAPTER_STATUS_LIVEZ_TRUE
default
ready,watchdog
Comma-separated list of events to react to, changing the status of
/livez
totrue
-
ADAPTER_STATUS_LIVEZ_FALSE
default
errno,buserror,watchdog_trigger,watchdog_timeout,start_timeout
Comma-separated list of events to react to, changing the status of
/livez
tofalse
-
ADAPTER_STATUS_READYZ_TRUE
default
ready,watchdog
Comma-separated list of events to react to, changing the status of
/readyz
totrue
-
ADAPTER_STATUS_READYZ_FALSE
default
reloading,stopping,errno,buserror,watchdog_trigger,watchdog_timeout,start_timeout
Comma-separated list of events to react to, changing the status of
/readyz
tofalse
-
ADAPTER_STATUS_SHUTDOWN
default empty
Comma-separated list of events to react to, shutting down the adapter
ready
: the adapter has processed aREADY=1
messagereloading
: the adapter has processed aRELOADING=1
messagestopping
: the adapter has processed aSTOPPING=1
messageerrno
: the adapter has proccesed aERRNO=...
messagebuserror
: the adapter has proccesed aBUSERROR=...
messagewatchdog
: the adapter has processed aWATCHDOG=1
messagewatchdog_trigger
: the adapter has processed aWATCHDOG=trigger
messagewatchdog_timeout
: the watchdog has timed out waiting forWATCHDOG=1
start_timeout
: the startup timer has timed out waiting forREADY=1
Refer to the systemd.service
man page for additional details.
-
ADAPTER_UNIT_TIMEOUT_START_SEC
default
90
Roughly equivalent to
TimeoutStartSec=
in asystemd
unit configuration; sends thestart_timeout
event if the firstREADY=1
message is not sent in time. -
ADAPTER_UNIT_WATCHDOG_SEC
default
0
(disabled)Roughly equivalent to
WatchdogSec=
in asystemd
unit configuration; enables watchdog functionality. By default it is set to0
(disabled).
The adapter can process the following messages. If an unsupported but well-known message is received, it may be parsed and echoed, but is otherwise ignored. If an unknown message is received, it is only mentioned in the error log. Refer to the sd_notify
man page for additional details.
Message | Purpose |
---|---|
READY=1 |
Sends event ready |
RELOADING=1 |
Sends event reloading |
STOPPING=1 |
Sends event stopping |
ERRNO=... |
Sends event errno |
BUSERROR=... |
Sends event buserror |
WATCHDOG=1 |
Sends event watchdog and updates the watchdog |
WATCHDOG=trigger |
Sends event watchdog_trigger |
WATCHDOG_USEC=... |
Supported if ADAPTER_ALLOW_MESSAGE_WATCHDOG_USEC is true |
EXTEND_TIMEOUT_USEC=... |
Supported if ADAPTER_ALLOW_MESSAGE_EXTEND_TIMEOUT_USEC is true |
pre-commit install
rustup install nightly