-
-
Notifications
You must be signed in to change notification settings - Fork 816
feat: override authority in GRPC client initialization #12556
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
|
||
| package basic_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/siderolabs/talos/pkg/grpc/middleware/auth/basic" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestParseAuthority(t *testing.T) { | ||
| for _, tc := range []struct { | ||
| host string | ||
| want string | ||
| }{ | ||
| {"", ""}, | ||
| {"::1", ""}, | ||
| {"[::1]", ""}, | ||
| {"[::1]:443", ""}, | ||
| {"127.0.0.1", ""}, | ||
| {"127.0.0.1:443", ""}, | ||
| {"[example.com]", ""}, | ||
| {"example.com", "example.com"}, | ||
| {"example.com:443", "example.com"}, | ||
| {"[example.com]:443", "example.com"}, | ||
| } { | ||
| assert.Equalf(t, tc.want, basic.ParseAuthority(tc.host), "ParseAuthority(%q)", tc.host) | ||
| } | ||
| } |
14 changes: 0 additions & 14 deletions
14
pkg/grpc/middleware/auth/basic/username_and_password_test.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this wouldn't work, as we have a list of endpoints, and pass a single authority with it.
Either the round-robin should return a proper authority, or something else should be going on here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smira is there any difference in the way Talos populates the value for the
addressparameter for theNewConnectionmethod depending on the number of endpoints that would make this fail if there is more than one endpoint to balance the load with ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, reading through the code of the gRPC client, and looking at our code, we are setting the
ServerNamecorrectly in our resolver, so it should be propagated as intended:Adding the
WithAuthorityhere will override that - and this is to be done by the user. We need a new configuration (new document? field in existing document?) that will allow setting that field (?).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to describe the setup I've successfully tested this with.
I have an existing "admin" cluster made up of Talos nodes.
Within that cluster I have deployed :
tenant-onewith talos-csr-signer as an extra container (as described here)api.tenant-one.ingress.example.comon both ports to either the Kamaji control plane or CSR signer for that tenantI also have :
*.ingress.example.compointing to that IPI'm now trying to add Talos nodes to that
tenant-oneKamaji control-plane with the following cluster configuration :With Talos v1.10.9 (without the proposed changes) when the node is initializing it sends a request to the resolved IP for
api.tenant-one.ingress.example.comon port 50001. As that requests doesn't include the configured host name, the Gateway API controller doesn't present the right certificate and Talos can't validate the CA.With a custom Talos image with the hard-coded string
api.tenant-one.ingress.example.comas authority, the node successfully gets its certificate from the CSR signer.Even if I haven't tested this setup with more than one IP resolving the host or with Talos control-plane nodes (and not Kamaji's CSR signer), I don't see why it would not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide a reproducer - minimal set of manifests that we can test this with? This might be easier than I initially thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it reproduces (with pods in a K8S cluster) a regular setup with 3 control-plane nodes and a bunch of worker Nodes all running Talos images, that test actually also shows that it works even if we pass multiple addresses.
I had to run the test again as the pod logs had expired since my initial test, but here are the logs from one of the worker nodes :
You can clearly see the control-plane pod IPs and the external LB IP (resolved from the provided cluster endpoint in the Talos config) being passed as endpoints to the gRPC client.
I'm sorry but I don't see how this would be any different with VM or BM nodes.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only restriction for it to work might be that all control-plane nodes need to include the host used as gRPC authority in the machine certSANs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly, and this is not the case for "bare" Talos, this is only the case for your setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this is not just my setup : it was built following Talos documentation guidelines :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This talks about API access, that is
apid, nottrustd, and this has nothing to do with what I posted above.Talos workers connect to
trustds using direct connection by IP - that's the primary path.