How to specify IPs for pods I want to health check?

11/15/2021

I am trying to add health probes (HTTP probes) to my microservice. I use K8 and have 2 pods. I am following the documentation but I can't understand how I can create health check requests for the specific pod.

Should I create the third pod using liveness/readiness image? How can I specify the IP of the pod I want to heath check?

-- Marcin Gemra
health-check
kubernetes

1 Answer

11/15/2021

You do not need to create any additional pod or image for this purpose. Kubernetes probes use some ways for checking containers (i.e. HTTP request, TCP check). If we talk about the below snippet sample, kubelet itself send HTTP request to the respective port /healtz path under certain conditions (such as periodSeconds or initialDelaySeconds) which is described in the documentation and decide pod health whether running state or not with considering HTTP response code (such as HTTP 2xx OK or 5xx server error). Basically if kubelet receive success reponse code it decide pod is running state or if it gets 5xx response code pod never switch to the running state

readinessProbe:
  httpGet:
    scheme: HTTPS
    path: /healthz
    port: 8443
  initialDelaySeconds: 10
  periodSeconds: 5
-- Kağan Mersin
Source: StackOverflow