简体   繁体   English

golang k8s 客户端中的 Pod 重新部署触发器

[英]Pod redeploy trigger in golang k8s client

How can I trigger the update (redeploy) of the hearth through the k8s golang client.如何通过 k8s golang 客户端触发炉膛的更新(重新部署)。

At the moment, I use these libraries to get information about pods and namespaces:目前,我使用这些库来获取有关 pod 和命名空间的信息:

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也许还有另一个库,或者可以通过 linux 信号完成

The standard way to trigger a rolling restart is set/update an annotation in the pod spec with the current timestamp.触发滚动重启的标准方法是使用当前时间戳在 pod 规范中设置/更新注释。 The change itself does nothing but that changes the pod template hash which triggers the Deployment controller to do its thang.更改本身只会更改 pod 模板哈希,从而触发 Deployment 控制器执行其操作。 You can use client-go to do this, though maybe work in a language you're more comfortable with if that's not Go.您可以使用client-go来执行此操作,但如果不是 Go,则可能使用您更熟悉的语言工作。

The go client and similar libraries would be following the REST API structure. go 客户端和类似的库将遵循 REST API 结构。 I believe the kubectl client also uses the API, so it should be possible.我相信kubectl客户端也使用了 API,所以应该是可以的。

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/查看 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/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM