<p>Apart from @rohatgisanat <a href="https://devops.stackexchange.com/a/14134/28042">answer</a> which explains the Kubernetes side, Microsoft did a pretty good job on explaining its own HC middleware on the service side: <a href="https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-5.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-5.0</a></p>
<p>So the only thing for you to do is combine this knowledge :)</p>

CC BY-SA 4.0
2021-06-10T12:49:21.660Z
2021-06-10T12:49:21.660Z
Karolina Ochlik
<p>Any code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure.</p>
<p>More info is found here :- <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#:%7E:text=The%20kubelet%20uses%20liveness%20probes,application%20more%20available%20despite%20bugs" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#:~:text=The%20kubelet%20uses%20liveness%20probes,application%20more%20available%20despite%20bugs</a>.</p>

CC BY-SA 4.0
2021-06-09T19:13:36.520Z
2021-06-09T19:13:36.520Z
rohatgisanat
<p>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.<br/></p>
<pre><code>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
</code></pre>
<p>Apart from this what changes do I need to do in my C# code ? I am using below Kubernetes nuget in .csproj :</p>
<pre><code>&lt;PackageReference Include=&quot;KubernetesClient&quot; Version=&quot;3.0.7&quot; /&gt;
</code></pre>

CC BY-SA 4.0
2021-05-31T20:21:24.410Z
your app must respond to the defined health probe
Sathyajith Bhat
CC BY-SA 4.0
2021-06-01T07:45:51.943Z
@SathyajithBhat: what respond it shall do, is there any document that define the steps ?
solveit
CC BY-SA 4.0
2021-06-01T13:50:31.370Z
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
<kubernetes><dotnet><healthcheck>
Code Changes for Implementing Kubernetes Probes
solveit
# Code Changes for Implementing Kubernetes Probes

(Asked by: username_0 on 2021-05-30)

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 :

**Tags:** kubernetes, dotnet, healthcheck

> **Comments:**
> **username_1**: your app must respond to the defined health probe  
> **username_0**: @SathyajithBhat: what respond it shall do, is there any document that define the steps ?  
> **username_2**: 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.  

---

## 2 answers

### Answer by username_3 on 2021-06-10. Score: 0 | Accepted answer

Apart from @username_4 [answer](https://devops.stackexchange.com/a/14134/28042) 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 :)


---

### Answer by username_4 on 2021-06-09. Score: 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](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#:%7E:text=The%20kubelet%20uses%20liveness%20probes,application%20more%20available%20despite%20bugs).


---

