kubernetes golang客户端上的示例 [英] Samples on kubernetes golang client

查看:285
本文介绍了kubernetes golang客户端上的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从golang客户端创建复制控制器,服务等。 (github.com/kubernetes/kubernetes/pkg/client/unversioned)但是我找不到有关如何操作的任何文档。



我发现这个:



,err:= c.ReplicationControllers(api.NamespaceDefault).Create(rep) t知道把yml数据放在哪里等等。任何发现文档或者有一些我可以入门的示例代码?

我在Go中放置了一个示例Kubernetes客户端,它允许查询API版本并进行示例NGINX部署。也许这对你有帮助: https://github.com/timoreimann/kubernetes-goclient-example



请注意,它不使用复制控制器(顺便说一下,它已被副本集),但使用较新的部署API 。我也不提供YAML文件;相反,我通过编程来定义一切。读取YAML文件并将它们解组到Kubernetes结构中应该是一件相当直接的事情。


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 ?

解决方案

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.

这篇关于kubernetes golang客户端上的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆