Kubernetes Deep Dive Room

Sign Up Free or Log In to participate!

Multiple containers in a single pod

Why would someone want to deploy multiple containers within a single pod? I’m assuming if each container was a seperate service you would want different pods in order to scale and manage them effectively, does anyone have an example of more than 1 container in a pod?

2 Answers

The sidecar pattern is pretty common in Kubernetes. The application container is joined by supporting containers in the same pod. Examples would be a logging container (eg fluentd) or secrets retriever (eg consul-template connecting to HashiCorp Vault). You could also have init containers that are run inside the pod setting something up before the main container (application) is run.

Rob Wilkinson

ahhhh, totally! I remember this idea from working with Rancher (pre-k8s) but I didnt realize that was the major use. Is there a way to template out so you can have the same standard "stack" of sidekick containers added to every pod?


There are seceral possible ways. If you are just using yaml files for deployment, you could just have a standard template that includes them. If you are using a deployment mechanism (eg Jenkins), you could add them as part of a pipeline. Or you could use a mutating addmission controller to add them. Possibly even helm charts.

In addition to DanW comments above, sometimes you would need to deploy modules of application which require the same network infra and host because of various reasons/excuses. That too sometimes drives this kind of deployment

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?