-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Can't replicate kubectl apply -f
functionality with Python client
#1028
Comments
OK, I see there appears to be some activity on this precise issue now. The Java client seemed to be having the same kind of issue in 2017, to boot. Codegen seems to be a bit unwieldy. Still interested in any workarounds that stay in Python-land! |
We patched the generated rest client to allow using strategic merge patch: python/kubernetes/client/rest.py Lines 158 to 161 in ccd3ce4
That being said, kubectl apply is more than sending a strategic merge patch-- it has logic to do a three-way diff to compose the patch. A better way to do that is to use the new server-side apply feature kubernetes/enhancements#555. We should support sending patch with application/apply-patch content type
|
@roycaihw it looks like this feature is not generally available as of 1.17? |
No it is not. From what I heard it was supported for a sub-portion of Kubernetes APIs in 1.15. |
@roycaihw given that this client doesn't implement the three-way diff logic found in the Related - is this the logic that you're referring to? If so, I might try my hand at implementing it myself - especially if the only two requirements are 1) getting the patch body correct and 2) having the correct content-type. |
also @roycaihw doesn’t that rest client patch preclude me from doing anything other than a strategic merge patch? I’m on a mobile device so it’s a little hard to look at code right now but I’m unclear as to when |
Hi ! As I understand with the current patched generator, all PATCH requests will use Thanks. |
@roycaihw when approximately will this client be supporting the |
I'd be watching the status of PR #959. There are propositions of how to deal with it, but it might require upstream (generator) changes. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What happened (please include outputs or screenshots):
The kubectl CLI uses a StrategicMergePatch type in the underlying API request for
apply
.The Python client should be able to do the same by letting us pass a Content-Type of 'application/strategic-merge-patch+json' into the headers dict, but this odd little piece of generated code precludes us from doing so
python/kubernetes/client/api/apps_v1_api.py
Line 3889 in ccd3ce4
I would like to leverage the Python client as much as possible without resorting to
kubectl
. Is there a way to get around this for the time being?Thanks in advance!
Environment:
Kubernetes version (
kubectl version
):OS (e.g., MacOS 10.13.6):
10.15.1
Python version (
python --version
)3.8.0
Python client version (
pip list | grep kubernetes
)10.0.1
The text was updated successfully, but these errors were encountered: