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?
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.
Google Container Engine health checks are recognizable by the HTTP request header 'user-agent' having the value GoogleHC/1.0
.
if ((request.headers['user-agent'] || '').toLowerCase().startsWith('googlehc')) {
return reply('Healthy')
}