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(mTLS): adds mTLS support to dataplane api-server #280

Merged

Conversation

EandrewJones
Copy link
Contributor

@EandrewJones EandrewJones commented Sep 8, 2024

Closes #50.

Questions

I am not sure how best to add tests for this. Unit testing the config trivially tests the behavior of Opt which we know works. Unit testing setup_tls forces me to mock read_to_string in the absence of an actual file to read in and all the ways I've read about doing that in rust feel really kludgie / dirty up the code with dependency injections, etc.

  1. Is this all we need to add mTLS support for the api-server?
  2. Is there some sort of API contract we need to maintain for this such that I can write a conformance or integration test?
  3. What documentation would we like to see for this?

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 8, 2024
@shaneutt shaneutt self-requested a review September 9, 2024 13:00
@shaneutt shaneutt self-assigned this Sep 12, 2024
@aryan9600
Copy link
Member

Unit testing setup_tls forces me to mock read_to_string in the absence of an actual file to read in

how about generating certs during the test, writing them to temp files and then passing those to setup_tls?

  1. Is this all we need to add mTLS support for the api-server?

this looks good. we can test it using https://github.com/islishude/grpc-mtls-example/blob/main/cmd/client/main.go.

  1. Is there some sort of API contract we need to maintain for this such that I can write a conformance or integration test?

we don't have an integration test for the current grpc server. i guess an integration test for the api server would involve spinning up the server and calling each method from an independent client? for testing mTLS specifically, i think we can just get away with only testing one method, since the thing we want to test is actually the TLS connection. something, like the answer to your first question, but coded in a script.

  1. What documentation would we like to see for this?

we don't really have any docs apart from code comments. i think code comments for now is fine. documentation is an entirely separate conversation that we need to have soon.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 17, 2024
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 22, 2024
@EandrewJones
Copy link
Contributor Author

EandrewJones commented Sep 22, 2024

@aryan9600 All comments addressed apart from the one issue flagged below.

  1. Is this all we need to add mTLS support for the api-server?

this looks good. we can test it using https://github.com/islishude/grpc-mtls-example/blob/main/cmd/client/main.go.

If we're not treating this as an integration test, where should we add this so it runs in our pipeline? We need the dataplane server running so we can mimic the client, so it seems like it should go into the integration test pipeline (tests/integration). However, the makefile states these tests are deprecated, so should I really be adding new tests to the suite?

@shaneutt shaneutt added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 15, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 18, 2024
@EandrewJones EandrewJones force-pushed the #50-mtls-for-dataplane branch from 2f70c40 to 06d22a3 Compare October 21, 2024 01:38
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 21, 2024
@EandrewJones
Copy link
Contributor Author

EandrewJones commented Oct 23, 2024

I pushed up a go test that creates certs, spins up the dataplane, and dials the grpc w/ mTLS from a client. The test passes, but I suspect it's a false positive because the dataplane exits almost immediately on my machine due to an error:

Error: map error: failed to create map `AYA_LOGS` with code -1

Caused by:
    0: failed to create map `AYA_LOGS` with code -1
    1: Operation not permitted (os error 1)
Error: map error: failed to create map `GATEWAY_INDEXES` with code -1

Caused by:
    0: failed to create map `GATEWAY_INDEXES` with code -1
    1: Operation not permitted (os error 1)

I only care about having a valid test at this point and adding it to our CI.

My guess is I need to deploy the dataplane into KTF to get a proper environment for testing. Is that correct @shaneutt ?

@EandrewJones
Copy link
Contributor Author

EandrewJones commented Oct 23, 2024 via email

@shaneutt
Copy link
Member

Does the golang controlplane archival have any impact on this? Or do I just need to stand up KTF before I run these tests?

The archival shouldn't have an impact: there's a make build.cluster target that sends the right flags (and will automatically install ktf for you). The Golang integration tests actually were left in main despite removing all the other Go code (since the tests in still have value and help us validate our Rust changes until we replace them with Rust tests).

@EandrewJones EandrewJones force-pushed the #50-mtls-for-dataplane branch from 06d22a3 to e7c2ff1 Compare November 5, 2024 20:53
@EandrewJones EandrewJones force-pushed the #50-mtls-for-dataplane branch from 7dc3686 to 3fa2eef Compare November 17, 2024 21:42
@EandrewJones
Copy link
Contributor Author

@shaneutt @aryan9600 This should be ready for final review. I finally have passing tests. Upon lgtm, I'll squash my commits.

@shaneutt shaneutt requested a review from aryan9600 November 18, 2024 12:41
@EandrewJones EandrewJones force-pushed the #50-mtls-for-dataplane branch from 9fab255 to 9ad32bc Compare December 2, 2024 19:35
@EandrewJones
Copy link
Contributor Author

EandrewJones commented Dec 2, 2024 via email

@EandrewJones
Copy link
Contributor Author

EandrewJones commented Dec 2, 2024

Changes to the docker-build on main break this branch's docker-build step now. Looks like it's due to the branch name violating docker syntax (can't include '#' in a docker image tag is my guess).

I won't have time to touch this this week. :(

@shaneutt
Copy link
Member

shaneutt commented Dec 3, 2024

Ok! No worries, no rush.

@EandrewJones
Copy link
Contributor Author

EandrewJones commented Dec 3, 2024 via email

Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

Thank you so much for all your hard work making this happen.

I approve in that I think we're just about ready to go and I don't see any major blocking issues, however I do have some comments I would like to see resolved before we merge please. Also we gotta figure out the CI issue, but in any case, I think we're really close. Thank you!

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 4, 2024
@shaneutt shaneutt added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 4, 2024
Co-authored-by: Shane Utt <[email protected]>
Signed-off-by: Evan Jones <[email protected]>
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 8, 2024
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Dec 8, 2024
@EandrewJones
Copy link
Contributor Author

@shaneutt I addressed all your comments and fixed the docker-build naming issue by switching the workflow to use the PR number instead of branch name since it's guaranteed to comply with docker's naming rules.

The last thing I need to do is squash. Is there a way for me to squash and re-push without triggering the docker-build action? It's extremely expensive/long-running.

Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

/approve
/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 9, 2024
@shaneutt shaneutt removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 9, 2024
@shaneutt
Copy link
Member

shaneutt commented Dec 9, 2024

Oh wow yeah 70m build time... holy cow.

Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

We could always spend more time here, but given the project is still nascent and we do not have end-users for breakages to impact, let's merge this and start using it!

Thanks for all your hard work @EandrewJones 🙇

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: EandrewJones, shaneutt

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 merged commit af312e6 into kubernetes-sigs:main Dec 9, 2024
5 checks passed
@kubernetes-sigs kubernetes-sigs deleted a comment from EandrewJones Dec 9, 2024
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
Development

Successfully merging this pull request may close these issues.

mTLS for dataplane API
4 participants