<ul>
<li>I need to see the logs of all the pods in a deployment with N worker pods</li>
<li>When I do <code>kubectl logs deployment/name --tail=0 --follow</code> the command syntax makes me assume that it will tail all pods in the deployment</li>
<li>However when I go to process I don't see any output as expected until I manually view the logs for all N pods in the deployment</li>
</ul>
<h3>Does <code>kubectl log deployment/name</code> get all pods or just one pod?</h3>

Trevor Boyd Smith
<p>Yes, if you run <code>kubectl logs</code> with a deployment, it will return the logs of only one pod from the deployment.</p>
<p>However, you can accomplish what you are trying to achieve by using the <code>-l</code> flag to return the logs of all pods matching a label.</p>
<p>For example, let's say you create a deployment using:</p>
<pre><code>kubectl create deployment my-dep --image=nginx --replicas=3
</code></pre>
<p>Each of the pods gets a label <code>app=my-dep</code>, as seen here:</p>
<pre><code>$ kubectl get pods -l app=my-dep
NAME                      READY   STATUS    RESTARTS   AGE
my-dep-6d4ddbf4f7-8jnsw   1/1     Running   0          6m36s
my-dep-6d4ddbf4f7-9jd7g   1/1     Running   0          6m36s
my-dep-6d4ddbf4f7-pqx2w   1/1     Running   0          6m36s
</code></pre>
<p>So, if you want to get the combined logs of all pods in this deployment you can use this command:</p>
<pre><code>kubectl logs -l app=my-dep
</code></pre>
