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

Correct Kubernetes Ingress and IngressRoute port heuristic for choosing HTTPS #5167

Merged
merged 2 commits into from Aug 14, 2019

Conversation

seh
Copy link
Contributor

@seh seh commented Jul 30, 2019

What does this PR do?

When applying the port value heuristic to decide whether to contact a Kubernetes Service's Endpoints using HTTP or HTTPS, inspect the Service's front-end port instead of the upstream servers' port values. That is, for example, when Traefik services an Ingress or IngressRoute object pointing at a Service that forwards from port 443 to servers listening on port 8443, it should use HTTPS.

Motivation

Fixes #5164 (though not yet honoring the "ingress.kubernetes.io/protocol" annotation yet like in Traefik version 1.7)

More

  • Added/updated tests
  • Added/updated documentation

Additional Notes

Should we include the "ingress.kubernetes.io/protocol" annotation here? At present, this patch addresses only the Service port value.

@dtomcej
Copy link
Contributor

dtomcej commented Jul 30, 2019

This PR exposes how the new providers do not support multiport services.

😢

@seh
Copy link
Contributor Author

seh commented Jul 30, 2019

I hadn’t thought of that, coming at it with a narrow focus on repair. Should we confront that gap here?

@dtomcej
Copy link
Contributor

dtomcej commented Jul 30, 2019

Going to discuss with the team tomorrow. May require a refactor.

@seh
Copy link
Contributor Author

seh commented Jul 31, 2019

While we do collect only one port per reference to a Service, an an IngressRoute can define multiple Routes, each of which can point at any number of Services. Even though each reference includes only one port of the Service, it looks like it's still possible, though, to include multiple references to the same Service, each referring to a different port.

Studying this code again, it's surprising that we watch all of these object kinds, but if any one of them changes, we reload the universe by making requests of the Kubernetes API server. If instead we used Informers, we'd have an in-memory cache of these objects, and could react more specifically to what changed. For instance, if an IngressRoute changes, you don't have to reload every other IngressRoute too. If an Endpoints changes, you have to work backwards through the dependency graph to figure out whether any Services of the same name exist and are referenced by any existing IngressRoutes, and, if so, only update those.

@dduportal dduportal added status/1-needs-design-review priority/P2 need to be fixed in the future and removed status/0-needs-triage priority/P2 need to be fixed in the future labels Jul 31, 2019
@ldez ldez added the kind/enhancement a new or improved feature. label Aug 1, 2019
@dtomcej
Copy link
Contributor

dtomcej commented Aug 1, 2019

@seh,

Discussed with the team, and we feel that it is acceptable to proceed with this PR as it is now.

We will work on the multi-port issue in a future PR.

Copy link
Contributor

@dtomcej dtomcej left a comment

Choose a reason for hiding this comment

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

LGTM
:shipit:

@seh
Copy link
Contributor Author

seh commented Aug 1, 2019

Thank you. I'd like to hear more detail about the multi-port concern, as my cursory reading per my comment above saw that we do accommodate Services with more than one port. Perhaps you're referring to a different meaning of "service" here.

Is it worth filing an issue suggesting those improvements to the controller reconciliation procedure, watching and reacting to more fine-grained changes in the object graph?

@dtomcej
Copy link
Contributor

dtomcej commented Aug 1, 2019

You can definitely file an issue, but currently providers are stateless. To maintain an object dependency graph, the state would need to be passed between iterations of the provider cycle, and potentially shared with the core server to persist with provider restarts.

May be worth examining, but Traefik does not operate as a controller, but as a watcher. The informers are registered to trigger a configuration reload, but each reload is atomic, so there is no inconsistencies to manage, and no "broken states".

@seh
Copy link
Contributor Author

seh commented Aug 8, 2019

Is there something else to be done here? We’d like to take advantage of this fix in the next container image release.

@ldez
Copy link
Member

ldez commented Aug 9, 2019

@seh
Copy link
Contributor Author

seh commented Aug 12, 2019

I read that document several times, and the most sense I can make of it is that we need two more maintainers to approve this patch, given that @dtomcej already gave it the nod. If there are daily meetings to discuss open requests, can you tell me whether this one has come up for discussion?

@dduportal
Copy link
Contributor

Hi @seh , the daily meeting is for triaging. The review work on the PRs heavily depends on the maintainer availability. With the context here (assumption's week, summer's week), it's not realistic to commit on a deadline.

We hear your concern and we try our best, but right now there is nothing else outside waiting, as rushing a review is never a good idea.

Thanks for this contribution and for the help proposal, it's always really appreciated!

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@ldez
Copy link
Member

ldez commented Aug 13, 2019

FYI We don't know who is @reddy-s but it's not a maintainer so his approval does not count.

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

LGTM

@ldez
Copy link
Member

ldez commented Aug 14, 2019

The error is not related to the PR, I will fix that.
Fixed by #5207

Steve Harris added 2 commits August 14, 2019 18:23
Induce the current unit test to fail, not producing the intended
result.
When applying the port value heuristic to decide whether to contact a
Kubernetes Service's Endpoints using HTTP or HTTPS, inspect the
Service's front-end port instead of the upstream servers' port
values. That is, for example, when Traefik services an Ingress or
IngressRoute object pointing at a Service that forwards from port 443
to servers listening on port 8443, it should use HTTPS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants