Kubernetes Java Client 13.0.0 copyFileToPod() hangs

8/27/2021

Client: Windows Server 2019 (GCE node) / JDK8 / kubernetes-java 13.0.0 Cluster: Google Kubernetes Engine v1.19.12-gke.2100 Pod: Ubuntu 20.04 base image (also tried w/ Alpine Linux)

I'm trying to integrate the Kubernetes Java client (v13.0.0) into my QA automation code so I can push test files to a pod. I'm trying to use the copyFileToPod() method however it hangs while seemingly waiting for the remote process to complete.

It seems based on my current level of knowledge that the client side is waiting for an exit code via WebSocket stream 3 (remote process completes and sends the exit status?) that never happens.

In a typical shell command when streaming to a process (such as tar) from stdin, there needs to be a way to signal end of input (CTRL-D).

In the WebSocket world, what would trigger this? I have tried closing the streams, writing CTRL-D (0x04) + '\n' to the outputStream with no luck.

I have a workaround that does work by flushing the outputStream and then destroying the process via proc.destroy() which closes the underlying socket, but this feels like a kludge as it doesn't seem to cleanly terminate the remote process.

  • Has anyone successfully been able to copy files to a Pod?
  • Can anyone provide additional insight on how the client-side WebSocket should stream data (file copy) and signal the end of transmission/input so the remote process completes and returns the exit code normally?

Thanks!

-- Jeff Vincent
kubernetes
kubernetes-apiserver

0 Answers