7

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?

Sujai Sivasamy
  • 1,101
  • 3
  • 14
  • 32
  • I tried HEALTHCHECK docker command while creating the docker image. But even if the container is unhealthy, pod description doesn't give those details. I just states that the container is in running phase. – Sujai Sivasamy Apr 11 '17 at 08:46

3 Answers3

2

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

2

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.

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
  • This is what it looks like: https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/pods/probe/exec-liveness.yaml – Tillerino Jul 24 '20 at 10:34
1

This would be a very useful feature but that is missing. As others mentioned earlier you can use a script for health check instead of httpget and check both urls in that script.
One another option is to create a sidecar health container to monitor both urls of the main container and take action.

techuser soma
  • 4,766
  • 5
  • 23
  • 43