Skip to content

Latest commit

 

History

History

Bet.Extensions.HealthChecks

Bet.Extensions.HealthChecks

GitHub license Build status NuGet Nuget feedz.io

The second letter in the Hebrew alphabet is the ב bet/beit. Its meaning is "house". In the ancient pictographic Hebrew it was a symbol resembling a tent on a landscape.

Note: Pre-release packages are distributed via feedz.io.

Summary

The collection of the HealthChecks functionality for IHost that can be used within the Worker in Kubernetes.

buymeacoffee

Give a Star! ⭐

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

Install

    dotnet add package Bet.Extensions.HealthChecks

Usage

  1. Add HealthCheck configuration in ConfigureServices.
    services.AddHealthChecks()
        // validates ssl certificate
        .AddSslCertificateCheck("localhost", "https://localhost:5001")
        .AddSslCertificateCheck("kdcllc", "https://kingdavidconsulting.com")
        // Checks specific url
        .AddUriHealthCheck("200_check", builder =>
        {
            builder.Add(option =>
            {
                option.AddUri("https://httpstat.us/200")
                        .UseExpectedHttpCode(HttpStatusCode.OK);
            });

            builder.Add(option =>
            {
                option.AddUri("https://httpstat.us/203")
                        .UseExpectedHttpCode(HttpStatusCode.NonAuthoritativeInformation);
            });
        })
        .AddUriHealthCheck("ms_check", uriOptions: (options) =>
        {
            options.AddUri("https://httpstat.us/503").UseExpectedHttpCode(503);
        })
        // used with kubernetes
        .AddSigtermCheck("Sigterm_shutdown_check")
        .AddSocketListener(8080);

Helm configuration for Kubernetes

spec:
  containers:
    - name: { { .Chart.Name } }
      image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
      imagePullPolicy: { { .Values.image.pullPolicy } }
      ports:
        - name: health
          containerPort: 8080
          protocol: TCP
      livenessProbe:
        tcpSocket:
          path: /
          port: health
      readinessProbe:
        tcpSocket:
          path: /
          port: health