Attach to pod feature
See original GitHub issueIs your enhancement related to a problem? Please describe
For our current project, we need the ability to attach to the container in a pod to send stdin and read stdout. If I understood correctly, currently there is no way to do it.
Describe the solution you’d like
Implement kubectl attach
equivalent the same way as kubectl exec
is implemented. The main concern regarding the implementation of such feature is that its’ DSL would clash the existing one for exec
(e.g. redirectingInput().redirectingOutput().exec("...")
). In my point of view, the DSL should be extended instead of copying, i.e.:
ExecWatch execResult = client.pods().withName("...").inContainer("session").redirectingInput().exec("ls");
AttachWatch attachResult = client.pods().withName("...").inContainer("session").redirectingInput().attach("ls");
Describe alternatives you’ve considered
The alternative way to support such case would be to give a user the ability to use WebSockets directly as it is implemented in official kubernetes-client (though, just to mention, official kubernetes-client has the attach
feature). I don’t like such approach, but it may be easier to implement.
Additional context
I’m ready to try to implement this feature by myself after syntax & requirements will be clear.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Sounds good.
Try adding ExecWatch attach() as a method on https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/dsl/Execable.java
Then add the attach implementation on PodOperationsImpl - you should be able to reuse most of the exec logic.
I’m trying to attach to the main process (that is actually a shell) of the pod. In that case I can reconnect to the same process (with same previously defined env vars, for example).
Sorry, I didn’t clarify that in my previous message - I meant rescheduling or failure of my app with k8s client, not of a pod with a shell.