When to put all containers in a pod and when to deploy them individually?
Let's start from the beginning.

First, I'll answer the original question, the one in the title.

When to put all containers in a pod and when to deploy them individually?

This depends on what your app does. For instance (this is an actual example from the company I work for), for a web application, you may have a pod which runs three containers:


app: the actual app with its code
nginx: serves all the requests
heka: a log service which proxies the logs to wherever you want them


The reason for grouping this three containers within a single pod is simple: a pod assures you the containers run in the same Kubernetes node, this is to have the least possible latency with requests being interchanged along the three containers.

That being said, this is only an example, you could have different and multiple reasons for grouping containers in a pod, but I think this is the most common.

With that being clarified, I follow to the question that you present in the body of your post.

How do you access a single container within a pod?

This is simply using kubectl, I use the command like this:

kubectl exec -it &lt;pod-name&gt; -c=&lt;container-name&gt; -- /bin/bash

Suppose we want to access the nginx container inside our my-app pod; we would type this:

kubectl exec -it my-app -c=nginx -- /bin/bash

If you don't specify the container with the -c flag, it defaults to the first container that is in the Kubernetes yaml (I think). So when you say it was impossible to access a container, you actually did access a container (the default one), because a pod cannot be accessed, it is merely a collection of containers and its configurations.

Hope I've been helpful.