-2

I want to implement Kubernetes Liveliness Probes in my .Net core application with C# language. I understood that first I need to define the liveliness probe in deployment.yaml file of my application. I also created the http service in my application that is responding at 8080 port.

apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-http
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/liveness
    args:
    - /server
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
        - name: Custom-Header
          value: Awesome
      initialDelaySeconds: 3
      periodSeconds: 3

Apart from this what changes do I need to do in my C# code ? I am using below Kubernetes nuget in .csproj :

<PackageReference Include="KubernetesClient" Version="3.0.7" />
solveit
  • 105
  • 2

2 Answers2

0

Any code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure.

More info is found here :- https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#:~:text=The%20kubelet%20uses%20liveness%20probes,application%20more%20available%20despite%20bugs.

rohatgisanat
  • 431
  • 1
  • 3
  • 10
0

Apart from @rohatgisanat answer which explains the Kubernetes side, Microsoft did a pretty good job on explaining its own HC middleware on the service side: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-5.0

So the only thing for you to do is combine this knowledge :)