Should we run a Consul container in every Pod?

4/20/2017

We run our stack on the Google Cloud Platform (hosted Kubernetes, GKE) and have a Consul cluster running outside of K8s (regular GCE instances).

Several services running in K8s use Consul, mostly for it's CP K/V Store and advanced locking, not so much for service discovery so far.

We recently ran into some issues with using the Consul service discovery from within K8s. Right now our apps talk directly to the Consul Servers to register and unregister services they provide.

This is not recommended best-practice, usually Consul clients (i.e. apps using Consul) should talk to the local Consul agent. In our setup there are no local Consul agents.

My Question: Should we run local Consul agents as sidekick containers in each pod?

IMHO this would be a huge waste of ressources, but it would match the Consul best-practies better.

I tried searching on Google, but all posts about Consul and Kubernetes talk about running Consul in K8s, which is not what I want to do.

-- tex
consul
kubernetes
service-discovery

2 Answers

10/23/2019

As the official Consul Helm chart and the documentation suggests the standard approach is to run a DaemonSet of Consul clients and then use a connect-side-car injector to inject sidecars into your node simply by providing an annotation of the pod spec. This should handle all of the boilerplate and will be inline with best practices.

-- tsturzl
Source: StackOverflow

2/19/2018

I dont understand what do you mean by Consul service discovery from within K8s, but we also have services available on VM-based environment that is discovered by Consul, which several pods should access.

If what you mean is to access services available on Consul from K8s pods, we accomplished it by making our internal Kubernetes DNS forward the consul zone to Consul servers. So we don't make Consul agent as sidekick for each pods.

-- Ismail Faruqi
Source: StackOverflow