I'm using AWS' EKS which is Kubernetes v1.10 and I'm using client-go v7.0.0.
What I'm trying to do is parse a .yml file with multiple Kubernetes resource definitions in a file and submit those resources to the Kubernetes API. I can successfully parse the files using this code scheme.Codecs.UniversalDeserializer().Decode
, and I get back an array of runtime.Object
.
I know that all the Kubernetes resources conform to the runtime.Object
interface, but I can't find a way to submit the generic interface to the API. Most methods I've seen use the methods on the concrete types like Deployment, Pod, etc.
I've seen some code around a generic RESTClient like this clientset.RESTClient().Put().Body(obj).Do()
, but that doesn't work and I can't figure it out.
I know my clientset is configured correctly because I can successfully list all Pods.
If you have a "generic"
runtime.Object
, you can use the dynamic client in client-go for this. The dynamic client deals withunstructured.Unstructured
objects and allruntime.Object
s can be converted to it. Here is an example: