<p>I am using <a href="https://github.com/kubernetes/client-go" rel="nofollow noreferrer">kubernetes/client-go</a> to retrieve some pod logs. I am able to retrieve logs should the pod have one container as such</p>

<pre class="lang-golang prettyprint-override"><code>req := client.CoreV1().Pods("namespace").GetLogs("mypod", &amp;corev1.PodLogOptions{})
logs, err := req.Stream()
[...]
</code></pre>

<p>This works well, until I encounter a pod that has <em>more than one container,</em> to which I get the following error</p>

<blockquote>
  <p>a container name must be specified for pod xxx, choose one of: [aaa
  bbb] or one of the init containers: [aaa bbb]</p>
</blockquote>

<p>I was hoping to find an accommodating field on the <a href="https://godoc.org/k8s.io/api/core/v1#PodLogOptions" rel="nofollow noreferrer"><code>corev1.PodLogOptions</code></a> object, but am only finding a specific <code>Container</code> field.</p>

<p>I'm searching for an <code>--all-containers</code> equivalent as offered with the REST client. </p>

<pre class="lang-sh prettyprint-override"><code>$ kubectl logs mypod --all-containers
</code></pre>

<p>Is this possible? Any alternatives?</p>

scniro
<p>If you take a look in <code>kubectl</code> code they just get all relevant containers in a pod and then iterate over them and gather logs container by container. So I don't think there's REST API endpoint that would do that for you.</p>

<p>See here: <a href="https://github.com/kubernetes/kubectl/blob/19fd05792d8c806a5024d6bbbdd7d66d3234cbcb/pkg/polymorphichelpers/logsforobject.go#L86" rel="nofollow noreferrer">https://github.com/kubernetes/kubectl/blob/19fd05792d8c806a5024d6bbbdd7d66d3234cbcb/pkg/polymorphichelpers/logsforobject.go#L86</a> </p>
