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

feat(kuma-cp) permissive mTLS mode #2579

Merged
merged 8 commits into from
Aug 23, 2021
Merged

feat(kuma-cp) permissive mTLS mode #2579

merged 8 commits into from
Aug 23, 2021

Conversation

lobkovilya
Copy link
Contributor

@lobkovilya lobkovilya commented Aug 16, 2021

Summary

The initial implementation of the permissive mTLS model according to #2550

Full changelog

  • add new mode option for Mesh
  • add e2e tests for STRICT and PERMISSIVE modes
  • update inbound generator

Issues resolved

N/A

Documentation

Testing

  • Unit tests
  • E2E tests
  • Manual testing on Universal
  • Manual testing on Kubernetes

Backwards compatibility

  • Add backport-to-stable label if the code is backwards compatible. Otherwise, list breaking changes.

Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

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

very nice! I'm excited to see this feature.

api/mesh/v1alpha1/mesh.proto Outdated Show resolved Hide resolved
pkg/xds/generator/inbound_proxy_generator.go Outdated Show resolved Hide resolved

getServiceEndpoint := func() string {
var addr string
r := regexp.MustCompile(`::([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}):?([0-9]{1,5})?::`)
Copy link
Contributor

Choose a reason for hiding this comment

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

how about kumactl get dataplanes and get address + port?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, probably it's simpler, but at that moment I don't see the point in rewriting this to kumactl get dataplanes, the same amount of work, still have to parse the output somehow

test/e2e/mtls/standalone_universal.go Outdated Show resolved Hide resolved

checkInsideMeshConnection()

checkNoOutsideMeshConnection()
Copy link
Contributor

Choose a reason for hiding this comment

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

Disclaimer: My opinion, your opinion may vary.

Please try to not overuse functions inside a test. For me, it's easier to read a test with code embedded

// given a mesh
... code that creates a mesh

// and test server
... code that creates test server

than test with functions. To read the full test I need to jump back and forth between test and function implementations.

Of course, if we have reusable functions and repeating the complex operations, it may make sense to use it.

Also, I'd try to keep the given, when, then convention. For me, it makes it easier to read the intention of the test.

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 agree that it was probably too much. I got rid of these checkInsideMeshConnection and checkNoOutsideMeshConnection, but I left the functions that create a mesh and runs client, they are 100 percent reusable across tests in this file

@jakubdyszkiewicz
Copy link
Contributor

#2550 (comment) <- supporting this use case is critical for this functionality.

@lobkovilya lobkovilya marked this pull request as ready for review August 20, 2021 14:28
@lobkovilya lobkovilya requested a review from a team as a code owner August 20, 2021 14:28
@codecov-commenter
Copy link

codecov-commenter commented Aug 20, 2021

Codecov Report

Merging #2579 (b9a9b86) into master (ab55603) will decrease coverage by 0.10%.
The diff coverage is 21.60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2579      +/-   ##
==========================================
- Coverage   52.08%   51.98%   -0.11%     
==========================================
  Files         877      878       +1     
  Lines       49478    49628     +150     
==========================================
+ Hits        25771    25799      +28     
- Misses      21641    21759     +118     
- Partials     2066     2070       +4     
Impacted Files Coverage Δ
pkg/xds/envoy/tls/tls.go 100.00% <ø> (ø)
test/e2e/mtls/standalone_universal.go 0.00% <0.00%> (ø)
test/server/cmd/echo.go 0.00% <0.00%> (ø)
api/mesh/v1alpha1/mesh.pb.go 32.72% <30.00%> (-0.20%) ⬇️
pkg/xds/generator/inbound_proxy_generator.go 74.77% <90.90%> (+2.14%) ⬆️
...kg/xds/envoy/listeners/filter_chain_configurers.go 97.29% <100.00%> (+0.01%) ⬆️
...nvoy/listeners/v3/filter_chain_match_configurer.go 100.00% <100.00%> (ø)
pkg/xds/envoy/tls/v3/tls.go 93.85% <100.00%> (+0.05%) ⬆️
pkg/xds/generator/admin_proxy_generator.go 86.79% <100.00%> (ø)
pkg/xds/generator/ingress_generator.go 85.56% <100.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab55603...b9a9b86. Read the comment docs.

@lobkovilya
Copy link
Contributor Author

I added support of the case when the client and server already have TLS, covered this with a test. I'm going to provide docs on how to migrate your services under the mesh.

Also, this PR probably requires a disclaimer for UPGRADE.md – you can't set PERMISSIVE mode until all Kuma CP instances are updated to the newer version, because ALPN protocol kuma won't be set for proxies connected to the old Kuma CP.

@@ -14,6 +14,7 @@ import (
envoy_names "github.com/kumahq/kuma/pkg/xds/envoy/names"
v3 "github.com/kumahq/kuma/pkg/xds/envoy/routes/v3"
"github.com/kumahq/kuma/pkg/xds/envoy/tags"
xds_tls "github.com/kumahq/kuma/pkg/xds/envoy/tls/v3"
Copy link
Contributor

Choose a reason for hiding this comment

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

we should not import individual Envoy versions in generator. KumaALPNProtocols should be common to all versions. I'd suggest moving KumaALPNProtocols out of pkg/xds/envoy/tls/v3 into pkg/xds/envoy/tls

Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>

# Conflicts:
#	test/server/cmd/echo.go
Signed-off-by: Ilya Lobkov <lobkovilya@yandex.ru>
@lobkovilya lobkovilya merged commit 46d6a19 into master Aug 23, 2021
@lobkovilya lobkovilya deleted the feat/permissive-mtls branch August 23, 2021 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants