-
Notifications
You must be signed in to change notification settings - Fork 3.3k
How do I run kubectl apply-f using the API #1168
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
Comments
maybe you can use replace_XXX api |
You can look at that example as well https://github.com/kubernetes-client/python/blob/master/kubernetes/utils/create_from_yaml.py |
@MoShitrit create_from_yaml works when we have to create a resource. |
Trying to write a utility replace_from_yaml
The same payload works with |
What's the value of |
This is the payload Am passing
If you can point me in the right direction I might be able to write down both these functionalities replace and apply. |
The payload seems fine. But looking back at your code, I think I see what's missing. else:
namespace = "default"
|
kubectl implements a three-way diff logic to perform a client-side apply. We should add example/documentation about how to use the new server-side apply feature instead of re-implementing client-side apply in this client. |
@roycaihw Can you point me to the kubectl implementation Let me see if I can code the same logic in python. |
@MoShitrit agree but for the yaml am providing am passing the namespace value. |
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. |
I'm not sure how people are using the python client without this feature... I'm trying to move our deployment process from command line tools (like |
@tvkit i'm sure it is, but it doesn't have a lot to do with the |
This ticket may be a duplicate of #1093 |
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. |
Hey! Is there any chance this would be implemented in the future? Not sure how to effectively mimic |
@adammrozik - Looks like they just merged an example https://github.com/kubernetes-client/python/pull/1752/files |
This example actually uses the |
I assume this requires a rewrite of kubectl's The workaround is to pipe input to kubectl subprocess.run(["kubectl", "apply", "-f", "-"], input=substituted, encoding='utf-8') Where |
I tried using the Kubernetes API python to execute the
kubect apply
command to deploy and update resourcesthe kubectl command is as follows:
export
is afolder
containingmultiple yaml files
, which is generated bykompose convert -o export
I only found an alternative API for
kubectl create
, but I didn't findapply
How do I implement
kubectl apply
tocreate
resources and possible subsequentupdates
If you know, please let me know. thank you in advance!
The text was updated successfully, but these errors were encountered: