Over the past year containerizing applications has become an extremely popular practice to quickly develop, ship and deploy applications. With the help of containerization tools like Docker, the desired container environment can be described in a declarative manner.
With Kubernetes, containerized applications can be deployed, scaled when needed, and further managed. Kubernetes has self-healing powers for containers — but only works to it’s fully potential when it’s set up right.
In this article, we are going to implement health checks and corresponding probes so that Kubernetes is able to define whether a containerized application is healthy and can act accordingly.
_The implementation examples on the application side are implemented with .NET Core. The theory and implementations can be as well applied to Java/Spring Boot applications. Spring Boot offers the _Actuator module_ to implement comparable functionality that is stated further into this article._
To understand what a probe in Kubernetes context is, it is smart to take a step back and look into what the definition of the word:
verb (used with object), probed, prob·ing.
1. to search into or examine thoroughly; question closely:to probe one’s conscience.
2. to examine or explore with a probe.
verb (used without object), probed, prob·ing.
3. to examine or explore with or as if with a probe.
noun
4. the act of probing.
_Definition by _Dictionary
With the help of the definition above, Kubernetes probes can be defined as an instrument to examine the state of a container. Kubernetes uses this probe functionality to determine if a container and thus the pod is unhealthy and if so, Kubernetes will use its self-healing power. Kubernetes will try to schedule replacement pods to get back to the desired amount of instances(replicas) of pods to get to a healthy state again.
Kubernetes uses probes during a rolling update to determine if the newly deployed pod is up. Only after reporting the new pod up, the old pod will be removed.
Kubernetes has three types of probes that can be declared:
#kubernetes #dotnet #software-development #cloud #resilience