How should I check the health of my go service in Kubernetes?

5/24/2016

I'm running a service written in go in a pod in Kubernetes. The service doesn't expose an HTTP interface; it's processing work from a queue.

I could:

  • Use an executable liveness check to see if the process is running
  • Expose an HTTP health check endpoint
  • Use expvars to expose basic health data.

Is there a common / idiomatic way of doing this in go/Kubernetes?

-- Ross McFarlane
go
kubernetes
kubernetes-health-check

2 Answers

5/24/2016

I won't get into reasoning about the convenience of instrumenting the process running into the pod to focus on the question.

I'd avoid creating another process inside the container to expose data, or modify the current process just to expose health endpoint, so I'd choose the liveness check exec way. It doesn't gets into your application and hopefully, it will only consume some cycles of CPU periodically.

Anyway, if you decide to expose health info from the pod, I'd use a multi-container pod, with the health exposing application as a sidecar and the working process in a different container.

-- Pablo Mercado
Source: StackOverflow

8/31/2016

In general I recommend the HTTP mechanism because it is SO easy to add in Go. If you already have an execable command that will return a useful status, go for it. Or you might consider https://github.com/kubernetes/contrib/tree/master/exec-healthz

-- Tim Hockin
Source: StackOverflow