<p>How to pass container name information for Kubernetes k8s.io client-go app:</p>
<pre><code>    execReq = client.CoreV1().RESTClient().Post().
        Resource(&quot;pods&quot;).
        Name(solrPod).
        Namespace(brConfig.solrOptions.Namespace).
        SubResource(&quot;exec&quot;).
        SubResource(&quot;solr&quot;).
        VersionedParams(&amp;corev1.PodExecOptions{
            Command: []string{&quot;java&quot;, &quot;CorruptFile&quot;, &quot;/opt/solr/data&quot;},
            Stdin:   true,
            Stdout:  true,
            Stderr:  true,
        }, scheme.ParameterCodec)
</code></pre>
<p>like -</p>
<pre><code>kubectl -n namespace exec pod-name -c container-name.
</code></pre>
<p>How to pass the container-name via client-go?</p>

Amrit Sarkar
<p>I dug through this for a while 💭. It's an option in your <a href="https://docs.openshift.com/container-platform/3.7/rest_api/api/v1.Pod.html#query-parameters-17" rel="nofollow noreferrer">parameters</a>, also <a href="https://godoc.org/k8s.io/api/core/v1#PodExecOptions" rel="nofollow noreferrer">here</a>:</p>
<pre class="lang-golang prettyprint-override"><code>execReq = client.CoreV1().RESTClient().Post().
    Resource(&quot;pods&quot;).
    Name(solrPod).
    Namespace(brConfig.solrOptions.Namespace).
    SubResource(&quot;exec&quot;).
    SubResource(&quot;solr&quot;).
    VersionedParams(&amp;corev1.PodExecOptions{
        Command: []string{&quot;java&quot;, &quot;CorruptFile&quot;, &quot;/opt/solr/data&quot;},
        Container: []string(&quot;containername&quot;), 👈
        Stdin:   true,
        Stdout:  true,
        Stderr:  true,
    }, scheme.ParameterCodec)
</code></pre>
<p>✌️☮️</p>
