Closed gohonsen closed 2 months ago
This isn't currently supported. You can read resize messages from the stream via Exec.getResizeStream()
but you can't write to that stream currently.
We need something like the following in the Javascript client:
We'd be happy to take a PR for this support.
Alternately, you could use ExecProcess.getInputStream(4).write("{ 'width': foo, 'height': bar}")
that should work.
@brendandburns I got it, the codes like this:
Exec.ExecutionBuilder executionBuilder = k8sExec.newExecutionBuilder(namespace, podName, new String[]{shellPath}); executionBuilder.setTty(tty); executionBuilder.setContainer(containerName); execProcess = (Exec.ExecProcess) executionBuilder.execute(); resizeOutStream = execProcess.getResizeStream(); outputStream = execProcess.getOutputStream(); inputStream = execProcess.getInputStream(); String resize = "{\"Width\":" + cols + ",\"Height\":" + rows + "}"; resizeOutStream.write(resize.getBytes());
and it works, thanks.
Glad it's working. Making this a little easier could be a good first issue, so I'll leave this open in case someone wants to take it on.
@brendandburns i want to work on this issue. But the problem i cant setup the code properly can you send me the steps to setup the code.
i have done this till now.
thanks
then i did this
next how should i proceed to do the required changes and test and contribute. It is some what tricky to a begginer to this code base. can you kindly please help me.
@sriganeshres the second command is to regenerate the code, you don't need to do that.
What you need to do is edit this file:
To add a function like setTerminalSize(int widthColumns, int heightColumns)
and which does code similar to https://github.com/kubernetes-client/java/issues/3641#issuecomment-2301637328.
If you need help with git or making a PR, please see instructions here: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request?tool=cli
thank you @brendandburns
@brendandburns I have added a PR #3657 for this. Thanks for the help and understanding.
@sriganeshres thank you. In the future, you can just push new commits to the same branch and this PR will update, you don't need to create a new PR. I will close this PR given the new one.
Describe the bug Hey, I want to enter the k8s pod container to run shell commands through web terminal, but I found that after the web terminal page size changed, I cann't synchronize set terminal size through exec API, and the page display is disordered. Is there any way to set the terminal stty cols and rows ? Thanks a lot
Client Version
18.0.1
Kubernetes Version
v1.28.0
Java Version Java 8