Amrit Sarkar
Amrit Sarkar

Reputation: 23

How to pass container name with k8s.io client-go rest API request

How to pass container name information for Kubernetes k8s.io client-go app:

    execReq = client.CoreV1().RESTClient().Post().
        Resource("pods").
        Name(solrPod).
        Namespace(brConfig.solrOptions.Namespace).
        SubResource("exec").
        SubResource("solr").
        VersionedParams(&corev1.PodExecOptions{
            Command: []string{"java", "CorruptFile", "/opt/solr/data"},
            Stdin:   true,
            Stdout:  true,
            Stderr:  true,
        }, scheme.ParameterCodec)

like -

kubectl -n namespace exec pod-name -c container-name.

How to pass the container-name via client-go?

Upvotes: 1

Views: 492

Answers (1)

Rico
Rico

Reputation: 61521

I dug through this for a while šŸ’­. It's an option in your parameters, also here:

execReq = client.CoreV1().RESTClient().Post().
    Resource("pods").
    Name(solrPod).
    Namespace(brConfig.solrOptions.Namespace).
    SubResource("exec").
    SubResource("solr").
    VersionedParams(&corev1.PodExecOptions{
        Command: []string{"java", "CorruptFile", "/opt/solr/data"},
        Container: []string("containername"), šŸ‘ˆ
        Stdin:   true,
        Stdout:  true,
        Stderr:  true,
    }, scheme.ParameterCodec)

āœŒļøā˜®ļø

Upvotes: 1

Related Questions