Google Container Engine - How do I detect that requests to my service are health checks?

4/27/2016

On Google Container Engine, how do I detect that requests to my Web service, running behind an L7 load balancer, are in fact health checks?

-- aknuds1
google-kubernetes-engine
kubernetes
load-balancing

2 Answers

4/28/2016

Instead of relying on user specified parameters like user-agent, I think the standard for this is just to make a /healthz route that returns 200 if healthy. The internal Kubernetes components all do this.

-- Christian Stewart
Source: StackOverflow

4/27/2016

Google Container Engine health checks are recognizable by the HTTP request header 'user-agent' having the value GoogleHC/1.0.

Example Hapi.js code:

if ((request.headers['user-agent'] || '').toLowerCase().startsWith('googlehc')) {
  return reply('Healthy')
}
-- aknuds1
Source: StackOverflow