<p>Is there a generic way to query a container's health?</p>
<p>I want to inject a generic sidecar container into every pod which exposes the 'main' container's health on a different endpoint.</p>
<p>My main container is protected behind <code>oauth2</code> so I cannot do any uptime checks using <code>StatusCake</code> for example.</p>
<p>The idea was to inject a sidecar which can report only the container health on an exposed path. Then I could configure <code>StatusCake</code> to query that endpoint instead.</p>
<p>I could query the 'official' health endpoint in my sidecar, but I don't know how to inject the path generically.</p>
<p>Also I was wondering whether I could check the health via some <code>kubectl</code> command?</p>

<p>I would suggest using <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">readiness probe</a> provided by kubernetes as health check of the sidecar container.Then you can use <code>kubectl</code> to check the health of the sidecar container as well as use StatusCake</p>
<p>As part of the implementation of the readiness probe of the sidecar you do a health check of the main container. Since the sidecar container and main container are part of same pod <code>localhost</code> can be used to connect to main container from the sidecar container.</p>
