The examples in this post are for a TCP health check see Health Checks for detailed motivation and alternatives like HTTP.
“Kubernetes relies on probes in your application to assess whether your application is healthy.” - dzone.com
If the worker instance is un-healthy then K8s will tear it down and spin up a new instance.
Install the following package :
Create a simple health check that implements IHealthCheck and always returns healthy.
- Create a new background service to accept the TCP socket liveness probe, this code was adapted from dzone.com and is intentionally simple without logging and error handling. So turn piss off Karen 😛
public class TcpLivenessProbeService : BackgroundService
- Now resolve the dependencies in Program.cs
// Liveness check
- You will then need to configure the liveness probe in K8s to query port 5000