Skip to content
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

How to simply create k8s resources by Yaml.loadAs(file) #611

Closed
weixsun opened this issue Jul 6, 2019 · 4 comments
Closed

How to simply create k8s resources by Yaml.loadAs(file) #611

weixsun opened this issue Jul 6, 2019 · 4 comments

Comments

@weixsun
Copy link

weixsun commented Jul 6, 2019

@brendandburns @kondapally1989
I readed issues #254 and #170 .
But I want to create k8s resources via the brower upload yaml file. I actually don't know that the user write which kind and apiVsersion into yaml file, if so, how to create k8s resources via io.kubernetes.client.util.Yaml.loadAs(file)
does it support in this library?
Thanks 🙏

@weixsun weixsun changed the title How to simply create k8s resources by Yaml.loadAs(filePath) How to simply create k8s resources by Yaml.loadAs(file) Jul 6, 2019
@weixsun
Copy link
Author

weixsun commented Jul 6, 2019

For example:kubectl create -f xxx.yaml,kubectl command actually don't know what resources in yaml file, but it works.

@yue9944882
Copy link
Member

the go library has a dynamic [de]serializer so it doesn't require the concrete types. and that implementation is some sort of debatable for a period of time.. as a walkaround, consider deserializing w/ a CustomObject which basically fits into any types.

@brendandburns
Copy link
Contributor

You can do this, the call is:

Yaml.load(file) or Yaml.load(String content)

https://github.com/kubernetes-client/java/blob/master/util/src/main/java/io/kubernetes/client/util/Yaml.java#L171

It returns a generic Object that has the right type (assuming it's known)

@brendandburns
Copy link
Contributor

Closing this since I think the question is answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants