Skip to content

Commit

Permalink
[fix]: make http client reusable
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Yuan <[email protected]>
  • Loading branch information
SamYuan1990 committed Dec 6, 2024
1 parent 604ba8d commit a8104f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/kubelet/kubelet_pod_lister.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (

var (
podURL string
client http.Client
)

func init() {
Expand All @@ -50,6 +51,8 @@ func init() {
port = "10250"
}
podURL = "https://" + nodeName + ":" + port + "/pods"
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client = http.Client{}
}

func httpGet(url string) (*http.Response, error) {
Expand All @@ -65,8 +68,6 @@ func httpGet(url string) (*http.Response, error) {
return nil, err
}
req.Header.Add("Authorization", bearer)
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to get response from %q: %v", url, err)
Expand Down

0 comments on commit a8104f8

Please sign in to comment.