-
Notifications
You must be signed in to change notification settings - Fork 410
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
[Feature][kubectl-plugin] Implement kubectl ray session #2298
[Feature][kubectl-plugin] Implement kubectl ray session #2298
Conversation
@chiayi @andrewsykim @kevin85421 PTAL In this draft PR I only implemented the port-forwarding part of the Ray Dashboard. I use the
If we don't use https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/portforward/portforward.go What do you think? |
I think usnig client-go portforward library makes sense. Can you share the output you see when you run |
rayHeadSrc := rayHeadSvcs.Items[0] | ||
|
||
portForwardCmd := portforward.NewCmdPortForward(factory, *options.ioStreams) | ||
portForwardCmd.SetArgs([]string{"service/" + rayHeadSrc.Name, "0:8265"}) |
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.
Another possibility instead of using 0:8265
is to default the local port to 8265 and make it configurable?
rayHeadSrc := rayHeadSvcs.Items[0] | ||
|
||
portForwardCmd := portforward.NewCmdPortForward(factory, *options.ioStreams) | ||
portForwardCmd.SetArgs([]string{"service/" + rayHeadSrc.Name, "0:8265"}) |
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.
Also consider port-forwarding the client port at 10001?
0b23893
to
ac6f6fb
Compare
@andrewsykim The above is the output of the command. Currently I hard-coded the port to 8265 and 10001. We can make these 2 ports configurable if needed in the future. |
portForwardCmd := portforward.NewCmdPortForward(factory, *options.ioStreams) | ||
portForwardCmd.SetArgs([]string{"service/" + rayHeadSrc.Name, "0:8265"}) | ||
|
||
if err := portForwardCmd.ExecuteContext(ctx); err != nil { |
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.
Run this as a goroutine with a stop channel?
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.
Are there any benefits to run it as a goroutine?
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.
Feel free to ignore, I thought the stop channel would be necessary to handle stop signal but looks like it's already handled by client-go
|
||
fmt.Printf("Ray Dashboard: http://localhost:%d\nRay Interactive Client: http://localhost:%d\n\n", DASHBOARD_PORT, CLIENT_PORT) | ||
|
||
if err := portForwardCmd.ExecuteContext(ctx); err != nil { |
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.
Will interrupt signal work here? (^C)
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. You can see from the screenshot above that the last line is ^C.
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, I didnt' see the terminal prompt after so it wasn't clear if it actually stopped the program
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
ac6f6fb
to
37f133e
Compare
@andrewsykim @kevin85421 I've added tests and marked this PR as ready for review. Thanks. |
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.
LGTM, @chiayi can you review this too please?
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.
Just one thing I want to clear up but other than that LGTM!
return err | ||
} | ||
|
||
portForwardCmd := portforward.NewCmdPortForward(factory, *options.ioStreams) |
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.
@andrewsykim @MortalHappiness Want to make sure I'm on the same page, since I know there were some discussion on the port forwarding. Is the plan to currently use kubectl port forward since it's more straightfoward and change to client-go in the future for more configurability?
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, now in #2298 I use the kubectl port-forward
directly by calling ExecuteContext
(from cobra
package).
But I don't know whether we want to change to client-go
in the future.
https://pkg.go.dev/github.com/spf13/cobra#Command.ExecuteContext
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.
Merge this PR because @andrewsykim has already approved the PR.
Why are these changes needed?
This PR implements the Ray session part in this REP.
Related issue number
N/A
Checks