![]() |
VOOZH | about |
dotnet add package HealthChecks.Kubernetes.Aspire --version 2.0.2
NuGet\Install-Package HealthChecks.Kubernetes.Aspire -Version 2.0.2
<PackageReference Include="HealthChecks.Kubernetes.Aspire" Version="2.0.2" />
<PackageVersion Include="HealthChecks.Kubernetes.Aspire" Version="2.0.2" />Directory.Packages.props
<PackageReference Include="HealthChecks.Kubernetes.Aspire" />Project file
paket add HealthChecks.Kubernetes.Aspire --version 2.0.2
#r "nuget: HealthChecks.Kubernetes.Aspire, 2.0.2"
#:package HealthChecks.Kubernetes.Aspire@2.0.2
#addin nuget:?package=HealthChecks.Kubernetes.Aspire&version=2.0.2Install as a Cake Addin
#tool nuget:?package=HealthChecks.Kubernetes.Aspire&version=2.0.2Install as a Cake Tool
Aspire.HealthChecks.Kubernetes provides extension methods to easily add Kubernetes-related probes and health checks to your ASP.NET Core applications and the Aspire Dashboard. These health checks help monitor the health of your application in a Kubernetes environment by checking the status of the Kubernetes API, nodes, and pods. You can use it with, or without the Aspire integration.
Kubernetes health probes are essential for ensuring that your application is running smoothly within a Kubernetes cluster. They allow you to monitor the health of the Kubernetes API, nodes, and pods, providing insights into the operational status of your application. These checks can be integrated into your ASP.NET Core application to provide a robust health monitoring solution. The 3 health probes used by Kubernetes are:
Add a reference to the Aspire.HealthChecks.Kubernetes project or package in your ASP.NET Core application.
dotnet add package HealthChecks.Kubernetes.Aspire
If you are using the Aspire Dashboard, add a reference to the Aspire.Hosting.HealthChecks.Kubernetes project in your Aspire AppHost project.
dotnet add package HealthChecks.Kubernetes.Aspire.Hosting
This will add the 3 health checks to your application. You can then easily use them in your kubernetes pod yaml file to configure the health checks for your application. That way Kubernetes can monitor the health of your application and restart it if necessary.
In your Program.cs:
var builder = WebApplication.CreateBuilder(args);
// Register The general Health Check service
var healthChecksBuilder = builder.Services.AddHealthChecks();
// Add your Health Checks with the Tags from Aspire.HealthChecks.Kubernetes.Common.Constants
healthChecksBuilder.Services.Configure<HealthCheckServiceOptions>(o =>
{
o.Registrations.Add(new HealthCheckRegistration("My Health Check", new MyHealthCheck(), null, [Constants.LiveTag]));
});
var app = builder.Build();
// Register Kubernetes health checks
app.UseKubernetesHealthChecks();
await app.RunAsync();
If you are using the Aspire Dashboard, you can easily add the Kubernetes health probes to your Aspire AppHost project. This will automatically register the health probes and checks with the Aspire Dashboard, allowing you to monitor the health of your application from the dashboard.
In your Program.cs:
var builder = DistributedApplication.CreateBuilder(args);
/// Add your application
builder.AddProject<MyApp>(nameof(MyApp))
.WithKubernetesHealthProbes();
var app = builder.Build();
await app.RunAsync();
If you are dealing with ExternalServiceResource, or do not want probes, you can use WithKubernetesHealthChecks() instead.
In your Program.cs:
var builder = DistributedApplication.CreateBuilder(args);
/// Add your application
builder.AddExternalService("MyExternalService", "https://example.com")
.WithKubernetesHealthChecks();
var app = builder.Build();
await app.RunAsync();
This project is licensed under the Unlicense.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on HealthChecks.Kubernetes.Aspire:
| Package | Downloads |
|---|---|
|
RESTworld.AspNetCore
Package Description |
This package is not used by any popular GitHub repositories.