1

I have a .net framework application written in C# running in K8s orchestration. I simply want to check in fixed interval (lets say in every 300sec) that my application which is running inside pod is responding or not.

Can someone let me know how to do this?

solveit
  • 255
  • 2
  • 11
  • Define "running". How would you check this if the app were not in a container? Perhaps the answer to that question provides clues. – berndbausch May 24 '21 at 11:42
  • I am not sure what is the problem here? Why do you want to check if the application is responding? Maybe k8s probes are the solution you are looking for, but I don't really know since you are not really explaining whats the end goal here. – Matt May 24 '21 at 12:08
  • its a high availability application. its a backup/monitoring feature to keep a check that app is responding or not. I came across something called heartbeat service. is it same as probs in k8s ? – solveit May 24 '21 at 12:17
  • I've never used [heartbeat](https://www.elastic.co/beats/heartbeat), but it looks like its only used for monitoring. K8s probes are a bit different. There are two types of k8s probes, readiness probes and liveness probes. Liveness probe is used to to check if an app is alive. If a probe fails, container is restarted (probe assumes container is dead since liveness probe failed). Readiness probes check if an app is ready to serve traffic. If readiness probe fails, pod is removed from a list of service endpoints (and no requests are sent to this pod until the readiness probe stops failing). – Matt May 24 '21 at 12:31
  • Check the k8s docs [configure-liveness-readiness-startup-probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/). There are also startup probes but you can read more about them in docs. But I am still not sure what you are trying to achieve. Are you asking how to monitor you application with heartbeat? – Matt May 24 '21 at 12:40
  • @Matt: I guess you answered. I am looking for probes to diagnose and take action when application or container not responding. – solveit May 25 '21 at 08:16

1 Answers1

1

Here is my summarized answer; Since what you are trying to do is monitor your application and take action in case of its failure, K8s probes are there to help you with this.

There are three types of k8s probes, readiness probes, liveness probes and stratup probes.

Liveness probe is used to to check if an app is alive. If a probe fails, container is restarted (probe assumes container is dead since liveness probe failed).

Readiness probes check if an app is ready to serve traffic. If readiness probe fails, pod is removed from a list of service endpoints (and no requests are sent to this pod until the readiness probe stops failing)

Startup probes are used to check if application started properly. All other probes are disabled if a startup probe is provided, until it succeeds.

Check the k8s docs for more information: configure-liveness-readiness-startup-probes

Matt
  • 528
  • 3
  • 7