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

Proxy: handle lower case proxy env vars #4602

Merged
merged 1 commit into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) {
if !cmd.Flags().Changed("docker-env") {
for _, k := range proxy.EnvVars {
if v := os.Getenv(k); v != "" {
// convert https_proxy to HTTPS_PROXY for linux
// TODO (@medyagh): if user has both http_proxy & HTTPS_PROXY set merge them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea on merge, you mean just take one's precedence over the other one ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ! thanks for correcting me, I meant that for no_proxy and NO_PROXY, if there are both merge them into one bigger NO_PROXY. good catch !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, and also, would you mind me to REGISTRY_MIRROR env to EnvVars in the same file (proxy.go) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried to use viper to load MINIKUBE_REGISTRY_MIRROR env

see PR #4607

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with REGISTRY_MIRROR env var. the purpose of this PR is to plumb the standard networking env vars. (the ones that operating systems use to change their proxies). does REGISTRY_MIRROR env var change the behaviour of OS ? or is it minikube specific en var ?

if it is minikube specific that would be for a different PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a second thought, is that env var a standard docker env var that everyone uses to set their registery mirror ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also have another in progress PR by by @tstromberg https://github.com/kubernetes/minikube/pull/3835/files

I think we can address the registry mirror in a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@medyagh REGISTRY_MIRROR is docker env var, it's important for users to pull images faster in China, no need to change here, i've send a PR, see #4607

k = strings.ToUpper(k)
dockerEnv = append(dockerEnv, fmt.Sprintf("%s=%s", k, v))
}
}
Expand Down Expand Up @@ -604,6 +607,7 @@ func validateNetwork(h *host.Host) string {
}
console.OutStyle(console.Option, "%s=%s", k, v)
ipExcluded := proxy.IsIPExcluded(ip) // Skip warning if minikube ip is already in NO_PROXY
k = strings.ToUpper(k) // for http_proxy & https_proxy
if (k == "HTTP_PROXY" || k == "HTTPS_PROXY") && !ipExcluded && !warnedOnce {
console.Warning("You appear to be using a proxy, but your NO_PROXY environment does not include the minikube IP (%s). Please see https://github.com/kubernetes/minikube/blob/master/docs/http_proxy.md for more details", ip)
warnedOnce = true
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

// EnvVars are variables we plumb through to the underlying container runtime
var EnvVars = []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
var EnvVars = []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", "http_proxy", "https_proxy", "no_proxy"}

// isInBlock checks if ip is a CIDR block
func isInBlock(ip string, block string) (bool, error) {
Expand Down