How to delete pod from Kubernetes cluster using kubectl proxy

12/8/2018

I have this code that can get a list of pod running on the cluster by using kubectl proxy and the http endpoint request, I tried to look for a method that can delete a Pod from the cluster using the same way "http endpoint request", but I did not find how I can do that.

v := url.Values{}

v.Add("fieldSelector", "status.phase=Running")

request := &http.Request{
    Header: make(http.Header),
    Method: http.MethodGet,
    URL: &url.URL{
        Host:     apiHost,
        Path:     podsEndpoint,
        RawQuery: v.Encode(),
        Scheme:   "http",
    },
}
request.Header.Set("Accept", "application/json, */*")

resp, err := http.DefaultClient.Do(request)
if err != nil {
    return nil, err
}
err = json.NewDecoder(resp.Body).Decode(&PodRunningList)
if err != nil {
    return nil, err
}
-- Gofrane Gohg
go
http
kubectl
kubernetes

0 Answers