<p>I have created a job in kubernetes through <strong>client-go</strong> api. Now I want to get the log of the job, but I can't find the log api of job in <strong>client-go</strong>. Therefore, I want to obtain the name of all the pods in a job to obtain the POD logs by name, and then obtain the logs of the job.</p>
<p>So,how to get the name of pod in a job in kubernetes through client-go?</p>
<p>Thanks so much.</p>

Worlder_Mo
<p>I create a pod with label, and then I get it through <strong>LabelSelector</strong>.
Like it :</p>
<pre class="lang-golang prettyprint-override"><code>    config, err := clientcmd.BuildConfigFromFlags(&quot;&quot;, &quot;~/.kube/config&quot;)
    if err != nil {
        println(&quot;config build error&quot;)
    }
    
    client, err := kubernetes.NewForConfig(config)
    
    pods, err := client.CoreV1().Pods(&quot;test&quot;).List(context.TODO(),
        v1.ListOptions{LabelSelector: &quot;name=label_name&quot;})
    
    for _, v := range pods.Items {
        log := client.CoreV1().Pods(&quot;test&quot;).GetLogs(v.Name, &amp;v12.PodLogOptions{})
    }
</code></pre>
