Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Providing multiple health check URLs for kubernetes probes

I am using container Probes to check the health of the application running inside the container within kubernetes pod. For now my example pod config looks like,

"spec":{
   "containers":[
      {
        "image":"tomcat",
        "name":"tomcat",
        "livenessProbe":{
           "httpGet":{
              "port": 80
            },
            "initialDelaySeconds": 15,
            "periodSeconds": 10
        }
      }
   ]
}

In my case, I need to monitor two ports for the same container. 80 and 443. But I am unable to find a method to provide both the ports for same container in the config file. Is there an alternate way of doing this?

like image 472
Sujai Sivasamy Avatar asked Apr 11 '17 07:04

Sujai Sivasamy


People also ask

What are the two types of health checks available in Kubernetes?

Kubernetes gives you two types of health checks performed by the kubelet. They are: Startup Probe. Liveness Probe.

How the pod health check is done?

To check the status of the pod, run the kubectl get pod command and check the STATUS column. As you can see, in this case all the pods are in running state. Also, the READY column states the pod is ready to accept user traffic.


2 Answers

If you have curl / wget on the container you could just run a container exec healthcheck, and do something like curl localhost:80 && curl localhost:443.

like image 102
Chris Stryczynski Avatar answered Nov 12 '22 14:11

Chris Stryczynski


It's not possible, try to encapsulate the health check inside your application

Ex: http://localhost:80/health_check?full => (proxy to) => http://localhost:443/health_check?full

can be help you https://github.com/kubernetes/kubernetes/issues/37218

like image 43
Giancarlo Rubio Avatar answered Nov 12 '22 16:11

Giancarlo Rubio