3 ms·
How does 'kubectl exec' work? (2019)
- debarshri 5y agoOne of the fun things I recently did was re-implementing it kubectl exec in client-go following a github [1]. Fun challenge is to then convert it into a websocket or http handler. [1]https://github.com/kubernetes/client-go/issues/809 https://github.com/kubernetes/client-go/issues/809
- Deathmax 5y agoI had to do it for work for a tool to interact with remotely hosted containers. Tip for anyone trying to do this in Go, look at Docker CLI's code for all the knobs you need to turn to have an actually interactive terminal, for example, setting raw mode on the terminal, handling terminal resizes, and other things across platforms.
- xelxebar 5y agoCrazy. I was just looking at this earlier when running into a problem with `kubectl exec` causing processes to leak in pods: 1. kubectl exec -ti foo -- bash # start shell in some pod 2. echo $$ # get pid of that shell 3. # close terminal without explicitly exiting bash 4. kubectl exec -ti foo -- sh -c 'ls /proc/<previous pid>' It looks like SIG* on the kubectl side aren't getting propagated to the in-pod process. Does anyone know of a proper way to prevent this process leak?
- deepsun 5y agoMaybe related: it matters whether you start your main in-pod process (entrypoint) though "sh java" or directly, e.g. "java". In the latter case all SIG* are received normally, but you cannot use env variables in command line.
- jl2718 5y agoImportant information: “By default, the apiserver does not verify the kubelet’s serving certificate, which makes the connection subject to man-in-the-middle attacks, and unsafe to run over untrusted and/or public networks.”