Skip to content

kubeadm: pod-cidr, service-cidr should not go through any proxy#58698

Closed
dixudx wants to merge 1 commit into
kubernetes:masterfrom
dixudx:kubeadm_no_proxy
Closed

kubeadm: pod-cidr, service-cidr should not go through any proxy#58698
dixudx wants to merge 1 commit into
kubernetes:masterfrom
dixudx:kubeadm_no_proxy

Conversation

@dixudx

@dixudx dixudx commented Jan 23, 2018

Copy link
Copy Markdown
Member

What this PR does / why we need it:
kubeadm passes proxy variables to static pods during init stage by #37494. But all the pods and service ips in pod-cidr, service-cidr should not go through any proxy.

This PR fixes this issue.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes kubernetes/kubeadm#666

Special notes for your reviewer:
/assign @luxas
/cc @kubernetes/sig-cluster-lifecycle-pr-reviews
/area kubeadm

Release note:

kubeadm: pod-cidr, service-cidr should not go through any proxy. Bypassing proxies for intra-cluster communication.

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jan 23, 2018
@k8s-ci-robot k8s-ci-robot added sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. area/kubeadm size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 23, 2018
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 23, 2018

@jamiehannaford jamiehannaford left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for fixing this, just one minor nit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you could also continue if name == no_proxy and set the env in 1 place rather than 2. WDYT? not a big issue IMO

@kad

kad commented Jan 23, 2018

Copy link
Copy Markdown
Member

First of all, kubeadm produce warnings if connections to any used CIDRs will end-up via proxy.
Altering or ignoring user set environments some time ago was considered as not appropriate solution, as in some corner cases it might be needed by cluster administrator.

As for PR itself, it handles only IPv4 addresses, that is not acceptable, as since 1.9.x release kubernetes can be both IPv4 and IPv6.

/assign kad

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

kubeadm must be able to handle both IPv4 and IPv6.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@kad Thanks for reminding. This function works both for IPv4 and IPv6. Locally tested.

@errordeveloper

Copy link
Copy Markdown
Contributor

The release note is not very clear at all. This is about bypassing proxies for intra-cluster communication, right? If so, please say something like that, so that it makes sense to end-users. To be honest it took me a while to get what it is about exactly. Also, as far as I am aware, the communication of all control plane components should not even leave the network, accept for fetching images from a public registry, or check version (like kubeadm and weave net do), so I am not entirely sure why we have it set everywhere in the first place...

@kad

kad commented Jan 23, 2018

Copy link
Copy Markdown
Member

@errordeveloper It is related to issues #36573 kubernetes/kubeadm#5

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dixudx
We suggest the following additional approver: luxas

Assign the PR to them by writing /assign @luxas in a comment when ready.

Associated issue: #37494

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@dixudx

dixudx commented Jan 24, 2018

Copy link
Copy Markdown
Member Author

@kad @jamiehannaford Updated. PTAL. Thanks.

@dixudx

dixudx commented Jan 24, 2018

Copy link
Copy Markdown
Member Author

Also, as far as I am aware, the communication of all control plane components should not even leave the network, accept for fetching images from a public registry, or check version (like kubeadm and weave net do), so I am not entirely sure why we have it set everywhere in the first place...

@kad Related to issue kubernetes/kubeadm#666 as well.

@dixudx

dixudx commented Jan 24, 2018

Copy link
Copy Markdown
Member Author

/retest

@dixudx

dixudx commented Jan 24, 2018

Copy link
Copy Markdown
Member Author

/retest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could be a really long list if you have a large CIDR block. Isn't there a limit on how long an environment variable can be (less than 32k)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is limit. And transport connections supports CIDR notation of subnets in no_proxy.
There is no need to expand them at all.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@kad AFAIK, golang does not support no_proxy with CIDR notation of subnet.
Here is an on-going issue golang/go#16704 on this.

Isn't there a limit on how long an environment variable can be (less than 32k)
There is limit.

Yeah. https://www.in-ulm.de/~mascheck/various/argmax/ lists Actual values for ARG_MAX. This is a risk when setting environments.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That is exactly the reason why I consider that patch is incorrect:

  1. kubeadm and other kubernetes components are utilizing modified http transport which supports CIDR notations.
  2. kubeadm gives warnings during init stage if access to any IP address in pod or service CIDRs will be going via proxies, according to values of *_proxy variables.
  3. If system admin require traffic to be going via proxies, he is able to ignore warning.
  4. if system admin wants to have traffic going directly = values of environment variables before running kubeadm should be including pod and service cidrs.
  5. with current idea of the patch behaviour becomes inconsistent: kubeadm will produce warning, but anyway will alter variables put into manifests. That is less predictable for sysadmins and will cause more issues.
  6. trying to expand IPv6 pod/service cidrs will lead to OOM-kill of kubeadm.

So, to summarise: if in issue kubernetes/kubeadm#666 warning was correctly shown to user of kubeadm but was ignored by user, we don't need this PR at all. If for some reason warning was not shown, we need to investigate more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@kad Thanks for the explanation.

And transport connections supports CIDR notation of subnets in no_proxy.
There is no need to expand them at all.

I did found the link

// http.ProxyFromEnvironment doesn't respect CIDRs and that makes it impossible to exclude things like pod and service IPs from proxy settings
// ProxierWithNoProxyCIDR allows CIDR rules in NO_PROXY
t.Proxy = NewProxierWithNoProxyCIDR(http.ProxyFromEnvironment)
.

Will update it.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 26, 2018
@dixudx

dixudx commented Jan 26, 2018

Copy link
Copy Markdown
Member Author

ping @jamiehannaford @roberthbailey @kad Updated. PTAL. Thanks.

@dixudx

dixudx commented Jan 26, 2018

Copy link
Copy Markdown
Member Author

/retest

@kad

kad commented Jan 26, 2018

Copy link
Copy Markdown
Member

I think that it is better to have consistent behavior, and this PR is not needed. Unless we get more information from kubernetes/kubeadm#666, I'd prefer to handle proxy settings as it was agreed in #35044: we have pre-flight checks and they are providing warnings to sysadmins. Sysadmins have choice which way is better for their particular setup.

@errordeveloper

errordeveloper commented Feb 1, 2018 via email

Copy link
Copy Markdown
Contributor

@dixudx

dixudx commented Feb 2, 2018

Copy link
Copy Markdown
Member Author

we have pre-flight checks and they are providing warnings to sysadmins. Sysadmins have choice which way is better for their particular setup.

Right. But most people would just ignore those warnings.

@kad

kad commented Feb 2, 2018

Copy link
Copy Markdown
Member

We can make them as errors in theory. With fine-grained error skipping, that can be an option for those who has legitimate cases to use transport calls via proxies. Not a nice solution, but at least predictable and explicit.

@k8s-github-robot

Copy link
Copy Markdown

@dixudx PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 12, 2018
@kad

kad commented Feb 13, 2018

Copy link
Copy Markdown
Member

Let's close this PR. If we consider that proxy checks must become errors, it can be done in separate PR.

/close

@errordeveloper

errordeveloper commented Feb 13, 2018 via email

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy environment variables shouldn't be passed to apiserver

8 participants