Adding health checks
Health checks (also known as liveness and readiness probes) are a way for any Pod to make its current functional state discoverable by other components in the cluster. This is usually done by way of exposing an endpoint in the container (traditionally /healthz
for liveness checks and /readyz
for readiness). That endpoint can be reached by other components (such as the kubelet) to determine whether the Pod is healthy and ready to serve requests. The topic is covered in detail in the Kubernetes documentation at https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/.
The code initialized by the Operator SDK in main.go
contains the healthz
and readyz
check setup by default:
main.go
import (
...
"sigs.k8s.io/controller-runtime/pkg/healthz"
)
func main() {
...
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{...