Samples on kubernetes golang client

2019-09-05 15:44发布

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条回答
老娘就宠你
2楼-- · 2019-09-05 16:37

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.

查看更多
登录 后发表回答