// getContainerInfo contacts kubelet for the container informaton. The "Stats" // in the returned ContainerInfo is subject to the requirements in statsRequest. func getContainerInfo(c *client.Client, nodeName string, req *kubelet.StatsRequest) (map[string]cadvisor.ContainerInfo, error) { reqBody, err := json.Marshal(req) if err != nil { return nil, err } data, err := c.Post(). Prefix("proxy"). Resource("nodes"). Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)). Suffix("stats/container"). SetHeader("Content-Type", "application/json"). Body(reqBody). Do().Raw() var containers map[string]cadvisor.ContainerInfo err = json.Unmarshal(data, &containers) if err != nil { return nil, err } return containers, nil }
Output string `json:"output"` Error string `json:"error"` } var uploadConfigOutput NetexecOutput // Upload the kubeconfig file By("uploading kubeconfig to netexec") pipeConfigReader, postConfigBodyWriter, err := newStreamingUpload(kubeConfigFilePath) if err != nil { Failf("unable to create streaming upload. Error: %s", err) } resp, err := c.Post(). Prefix("proxy"). Namespace(ns). Name("netexec"). Resource("pods"). Suffix("upload"). SetHeader("Content-Type", postConfigBodyWriter.FormDataContentType()). Body(pipeConfigReader). Do().Raw() if err != nil { Failf("Unable to upload kubeconfig to the remote exec server due to error: %s", err) } if err := json.Unmarshal(resp, &uploadConfigOutput); err != nil { Failf("Unable to read the result from the netexec server. Error: %s", err) } kubecConfigRemotePath := uploadConfigOutput.Output // Upload pipeReader, postBodyWriter, err := newStreamingUpload(testStaticKubectlPath)