-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Add port forward #446
Add port forward #446
Conversation
Hey, this is great! A lot of the hairy channel management (spawning a task for each port makes sense) looks like it's done. Error handling perhaps needs a bit more improvements, but you've already got a nice stream interfaces on top of Well, insofar as letting people write raw http requests into a stream can be user friendly. EDIT: But I guess we can't go all in HTTP as this is meant to be protocol agnostic. The Service idea does sound interesting though! At least if we can something like the interface you posted. |
Ah, forgot about this. Yeah, the example still works, and presents the basic functionality. We certainly can merge it as it stands as an initial version of it. But also feel like it might be better to have the canonical Then on the other hand, people needing that probably aren't writing up against |
Come to think of it, I might also be able to extract a tokio-tungstenite-based websocket example from my code in the next few days if that's interesting. |
4445087
to
61d2add
Compare
Codecov Report
@@ Coverage Diff @@
## master #446 +/- ##
==========================================
- Coverage 71.92% 70.02% -1.91%
==========================================
Files 56 57 +1
Lines 3775 3906 +131
==========================================
+ Hits 2715 2735 +20
- Misses 1060 1171 +111
Continue to review full report at Codecov.
|
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.
thanks for fixing this up - we haven'd had real feedback on this in a year, so it's probably fine to add it to get more users. i am happy to approve, just left a few minor nits here first that i think could be easy wins if they work
I thought the port stuff could be done a little cleaner, but ultimately don't see a good way - so resolved my gripes with some comments. Added some minor suggested tweaks to docs ultimately though, the functionality here works well and we should probably merge this to invite more users. How are you feeling about it now @kazk? |
Leaving this out of the release as it is still a draft PR - although I would be happy merging it. |
1c697d5
to
2a21db8
Compare
Sorry for the delay. |
I got an example to bind local port working. I'll push it after cleaning it up. |
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.
Ah, didn't realise you had such a large refactoring left in you. Thanks a lot, it's definitely cleaner!
Minor comments left, but no real suggestions other than the superficial example doc thing.
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.
very cool full port-forward
example in just over 100 lines with lot of helpful technical parts in it!
everything seems like it's working well! don't have any other outstanding comments.
looking forward to have this in :-)
let context = Arc::new(Mutex::new(sender)); | ||
let make_service = make_service_fn(move |_conn| { | ||
let context = context.clone(); | ||
let service = service_fn(move |req| handle(context.clone(), req)); | ||
async move { Ok::<_, Infallible>(service) } | ||
}); |
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.
cool quick use of tower!
Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Co-authored-by: Eirik A <[email protected]> Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Co-authored-by: Eirik A <[email protected]> Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Yeah, the local port example was easier than I had expected. I think this is good enough as a first version. |
Very nice! I'll do a release later on today. Tons of stuff ready. |
Super rough sketch I mentioned almost 2 months ago. #127 (comment)
I don't like this at all, but an example with Nginx (from Python client example) works and can be a starting point for discussion. Any feedback/ideas are appreciated, but I honestly don't remember much, so I might not be able to answer "why?".
Protocol
WebSocket messages are binary (
[channel, ...data]
) like/attach
and/exec
.For
/portforward
, channels are associated with the specified ports and each port uses 2 channels: a duplex data channel (2*i
) and a read-only error channel (2*i + 1
) fori
th port.The first message for a channel is always 3 bytes and describes this association:
Idea
EDIT: Maybe this can be done on top of the lower level API provided by kube in this PR. I won't be trying this for now.
Make
Portforwarder
tower::MakeService
(Service
ofService
)? I haven't tried, but it might be possible, and it'll make it a lot more usable.kubectl port-forward example local_port:remote_port
.