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:
Is there a common / idiomatic way of doing this in go/Kubernetes?
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.
In general I recommend the HTTP mechanism because it is SO easy to add in Go. If you already have an exec
able command that will return a useful status, go for it. Or you might consider https://github.com/kubernetes/contrib/tree/master/exec-healthz