-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" />
3
  • your app must respond to the defined health probe – Sathyajith Bhat May 31 at 20:21
  • @SathyajithBhat: what respond it shall do, is there any document that define the steps ? – solveit Jun 1 at 7:45
  • It needs to respond with 200 status code. Your question is being down voted because you used image instead of code, edit the question and remove the image. – Kyslik Jun 1 at 13:50
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 :)

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.