-
Notifications
You must be signed in to change notification settings - Fork 45
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
[wip] Implement pod exec functionality #192
Conversation
Codecov Report
@@ Coverage Diff @@
## main #192 +/- ##
==========================================
- Coverage 94.91% 94.43% -0.48%
==========================================
Files 25 25
Lines 2378 2391 +13
==========================================
+ Hits 2257 2258 +1
- Misses 121 133 +12
|
for more information, see https://pre-commit.ci
Thanks so much for raising this @jacksgt! I've also been working on an implementation on the side but have been struggling to reverse engineer the protocol, so that blog post you linked is very interesting. For port forwarding we use the websocket functionality in As you say I've converted this to a draft for now, but excited to see any progress you make. |
params["command"] = command | ||
|
||
if container: | ||
params["container"] = container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about defaulting to the first container right here?
params["container"] = container or self.spec.containers[0].name
Just noticed this from a backlink, and pinging in to note that There's a client = httpx.Client()
with client.stream("GET", url, headers=headers) as response:
if response.status != 101:
raise Exception("Failed to upgrade", response)
# Get the raw network stream.
network_steam = response.extensions["network_stream"]
# Read and write operations now available on the upgraded connection.
... (On the off-chance that this might be useful for ya) |
Thanks @tomchristie thats useful to know. We are currently using |
Great choice there. 👍 |
This is an attempt to solve #169 , unfortunately it got stuck due to limitations in the httpx library.
httpx does not support the "Connection: Upgrade" mechanism to switch the transport to SPDY or Websockets:
Here's an example of what
kubectl
does under the hood:For more details about the communication protocol, I recommend having a look at this article: https://cloud.redhat.com/blog/executing-commands-in-pods-using-k8s-api