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

Ensure kubeadm doesn't use proxy #7275

Merged
merged 2 commits into from
Feb 16, 2021

Conversation

champtar
Copy link
Contributor

@champtar champtar commented Feb 9, 2021

*_proxy variables might be present in the environment (/etc/environment, bash profile, ...)
When this is the case we end up with those proxy configuration in /etc/kubernetes/manifests/kube-*.yaml manifests

We cannot unset env variables, but kubeadm is nice enough to ignore empty vars
https://github.com/kubernetes/kubernetes/blob/93d288e2a47fa6d497b50d37c8b3a04e91da4228/cmd/kubeadm/app/util/env.go#L27

What type of PR is this?
/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #6250

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fix issue when *_PROXY variables are present in the environment

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 9, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @champtar. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 9, 2021
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 9, 2021
@floryut
Copy link
Member

floryut commented Feb 10, 2021

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 10, 2021
@michalskalski
Copy link
Contributor

Shouldn't playbooks configure proper no_proxy on environment which would be inherited by kubeadm? For installation maybe that is ok to ignore proxy settings but for later use things like local kubectl shouldn't probably use proxy too.

@champtar
Copy link
Contributor Author

Shouldn't playbooks configure proper no_proxy on environment which would be inherited by kubeadm? For installation maybe that is ok to ignore proxy settings but for later use things like local kubectl shouldn't probably use proxy too.

Problem is there are many ways to configure proxy on a system, this could be an option to put the computed values in /etc/environment, but for sure kubeadm should not have proxy set as it leads to issues. I can add this proxy_disable_env to all kubectl / calicoctl calls in this PR or in a follow up PR.

@champtar
Copy link
Contributor Author

I can add this proxy_disable_env to all kubectl / calicoctl calls in this PR or in a follow up PR.
or not

$ git grep '/kubectl ' | wc -l
153
$ git grep 'kube:' | wc -l
76

@michalskalski
Copy link
Contributor

Actually I thought more about situation after deployment, in environment with http proxy there will be environment variables exported for example with /etc/environment. If no_proxy variable will not be extended with k8s addresses then kubectl may try connect through proxy which probably will not be desired behavior. Even for installation, if playbook would set no_proxy variable in /etc/environment with values which are already calculated then that could be inherited by commands executed later.

@champtar
Copy link
Contributor Author

Proxies are a mess :(
Setting the values computed by kubespray in /etc/environment might not be 100% reliable (see #6250, some people are using profile.d) so I'm trying to think a bit more about it.

There is no reasons to use set_facts here

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
*_proxy variables might be present in the environment (/etc/environment, bash profile, ...)
When this is the case we end up with those proxy configuration in /etc/kubernetes/manifests/kube-*.yaml manifests

We cannot unset env variables, but kubeadm is nice enough to ignore empty vars
https://github.com/kubernetes/kubernetes/blob/93d288e2a47fa6d497b50d37c8b3a04e91da4228/cmd/kubeadm/app/util/env.go#L27

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
@floryut
Copy link
Member

floryut commented Feb 16, 2021

/cc @EppO
/cc @oomichi

Copy link
Contributor

@oomichi oomichi left a comment

Choose a reason for hiding this comment

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

Nice work.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 16, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: champtar, floryut

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 16, 2021
@k8s-ci-robot k8s-ci-robot merged commit 1c5391d into kubernetes-sigs:master Feb 16, 2021
@champtar champtar deleted the kubeadm-proxy branch February 17, 2021 21:03
champtar added a commit to champtar/kubespray that referenced this pull request Feb 17, 2021
* Move proxy_env to kubespray-defaults/defaults

There is no reasons to use set_facts here

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>

* Ensure kubeadm doesn't use proxy

*_proxy variables might be present in the environment (/etc/environment, bash profile, ...)
When this is the case we end up with those proxy configuration in /etc/kubernetes/manifests/kube-*.yaml manifests

We cannot unset env variables, but kubeadm is nice enough to ignore empty vars
https://github.com/kubernetes/kubernetes/blob/93d288e2a47fa6d497b50d37c8b3a04e91da4228/cmd/kubeadm/app/util/env.go#L27

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
(cherry picked from commit 1c5391d)
k8s-ci-robot pushed a commit that referenced this pull request Feb 22, 2021
* Move proxy_env to kubespray-defaults/defaults

There is no reasons to use set_facts here

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>

* Ensure kubeadm doesn't use proxy

*_proxy variables might be present in the environment (/etc/environment, bash profile, ...)
When this is the case we end up with those proxy configuration in /etc/kubernetes/manifests/kube-*.yaml manifests

We cannot unset env variables, but kubeadm is nice enough to ignore empty vars
https://github.com/kubernetes/kubernetes/blob/93d288e2a47fa6d497b50d37c8b3a04e91da4228/cmd/kubeadm/app/util/env.go#L27

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
(cherry picked from commit 1c5391d)
LuckySB pushed a commit to southbridgeio/kubespray that referenced this pull request Apr 6, 2021
* Move proxy_env to kubespray-defaults/defaults

There is no reasons to use set_facts here

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>

* Ensure kubeadm doesn't use proxy

*_proxy variables might be present in the environment (/etc/environment, bash profile, ...)
When this is the case we end up with those proxy configuration in /etc/kubernetes/manifests/kube-*.yaml manifests

We cannot unset env variables, but kubeadm is nice enough to ignore empty vars
https://github.com/kubernetes/kubernetes/blob/93d288e2a47fa6d497b50d37c8b3a04e91da4228/cmd/kubeadm/app/util/env.go#L27

Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
@floryut floryut mentioned this pull request May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubeadm injects broken no_proxy environment variables into /etc/kubernetes/manifests/kube-*.yaml
5 participants