<p>Creating a pod deployment first   </p>

<pre><code>if pod, err = clientset.CoreV1().Pods(namespace).Create(&amp;v1.Pod{
        TypeMeta: metav1.TypeMeta{
            Kind:       "Deployment",
            APIVersion: "apps/v1",
        },
        ObjectMeta: metav1.ObjectMeta{
            Name:      "mithu",
            Namespace: namespace,
        },
        Spec: v1.PodSpec{
            Containers: []v1.Container{
                v1.Container{
                    Name:            "mithu",
                    Image:           "test-app",
                    ImagePullPolicy: "IfNotPresent",
                    Ports: []v1.ContainerPort{
                        v1.ContainerPort{
                            Name:          "local",
                            HostPort:      8081,
                            ContainerPort: 8081,
                            Protocol:      v1.ProtocolTCP,
                        },
                    },
                    Env: []v1.EnvVar{
                        v1.EnvVar{
                            Name:  "ASD",
                            Value: "",
                        },
                    },
                },
            },
            RestartPolicy: v1.RestartPolicyOnFailure,
        },
}); err == nil {
    fmt.Println("Pod created succesfuly with status", pod.Name)
} else {
    fmt.Println("Error1: ", err)
}

time.Sleep(5000)
</code></pre>

<p>Now the pod has been deployed, I am now reading the logs</p>

<pre><code>req := clientset.RESTClient().Get().
    Namespace(namespace).
    Name(pod.Name).
    Resource("pods").
    SubResource("log").
    Param("follow", "").
    Param("container", "").
    Param("previous", "").
    Param("timestamps", "")

readCloser, err := req.Stream()
if err != nil {
    fmt.Println("Error2: ", err)
} else {
    buf := new(bytes.Buffer)
    _, err = io.Copy(buf, readCloser)
    fmt.Println("log : ", buf.String())
}
</code></pre>

<p>Followed reading of logs from <a href="https://stackoverflow.com/questions/32983228/kubernetes-go-client-api-for-log-of-a-particular-pod">here</a>
Pod is being created successfully but the client cant seem to find the resources getting the error as <code>Error2:  the server could not find the requested resource (get pods.meta.k8s.io mithu)</code></p>

<p>If I try to get logs from command line, there is no problems. I think the major issue is between pods.meta.k8s.io and the command line args pods</p>

<p>This worked for me:</p>

<pre><code>req := clientset.CoreV1().Pods(namespace).GetLogs(
    pod.Name, 
    &amp;v1.PodLogOptions{},
)

readCloser, err := req.Stream()
if err != nil {
        fmt.Println("Error2: ", err)
} else {
        buf := new(bytes.Buffer)
        _, err = io.Copy(buf, readCloser)
        fmt.Println("log : ", buf.String())
}
</code></pre>
