-
Notifications
You must be signed in to change notification settings - Fork 33
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
Create proxy connection (or other KubeAction) #100
Comments
I don’t think we’ve actually implemented port-forward to be honest; the pieces are there but nobody’s needed it so far so there is no explicit support for it. If you look at how the I might have time to look at implementing this sometime next week but the weekend is just about over in my time zone :) |
The enum is just a way for us to categorise the URLs we extracted from the K8s API Swagger document (which lists the API paths and their associated models). |
Ah ok, thought I missed something. Makes sense, would be nice to have, think it could be useful to many who like me wants to "abstract" the kubectl to an internal webpage or similar. I'll take a look at the exec method next week also. Thanks for all the help, appreciate it :) |
I've tried replicating the exec methods for websockets, but I get an 403 access denied when I try to use the portforward post command, not sure if the bearer token is passed on in the request header with this? Here's the method (a bit hardcoded for now):
I have no problems with other operations, like getting, listing, patching, creating. |
Also, is there any good tools to sniff the traffic when I try this? It works fine with kubectl portforward and I can see the POST cmd when i run it verbose (--v=8), but I'd like to see the request when I run this in VS. Tried wireshark, but didn't really give me anything useful. |
What framework are you targeting with the client program?
… On 27 Sep 2019, at 5:52 pm, Morten Meisler ***@***.***> wrote:
I've tried replicating the websocket methods, but I get an 403 access denied when I try to use the portforward post command, not sure if the bearer token is passed on in the request header with this?
Here's the method (a bit hardcoded for now):
public async static Task<WebSocket> PortForward(this IPodClientV1 podClient, string podName, string kubeNamespace = null, CancellationToken cancellation = default)
{
if (podClient == null)
throw new ArgumentNullException(nameof(podClient));
return await podClient.KubeClient.ConnectWebSocket(
$"api/v1/namespaces/{kubeNamespace ?? podClient.KubeClient.DefaultNamespace}/pods/{podName}/portforward?ports=8888,8888",
cancellation
).ConfigureAwait(false);
}
//Initialize KubeApi client
var Client = KubeApiClient.Create(new KubeClientOptions
{
ApiEndPoint = new Uri(myuri),
AuthStrategy = KubeAuthStrategy.BearerToken,
AccessToken = "mytoken",
AllowInsecure = true // Don't validate server certificate
});
//throws: 403 forbidden
var portforward = KubeOperations.PortForward(Client.PodsV1(), "jupyter-notebook-7cfb95db6b-788tm").GetAwaiter().GetResult();
I have no problems with other operations, like getting, listing, patching, creating.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Does it work when you use Exec? Just trying to work out whether it’s a generic websockets issue or something specific to port-forward... |
Yes I think so, this one went through and populated the multiplexer:
I am targeting .NET Core 3.0 Preview 9. But seems like the other methods works fine from your library, so guessing I need something more/else for the POST call of portforward. |
I should upgrade to release ofc, I just found out now it was released some days ago. Don't think it will matter here though. |
Not sure if it will help, but you could try enabling logging of payloads in the |
Hmm. Looks like port-forward uses something like |
Ok thanks, I tried logging, the websocket method is not passing in loggerfactory, so don't think it gives much (or maybe I need to set something more up). Code used:
Log:
|
Hmm, ok, looks like I need to add some logging there :) (sorry, don’t have a working cluster at the moment; I’ll see if I can get Docker for Desktop installed and have a go with that) |
Np, thanks for the effort in any case :) |
Sure thing, sorry for the delay - I should be able to try this out tomorrow |
I’m still looking into this, will let you know what I find :) |
If you run |
And what value do you see in |
Also, I take it if you don't do the |
You can also try |
Alright, I will try tonight when the kids are sleeping ;) |
Sorry for keep asking these "nub" questions :) But I can't figure out how to use the KubeActions (the enum values).
Trying to accomplish something similar to this for an existing pod:
kubectl port-forward jupyter-notebook-7cfb95db6b-z2frd 8888:8888 -n default
Not sure if it's working though ( #10 )
Any example is much appreciated, thank you.
The text was updated successfully, but these errors were encountered: