Samples on kubernetes golang client

落爺英雄遲暮 提交于 2020-01-16 19:36:13

问题


I`m trying to create replication controllers, services etc from the golang client. ("github.com/kubernetes/kubernetes/pkg/client/unversioned") However I cannot find any documentation on how to do so.

I found this:

r, err := c.ReplicationControllers(api.NamespaceDefault).Create(rep)

But I don`t know where to put the yml data etc. Anyone who found documentation or has some sample code that I could get started with ?


回答1:


I put together a sample Kubernetes client in Go that allows to query the API version and make a sample NGINX deployment. Maybe it's helpful to you: https://github.com/timoreimann/kubernetes-goclient-example

Note that it doesn't use replication controllers (which, by the way, have been replaced by replica sets by now) but uses the newer Deployments API. I also don't feed in YAML files; instead, I define everything programmatically. Reading YAML files and unmarshalling them into Kubernetes structs should be a fairly straight-forward thing to do though.



来源:https://stackoverflow.com/questions/37135933/samples-on-kubernetes-golang-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!