-
Notifications
You must be signed in to change notification settings - Fork 107
A way to load resources directly from file yaml manifest #101
Comments
I'd recommend shelling out to kubectl or using client-go for now. Supporting YAML and JSON serialization for known manifests isn't easy (#8). I've had the thought of adding a RawResouce, where you could stick a payload then the client would POST whatever's in the body: type RawResource struct {
APIVersion string
Kind string
Metadata v1.ObjectMeta
ContentType string
Bytes []byte
} but for now, it sounds like you'd probably just want to use |
the issue: app should support two different clusters, as example 1.7 and 1.11+ |
You probably want two different manifest then anyway, right?
A couple lines of bash sounds nicer to me than messing with untyped YAML and JSON in Go :) |
This might not help you, and it's certainly not ideal, but at least to share what worked for my use case: While using a manifest file that would work with kubernetes doesn't work as is, you could adjust the yaml so that the fields line up with what the unmarshaller is expecting. I used https://github.com/ghodss/yaml for yaml since it transitions through json allowing you to take advantage of the json related tags. (this might not be necessary any more, I see yaml tags have been merged in) You could also get an existing resource via the library and then marshall it to to yaml and dump it out to a file to get an example of what it needs to look like, I think that would work. for example a readinessProbe might become:
Once you get used to the differences they are pretty easy to write, they are just a little more verbose, and unfortunately it does require separate manifests for whatever you are using this library for. |
I love the simplicity of this kubernetes client, but I too am running into this same challenge. Any thoughts on replacing the |
If you need those packages I'd recommend using client-go. There's no way to import kubernetes/api without getting most of the client-go package anyway. I still think my earlier comment about a RawResource would be the way to handle this use case. |
Hi,
Is there a way to load resources directly from file yaml manifest? Let's say I have manifest stored in git and I want to apply it to the cluster.
I think it's possible to do so by creating new resource (in my case - deployment) and then apply this new resource, but it would be really nice to have out-of-the-box method for this, and maybe this method will take care of resource API version.
The text was updated successfully, but these errors were encountered: