Skip to content

Implement pod exec using a Popen like object#730

Open
iciclespider wants to merge 1 commit intokr8s-org:mainfrom
iciclespider:exec-popen
Open

Implement pod exec using a Popen like object#730
iciclespider wants to merge 1 commit intokr8s-org:mainfrom
iciclespider:exec-popen

Conversation

@iciclespider
Copy link
Contributor

@iciclespider iciclespider commented Jan 22, 2026

This is very much a POC, but I believe the functionality is all there. The examples directory has a set of both async and sync examples. I created this Draft PR to get some initial feed back on the direction before doing serious polishing of the code, such as proper unit tests.

Async examples: https://github.com/iciclespider/kr8s/blob/exec-popen/examples/exec_popen.py
Sync examples: https://github.com/iciclespider/kr8s/blob/exec-popen/examples/exec_popen_sync.py

I did run into issues with sync vs async that required creating stand alone sync and async implementations. This is because the sync to async support only works for single purpose calls, but this creates the Popen object inside a context manager that then performs api calls. I am very much open to creative solutions.

Another issue is the stdin, stdout, and stderr field expose different methods in sync vs async. I would like to come up with a common set of methods, but am not sure if the sync or the async flavor should be the target.

I implemented a sync version of api.open_websocket and made a best guess on what to do. It is functional, but not very clean.

Related Issues:

@iciclespider iciclespider marked this pull request as draft January 22, 2026 04:36
@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 46.16541% with 358 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.13%. Comparing base (87063fc) to head (04a3d60).
⚠️ Report is 299 commits behind head on main.

Files with missing lines Patch % Lines
kr8s/popen.py 15.32% 221 Missing ⚠️
kr8s/_popen.py 63.76% 104 Missing ⚠️
kr8s/__init__.py 20.00% 20 Missing ⚠️
kr8s/_exec.py 86.95% 6 Missing ⚠️
kr8s/_objects.py 62.50% 3 Missing ⚠️
kr8s/_api.py 50.00% 2 Missing ⚠️
kr8s/_auth.py 92.30% 1 Missing ⚠️
kr8s/_portforward.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #730      +/-   ##
==========================================
- Coverage   94.61%   89.13%   -5.49%     
==========================================
  Files          29       36       +7     
  Lines        3141     5736    +2595     
==========================================
+ Hits         2972     5113    +2141     
- Misses        169      623     +454     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@iciclespider iciclespider marked this pull request as ready for review February 13, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments