英文:
Pod redeploy trigger in golang k8s client
问题
你好!以下是你要翻译的内容:
如何通过k8s golang客户端触发Hearth的更新(重新部署)。
目前,我使用以下库来获取有关Pod和命名空间的信息:
v1 "k8s.io/api/core/v1"
k8s.io/apimachinery/pkg/apis/meta/v1
k8s.io/client-go/kubernetes
k8s.io/client-go/rest
也许还有其他的库,或者可以通过Linux信号来完成。
英文:
How can I trigger the update (redeploy) of the hearth through the k8s golang client.
At the moment, I use these libraries to get information about pods and namespaces:
v1 "k8s.io/api/core/v1
k8s.io/apimachinery/pkg/apis/meta/v1
k8s.io/client-go/kubernetes
k8s.io/client-go/rest
Maybe there is another library or it can be done through linux signals
答案1
得分: 2
触发滚动重启的标准方法是在Pod规范中设置/更新一个注释,其中包含当前的时间戳。这个改变本身并不起作用,但会改变Pod模板的哈希值,从而触发部署控制器执行其操作。你可以使用client-go
来实现这一点,不过如果你对Go语言不太熟悉的话,可以选择使用你更熟悉的语言。
英文:
The standard way to trigger a rolling restart is set/update an annotation in the pod spec with the current timestamp. The change itself does nothing but that changes the pod template hash which triggers the Deployment controller to do its thang. You can use client-go
to do this, though maybe work in a language you're more comfortable with if that's not Go.
答案2
得分: 1
go客户端和类似的库将遵循REST API结构。我相信kubectl
客户端也使用API,所以应该是可行的。
在go库中查看pod函数的代码(可能是"Apply"是你要找的):
https://github.com/kubernetes/client-go/blob/master/kubernetes/typed/core/v1/pod.go
以及API参考:
https://kubernetes.io/docs/reference/kubernetes-api/
英文:
The go client and similar libraries would be following the REST API structure. I believe the kubectl
client also uses the API, so it should be possible.
Checkout the code for pod functions in the go library (possibly "Apply" is what you're looking for):
https://github.com/kubernetes/client-go/blob/master/kubernetes/typed/core/v1/pod.go
and the API reference:
https://kubernetes.io/docs/reference/kubernetes-api/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论