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

Extending the no_proxy env variable to automatically include all the nodes of the cluster #2885

Merged
merged 5 commits into from
Aug 22, 2022

Conversation

wherka-ama
Copy link
Contributor

See: #2884

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 17, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @wherka-ama. 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 the area/provider/docker Issues or PRs related to docker label Aug 17, 2022
@k8s-ci-robot k8s-ci-robot added area/provider/podman Issues or PRs related to podman size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 17, 2022
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 18, 2022
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 18, 2022
…external load balancer and etc roles(as they may be created implicitly) to complete the picture
@wherka-ama
Copy link
Contributor Author

/retest

@k8s-ci-robot
Copy link
Contributor

@wherka-ama: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@wherka-ama
Copy link
Contributor Author

/cc @BenTheElder @aojea
I'm pretty sure the test failure is unrelated to the change. It's worth rerunning it.

@aojea
Copy link
Contributor

aojea commented Aug 19, 2022

/ok-to-test
/retest

@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 Aug 19, 2022
// Note: this is best effort based on the default CoreDNS spec
// https://github.com/kubernetes/dns/blob/master/docs/specification.md
// Any user created pod/service hostnames, namespaces, custom DNS services
// are expected to be no-proxied by the user explicitly.
var clusterNodeNames []string
Copy link
Member

Choose a reason for hiding this comment

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

we should probably just restructure to pass these in or add them to the list at the call site?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking in adding them here

func getProxyEnvs(cfg *config.Cluster, getEnv func(string) string) map[string]string {
envs := make(map[string]string)
for _, name := range []string{HTTPProxy, HTTPSProxy, NOProxy} {
val := getEnv(name)
if val == "" {
val = getEnv(strings.ToLower(name))
}
if val != "" {
envs[name] = val
envs[strings.ToLower(name)] = val
}
}
// Specifically add the cluster subnets to NO_PROXY if we are using a proxy
if len(envs) > 0 {
noProxy := envs[NOProxy]
if noProxy != "" {
noProxy += ","
}
noProxy += cfg.Networking.ServiceSubnet + "," + cfg.Networking.PodSubnet
envs[NOProxy] = noProxy
envs[strings.ToLower(NOProxy)] = noProxy
}
return envs

that will cascade for all the providers

Copy link
Member

Choose a reason for hiding this comment

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

The docker implementation already has this AFAICT, we just need to modify podman to match and drop the docker changes, I think #2885 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's worth moving to common, it's fairly noise to plumb any deeper as we just need to append the names

Copy link
Contributor Author

@wherka-ama wherka-ama Aug 19, 2022

Choose a reason for hiding this comment

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

If we were to match the podman flow with the docker one in that regard I guess the best option to start the restructuring from the planCreation and trickle it down. I'd be happy to do that.

My entrypoint would be:

genericArgs, err := commonArgs(cfg, networkName)

And the reference:

names := make([]string, len(cfg.Nodes))
for i, node := range cfg.Nodes {
name := nodeNamer(string(node.Role)) // name the node
names[i] = name
}
haveLoadbalancer := config.ClusterHasImplicitLoadBalancer(cfg)
if haveLoadbalancer {
names = append(names, nodeNamer(constants.ExternalLoadBalancerNodeRoleValue))
}
// these apply to all container creation
genericArgs, err := commonArgs(cfg.Name, cfg, networkName, names)

@BenTheElder @aojea : are you fine with that direction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just pushed a fresh commit with the refactoring. In short - it's an alignment with what we have for docker in that regards. I must admit I like this version a lot more than the previous one. I hope you don't disagree ;-)

/cc @BenTheElder @aojea

@@ -286,12 +286,22 @@ func getProxyEnv(cfg *config.Cluster, networkName string, nodeNames []string) (m

noProxyList := append(subnets, envs[common.NOProxy])
noProxyList = append(noProxyList, nodeNames...)
Copy link
Member

Choose a reason for hiding this comment

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

aren't we already adding these here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Indeed it looks like we can revert for docker and try to pass the list the same way as it's done here indeed.. I'll do it right away. Thanks!

@wherka-ama wherka-ama changed the title Extending the no_proxy anv variable to automatically include the control plane Extending the no_proxy env variable to automatically include all the nodes of the cluster Aug 21, 2022
@aojea aojea added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Aug 22, 2022
@aojea
Copy link
Contributor

aojea commented Aug 22, 2022

/lgtm
/approve
/label tide/merge-method-squash

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, wherka-ama

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 Aug 22, 2022
@k8s-ci-robot k8s-ci-robot merged commit c6b929b into kubernetes-sigs:main Aug 22, 2022
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. area/provider/docker Issues or PRs related to docker area/provider/podman Issues or PRs related to podman cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants