Merge pull request #2377 from erikwilson/no-proxy-fix

Use no_proxy env, add .svc and cluster domains
pull/2384/head
Erik Wilson 2020-10-12 13:46:22 -07:00 committed by GitHub
commit 6b11d86037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -387,12 +387,20 @@ func writeToken(token, file, certs string) error {
} }
func setNoProxyEnv(config *config.Control) error { func setNoProxyEnv(config *config.Control) error {
envList := strings.Join([]string{ splitter := func(c rune) bool {
os.Getenv("NO_PROXY"), return c == ','
}
envList := []string{}
envList = append(envList, strings.FieldsFunc(os.Getenv("NO_PROXY"), splitter)...)
envList = append(envList, strings.FieldsFunc(os.Getenv("no_proxy"), splitter)...)
envList = append(envList,
".svc",
"."+config.ClusterDomain,
config.ClusterIPRange.String(), config.ClusterIPRange.String(),
config.ServiceIPRange.String(), config.ServiceIPRange.String(),
}, ",") )
return os.Setenv("NO_PROXY", envList) os.Unsetenv("no_proxy")
return os.Setenv("NO_PROXY", strings.Join(envList, ","))
} }
func writeConfigSymlink(kubeconfig, kubeconfigSymlink string) error { func writeConfigSymlink(kubeconfig, kubeconfigSymlink string) error {