Replies: 1 comment
-
Hi @meharwan-singh-maersk To implement a health check for your .NET application running as a container in Kubernetes, you can create an endpoint in your application that returns the status of your topic consumer. This endpoint can be accessed by Kubernetes to check the health of your application. Here's an example of how you can implement a health check endpoint in .NET: using Microsoft.AspNetCore.Mvc;
[Route("api/[controller]")]
[ApiController]
public class HealthController : ControllerBase
{
[HttpGet]
public IActionResult Check()
{
// Add your health check logic here
bool isHealthy = true;
if (isHealthy)
{
return Ok();
}
else
{
return StatusCode(500);
}
}
} You can then expose this endpoint in your Kubernetes deployment YAML file using a livenessProbe or readinessProbe. Here's an example:
This configuration sets up a livenessProbe that checks the /api/health endpoint every 10 seconds, with an initial delay of 30 seconds. If the endpoint returns a status code of 200, the container is considered healthy. If it returns a status code of 500, the container is considered unhealthy and will be restarted by Kubernetes. You can customize this configuration to fit your specific needs, including adding additional checks or changing the endpoint URL. I hope the answer helps you. |
Beta Was this translation helpful? Give feedback.
-
I have an application which in consumer for a topic and deployed in k8s as container. I want to push the health check for same. How we can do that? I need bit depth information in this topic , specific to hosted server , For API I already know.
Thank You
Beta Was this translation helpful? Give feedback.
All reactions