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

internal: Adds support for TLSRoute #3627

Merged
merged 3 commits into from
May 19, 2021

Conversation

stevesloka
Copy link
Member

Add support for TLSRoute to enable Passthrough TCP Proxying to pods via SNI.

Note: This is currently rebased from #3620 which makes the Status bits more generic. Merging that first will make this PR smaller.

Updates #3440

Signed-off-by: Steve Sloka slokas@vmware.com

@stevesloka stevesloka added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Apr 30, 2021
@stevesloka stevesloka added this to the 1.16.0 milestone Apr 30, 2021
@stevesloka stevesloka requested a review from a team as a code owner April 30, 2021 16:25
@stevesloka stevesloka requested review from sunjayBhatia and youngnick and removed request for a team April 30, 2021 16:25
@codecov
Copy link

codecov bot commented Apr 30, 2021

Codecov Report

Merging #3627 (ad166f2) into main (dee6631) will decrease coverage by 0.05%.
The diff coverage is 79.56%.

❗ Current head ad166f2 differs from pull request most recent head 5feeee6. Consider uploading reports for the commit 5feeee6 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3627      +/-   ##
==========================================
- Coverage   76.18%   76.13%   -0.06%     
==========================================
  Files         103      103              
  Lines        7117     7185      +68     
==========================================
+ Hits         5422     5470      +48     
- Misses       1578     1596      +18     
- Partials      117      119       +2     
Impacted Files Coverage Δ
internal/dag/cache.go 95.43% <ø> (-0.05%) ⬇️
internal/status/conditions.go 31.88% <0.00%> (-3.60%) ⬇️
internal/dag/gatewayapi_processor.go 93.52% <94.66%> (-0.37%) ⬇️
internal/envoy/v3/listener.go 98.16% <100.00%> (+<0.01%) ⬆️
internal/k8s/log.go 69.56% <0.00%> (-15.29%) ⬇️
internal/dag/httpproxy_processor.go 91.71% <0.00%> (+0.01%) ⬆️

@@ -0,0 +1,187 @@
# Copyright Project Contour Authors
Copy link
Member

Choose a reason for hiding this comment

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

test looks good, should we leave as the original _integration version and conver to new e2e format later?

Copy link
Member

Choose a reason for hiding this comment

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

I can convert this one separately if necessary. PR #3665 adds code for the ingress-conformance-echo-tls fixture which is maybe what was missing for implementing this one in Go? After that merges, though, I'd love to see all new tests written in Go.

internal/dag/gatewayapi_processor.go Show resolved Hide resolved
internal/featuretests/v3/tlsroute_test.go Show resolved Hide resolved
name: tlsroute1
spec:
rules:
- forwardTo:
Copy link
Member

Choose a reason for hiding this comment

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

how does it work if we have both no SNI an SNI together? I think Envoy will choose the most specific so they should be able to coexist

https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchainmatch

For criteria that allow ranges or wildcards, the most specific value in any of the configured filter chains that matches the incoming connection is going to be used (e.g. for SNI www.example.com the most specific match would be www.example.com, then *.example.com, then *.com, then any filter chain without server_names requirements).

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a great point, there probably should be some validation higher up across all the listeners to check that only one wildcard (e.g. '*') can exist for the same port.

Additionally, we need to validate that the same domain isn't used for both TLSRoute as well as an HTTPRoute.

rh, c, done := setup(t)
defer done()

//s1 := &v1.Secret{
Copy link
Member

Choose a reason for hiding this comment

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

the docs mention that a secret is required on TLSRoutes, seems like the integration test and this one have omitted it and not made the TLS secret required?

Copy link
Member

Choose a reason for hiding this comment

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

is this because this just enables passthrough TLS and not terminating and re-encrypting?

Copy link
Member

Choose a reason for hiding this comment

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

what are the rules that we/upstream decided on for supporting TLS passthrough/termination and how they relate to TLSRoute/TCPRoute?

Copy link
Member Author

Choose a reason for hiding this comment

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

There were some discussions upstream (kubernetes-sigs/gateway-api#633 (comment)) and essentially from what I understand, TLSRoute is a passthrough TCPProxy against SNI.

If you want to terminate then route, you'd have to use TCPRoute.

@youngnick said we can't support TCPRoute so this will be a point that differs from HTTPProxy.

  • HTTPProxy.TCPProxy (passthrough: true) == TLSRoute
  • HTTPProxy.TCPProxy (passthrough: false) == TCPRoute

internal/dag/gatewayapi_processor.go Show resolved Hide resolved
@stevesloka stevesloka force-pushed the tlsRoute branch 2 times, most recently from 54e89c0 to e3cf805 Compare May 14, 2021 23:08
Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

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

I think this is all done? I think all my previous comments are resolved

internal/dag/gatewayapi_processor.go Outdated Show resolved Hide resolved
p.Errorf("error validating routes against Listener.Routes.Selector: %s", err)
}

if selMatches && nsMatches {
Copy link
Member

Choose a reason for hiding this comment

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

Is this block of logic that we have for HTTPRoutes not needed for TLSRoutes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup it is to satisfy the API. I think I just didn't add it yet for this PR. Is it easier to merge this with out (assuming the rest is ok), then follow up with a new PR to add that with corresponding tests?

Copy link
Member

Choose a reason for hiding this comment

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

OK with me

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM pending CI

Add support for TLSRoute to enable Passthrough TCP Proxying to pods via SNI.

Updates projectcontour#3440

Signed-off-by: Steve Sloka <slokas@vmware.com>
Signed-off-by: Steve Sloka <slokas@vmware.com>
Signed-off-by: Steve Sloka <slokas@vmware.com>
@stevesloka stevesloka merged commit 72edf8b into projectcontour:main May 19, 2021
@stevesloka stevesloka deleted the tlsRoute branch May 19, 2021 17:24
@skriss skriss mentioned this pull request Jul 30, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants