How can I use Kubernetes Python API to check health endpoints?

5/21/2021

I'm seeking the answer regarding how to use the Kubernetes Python API to check health

I am using:

kubectl get --raw='/readyz?verbose'  
-- karlos
kubectl
kubernetes

1 Answer

5/24/2021

kubectl get --raw='/readyz?verbose' is probing the /readyz endpoint of the Kubernetes apiserver.

If you want to check the current running and ready state of a Pod and its containers, you can look at the Pod's status.Conditions and status.ContainerStatuses field.

If you want to probe the health endpoints of a container directly, you can use kubectl proxy or kubectl port-forward to open a proxy connection into the Pod's network namespace, then probe the health endpoint through that proxy.

-- Dharma Bellamkonda
Source: StackOverflow