Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we run a Consul container in every Pod?

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.

like image 568
tex Avatar asked Apr 20 '17 07:04

tex


People also ask

Do we need Consul in Kubernetes?

Syncing Consul services to Kubernetes services enables non-Kubernetes services (such as external to the cluster) to be accessed in a native Kubernetes way: using kube-dns, environment variables, etc. This makes it very easy to automate external service discovery, including hosted services like databases.

Do all containers in a pod run on the same node?

The containers in a Pod share an IP Address and port space, are always co-located and co-scheduled, and run in a shared context on the same Node.

Why is there a Consul in Kubernetes?

Consul and Kubernetes provide a scalable and highly resilient platform for microservices. Consul supports any Kubernetes runtime including hosted solutions like EKS, AKS, GKE, and OpenShift.

Do containers in a pod share memory?

You can run multiple containers within a pod and they get shared memory automatically.


1 Answers

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.

  • Consul: Connect Sidecar; https://www.consul.io/docs/platform/k8s/connect.html
like image 174
tsturzl Avatar answered Oct 05 '22 11:10

tsturzl