From 56e077eb292a9a1f77de6d6fa34a936d7165ca0a Mon Sep 17 00:00:00 2001 From: Erik Wilson Date: Mon, 12 Oct 2020 11:02:07 -0700 Subject: [PATCH] Use no_proxy env, add .svc and cluster domains --- pkg/server/server.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index 92c5836200..6909cb7da7 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -387,12 +387,20 @@ func writeToken(token, file, certs string) error { } func setNoProxyEnv(config *config.Control) error { - envList := strings.Join([]string{ - os.Getenv("NO_PROXY"), + splitter := func(c rune) bool { + 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.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 {