<p>I am using kube go client with kube api to access kube data. I am currently not finding any api call for logs of a particular pod.</p>

<pre><code>kubectl logs pod-name
</code></pre>

<p>returns the logs for a particular pod. How do I do this using go client? 
I am using v1.0.6 of kubernetes.</p>

<p>I can get the pod by using</p>

<pre><code>client.Pods("namespace").Get("pod-name")
</code></pre>

<p><a href="https://pkg.go.dev/k8s.io/client-go@v0.20.2/kubernetes/typed/core/v1#PodExpansion" rel="nofollow noreferrer">Client Go</a> has offered a function <code>GetLogs</code> for this, which has been answered in <a href="https://stackoverflow.com/questions/53852530/how-to-get-logs-from-kubernetes-using-golang/53870271#53870271">How to get logs from kubernetes using Go?</a></p>
<hr />
<p>Looking at how kubectl implements its commands can be helpful when getting a feel for how to use the client library. In this case, <a href="https://github.com/kubernetes/kubernetes/blob/c2e90cd1549dff87db7941544ce15f4c8ad0ba4c/pkg/kubectl/cmd/log.go#L188" rel="nofollow noreferrer">kubectl's implementation of the logs command</a> looks like this:</p>
<pre class="lang-golang prettyprint-override"><code>    req := client.RESTClient.Get().
        Namespace(namespace).
        Name(podID).
        Resource(&quot;pods&quot;).
        SubResource(&quot;log&quot;).
        Param(&quot;follow&quot;, strconv.FormatBool(logOptions.Follow)).
        Param(&quot;container&quot;, logOptions.Container).
        Param(&quot;previous&quot;, strconv.FormatBool(logOptions.Previous)).
        Param(&quot;timestamps&quot;, strconv.FormatBool(logOptions.Timestamps))

    if logOptions.SinceSeconds != nil {
        req.Param(&quot;sinceSeconds&quot;, strconv.FormatInt(*logOptions.SinceSeconds, 10))
    }
    if logOptions.SinceTime != nil {
        req.Param(&quot;sinceTime&quot;, logOptions.SinceTime.Format(time.RFC3339))
    }
    if logOptions.LimitBytes != nil {
        req.Param(&quot;limitBytes&quot;, strconv.FormatInt(*logOptions.LimitBytes, 10))
    }
    if logOptions.TailLines != nil {
        req.Param(&quot;tailLines&quot;, strconv.FormatInt(*logOptions.TailLines, 10))
    }
    readCloser, err := req.Stream()
    if err != nil {
        return err
    }

    defer readCloser.Close()
    _, err = io.Copy(out, readCloser)
    return err
</code></pre>
