Skip to content

Commit

Permalink
Ignore proxy settings for kubelet client
Browse files Browse the repository at this point in the history
Proxy settings may interfere with a kubelet client communicating with
the API server, so set the proxy to nil.
  • Loading branch information
erikwilson authored and brandond committed Sep 16, 2021
1 parent 22f3ec2 commit 4759b2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/kube-apiserver/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func Run(completeOptions completedServerRunOptions, stopCh <-chan struct{}) erro
func CreateServerChain(completedOptions completedServerRunOptions, stopCh <-chan struct{}) (*aggregatorapiserver.APIAggregator, error) {
if DefaultProxyDialerFn != nil {
completedOptions.KubeletConfig.Dial = DefaultProxyDialerFn
completedOptions.KubeletConfig.Proxy = http.ProxyURL(nil)
}

kubeAPIServerConfig, serviceResolver, pluginInitializer, err := CreateKubeAPIServerConfig(completedOptions)
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubelet/client/kubelet_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"net/http"
"net/url"
"strconv"
"time"

Expand Down Expand Up @@ -58,6 +59,9 @@ type KubeletClientConfig struct {

// Lookup will give us a dialer if the egress selector is configured for it
Lookup egressselector.Lookup

// Proxy is a custom proxy function for the client
Proxy func(*http.Request) (*url.URL, error)
}

// ConnectionInfo provides the information needed to connect to a kubelet
Expand Down Expand Up @@ -116,6 +120,7 @@ func makeTransport(config *KubeletClientConfig, insecureSkipTLSVerify bool) (htt
rt = utilnet.SetOldTransportDefaults(&http.Transport{
DialContext: dialer,
TLSClientConfig: tlsConfig,
Proxy: config.Proxy,
})
}

Expand Down

0 comments on commit 4759b2b

Please sign in to comment.