Skip to content

Commit

Permalink
Merge pull request #434 from galal-hussein/add_no_proxy
Browse files Browse the repository at this point in the history
Add no_proxy env to server
  • Loading branch information
erikwilson authored May 3, 2019
2 parents 52f845e + f7376ad commit b0e4228
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/helm/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,13 @@ func keys(val map[string]intstr.IntOrString) []string {

func setProxyEnv(job *batch.Job) {
proxySysEnv := []string{
"all_proxy",
"ALL_PROXY",
"http_proxy",
"https_proxy",
"HTTP_PROXY",
"https_proxy",
"HTTPS_PROXY",
"no_proxy",
"NO_PROXY",
}
for _, proxyEnv := range proxySysEnv {
Expand Down
14 changes: 14 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -48,6 +49,10 @@ func StartServer(ctx context.Context, config *Config) (string, error) {
return "", err
}

if err := setNoProxyEnv(&config.ControlConfig); err != nil {
return "", err
}

if err := control.Server(ctx, &config.ControlConfig); err != nil {
return "", errors.Wrap(err, "starting kubernetes")
}
Expand Down Expand Up @@ -293,3 +298,12 @@ func writeToken(token, file, certs string) error {
token = FormatToken(token, certs)
return ioutil.WriteFile(file, []byte(token+"\n"), 0600)
}

func setNoProxyEnv(config *config.Control) error {
envList := strings.Join([]string{
os.Getenv("NO_PROXY"),
config.ClusterIPRange.String(),
config.ServiceIPRange.String(),
}, ",")
return os.Setenv("NO_PROXY", envList)
}

0 comments on commit b0e4228

Please sign in to comment.