【问题标题】:How to pass container name with k8s.io client-go rest API request如何使用 k8s.io client-go rest API 请求传递容器名称
【发布时间】:2020-11-18 15:02:37
【问题描述】:

如何为 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)

喜欢-

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

如何通过client-go传递容器名?

【问题讨论】:

    标签: go kubernetes containers client-go


    【解决方案1】:

    我研究了一段时间?。这是您的parametershere 中的一个选项:

    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)
    

    ✌️☮️

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-25
      • 2015-02-18
      • 2020-01-23
      • 2020-03-29
      • 1970-01-01
      • 1970-01-01
      • 2017-10-01
      • 1970-01-01
      相关资源
      最近更新 更多