Answers Kubernetes liveness, startup, and readiness TCP probes based on the results from the Health Checks service.
From the command-line:
dotnet add package Microsoft.Extensions.Diagnostics.ProbesOr directly in the C# project file:
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Diagnostics.Probes" Version="[CURRENTVERSION]" />
</ItemGroup>The health check endpoints can be registered and configured with the following methods:
public static IServiceCollection AddKubernetesProbes(this IServiceCollection services)
public static IServiceCollection AddKubernetesProbes(this IServiceCollection services, IConfigurationSection section)
public static IServiceCollection AddKubernetesProbes(this IServiceCollection services, Action<KubernetesProbesOptions> configure)Each type of probe handler can have its details configured separately.
services.AddKubernetesProbes(options =>
{
options.LivenessProbe.TcpPort = 2305;
options.StartupProbe.TcpPort = 2306;
options.ReadinessProbe.TcpPort = 2307;
})The HealthAssessmentPeriod property defines how often the health-checks are assessed. By default 30 seconds.
Each probe can also specify Func<HealthCheckRegistration, bool>? FilterChecks to customize which health checks are run.
We welcome feedback and contributions in our GitHub repo.