-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Models <-> Json/Yaml #63
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
I think converting models to JSON/Yaml and vice versa are both useful. Converting models to json should be easy. Each model has a import json
from kubernetes.models import V1Pod
v1Pod = ... # read it from somewhere
dic = v1Pod.to_dict()
print (json.dumps(dic)) Converting json to swagger model though is not straightforward I guess, we need to develop a utility method to do it with an interface like this: from kubernetes import util # maybe we would find better name than util
v1Pod = util.load(dict=v1_pod_dict) The |
Look like we should be able to pass a loaded json dic to an API call without any change. I will add an example for this, and if it worked, we can close this issue. |
In addition to fully wrapping the k8s client and replacing kubectl, I've found it very useful to be able to generate raw JSON/YAML for objects created using the swagger generated schema models.
This makes a few other deployment methods easier, such as Spread or Helm.
Thoughts on whether it's worth adding to this project, and where the cleanest place would be? Seems like it should likely be some utility functions in the model layer, rather than patching the client (unless there's a built-in way of doing this with the swagger-codegen client).
The text was updated successfully, but these errors were encountered: