Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow minikube to function with misconfigured NO_PROXY value #4229

Merged
merged 28 commits into from
May 20, 2019
Merged
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
581b63a
Fixed API connectivity with http(s) proxy
medyagh May 7, 2019
0529f0b
Added more comment
medyagh May 8, 2019
8bc0010
Fix dashboard behind proxy and refactor
medyagh May 10, 2019
6a433d0
Fixing K8S Client Config with TranportWrap
medyagh May 15, 2019
ddb95e1
return error if nil
medyagh May 15, 2019
8120cdd
No Proxy for Dashboard and moving logic to proxy package
medyagh May 15, 2019
830e18d
Updated warn message and remove duplicate warning
medyagh May 15, 2019
6384a22
Fix naming and improve public functions singatures
medyagh May 15, 2019
6fe614e
Fix stutter between the package name and the function
medyagh May 15, 2019
b9149b1
Better name
medyagh May 15, 2019
e878f9b
Merge remote-tracking branch 'upstream/master' into no_proxy_for_self
medyagh May 15, 2019
1079933
Added integration tests for proxy
medyagh May 15, 2019
a0c6013
Fixed Error handling for http serve
medyagh May 15, 2019
b8501ea
Fix formatting
medyagh May 15, 2019
08d19bf
Improve formatting and messages
medyagh May 15, 2019
53a4625
Return host IP when using vmware as vm driver.
ne0h May 14, 2019
88a1489
Make derivation of Host IP address more generic when using vmware.
ne0h May 15, 2019
a2590ec
Adding more unit test
medyagh May 16, 2019
f38efb9
Improved Style
medyagh May 16, 2019
3ff806a
Added unittest and rebase
medyagh May 16, 2019
a1e34b0
Improve http server shutdown handling
medyagh May 16, 2019
6484548
fix formatting
medyagh May 16, 2019
0d58773
Clean up after unit test
medyagh May 17, 2019
d4cf3b0
Merge remote-tracking branch 'upstream/master' into no_proxy_for_self
medyagh May 17, 2019
42e40e3
Debug
medyagh May 19, 2019
871c2e6
Better clean up after tesdt proxy setup
medyagh May 19, 2019
c428ce5
Fix typo
medyagh May 19, 2019
b6bf1df
Improve test clean up
medyagh May 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ func runStart(cmd *cobra.Command, args []string) {
host, preexisting := startHost(m, config.MachineConfig)

ip := validateNetwork(host)
// Makes minikube node ip to bypass http(s) proxy. since it is local traffic.
updateNoProxy(ip)
medyagh marked this conversation as resolved.
Show resolved Hide resolved
// Save IP to configuration file for subsequent use
config.KubernetesConfig.NodeIP = ip
if err := saveConfig(config); err != nil {
Expand Down Expand Up @@ -514,6 +516,55 @@ func startHost(api libmachine.API, mc cfg.MachineConfig) (*host.Host, bool) {
return host, exists
}

// isInNoProxy checks if ip is included in NO_PROXY env variable.
func isInNoProxy(ip string) (bool, string) {
v := os.Getenv("NO_PROXY")

if v == "" {
return false, ""
}

// Checking for when provided IP doesn't have CIDIR subnet.
// For example 192.168.39.224
if strings.Contains(v, ip) {
return true, v
}

// Checking if the ip is included in the CIDIR subnet ranges
// For example 192.168.39.15/24
noProxyBlocks := strings.Split(v, ",")
for _, b := range noProxyBlocks {
if yes, _ := isInBlock(ip, b); yes {
return true, v
}
}

return false, v
}

// isInBlock checks if ip is a CIDIR block
func isInBlock(ip string, block string) (bool, error) {
medyagh marked this conversation as resolved.
Show resolved Hide resolved
_, b, err := net.ParseCIDR(block)
if err != nil {
return false, err
}
i := net.ParseIP(ip)
if b.Contains(i) {
return false, nil
}
return false, nil
}

// updateNoProxy is used to whitelist minikube's VM ip from going through proxy
// It updates NO_PROXY environment variable, for the current run.
func updateNoProxy(ip string) error {
yes, v := isInNoProxy(ip)
if yes { // skip if already whitelisted
return nil
}
return os.Setenv("NO_PROXY", fmt.Sprintf("%s,%s/32", v, ip))
medyagh marked this conversation as resolved.
Show resolved Hide resolved
}

// validateNetwork tries to catch network problems as soon as possible
func validateNetwork(h *host.Host) string {
ip, err := h.Driver.GetIP()
Expand All @@ -529,6 +580,10 @@ func validateNetwork(h *host.Host) string {
optSeen = true
}
console.OutStyle("option", "%s=%s", k, v)
npSet, _ := isInNoProxy(ip) // Skip warning if already set
if (k == "HTTP_PROXY" || k == "HTTPS_PROXY") && !npSet {
console.Warning("You are using a proxy, You need to add minikube IP to the NO_PROXY. Use `export NO_PROXY=$NO_PROXY,%s/32`", ip)
}
}
}

Expand Down