On Openshift/Kubernetes, when a readiness check is configured with a HTTP GET with a path on for example a spring boot app with a service and route, is the HTTP GET request calling the Openshift service or route or something else and expecting 200-399?
Thanks, B.
The kubernetes documentation on readiness and liveness probes states that
For an HTTP probe, the kubelet sends an HTTP request to the specified
path
andport
to perform the check. The kubelet sends the probe to the pod’s IP address, unless the address is overridden by the optionalhost
field inhttpGet
. [...] In most scenarios, you do not want to set thehost
field. Here’s one scenario where you would set it. Suppose the Container listens on 127.0.0.1 and the Pod’shostNetwork
field is true. Thenhost
, underhttpGet
, should be set to 127.0.0.1. If your pod relies on virtual hosts, which is probably the more common case, you should not usehost
, but rather set the Host header inhttpHeaders
.
So it uses the Pod's IP unless you set the host
field on the probe. The service or ingress route are not used here because the readiness and liveness probes are used to decide if the service or ingress route should send traffic to the Pod.
The HTTP request comes from the Kubelet. Each kubernetes node runs the Kubelet process, which is responsible for node registration, and management of pods. The Kubelet is also responsible for watching the set of Pods that are bound to its node and making sure those Pods are running. It then reports back status as things change with respect to those Pods.
When talking about the HTTP probe, the docs say that
Any code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure.
Correct, it is using a webhook to determine if the container is ready to serve requests or not. By default the request is made to the Pod IP directly since when it fails, the container IP is removed from all endpoints for all services. This can be overridden by the host
filed in the probe definition.
Any response code from 200-399 is considered a success as you have mentioned.