[英]kubernetes Client-go kubectl rollout example
Could anyone get me a example about how to use谁能给我一个关于如何使用的例子
kubectl rollout pause xxx
kubectl rollout update xxx
in client-go?在客户端去? I can't find any example about it.
我找不到任何关于它的例子。 Thank you~
谢谢~
maybe.也许。
data := fmt.Sprintf(`{"spec":{"template":{"metadata":{"annotations":{"kubectl.kubernetes.io/restartedAt":"%s"}}}}}`, time.Now().String())
resultDeployment, err = p.Client.AppsV1().Deployments(p.Namespace).Patch(context.Background(), deployment.Name, types.StrategicMergePatchType, []byte(data), metav1.PatchOptions{FieldManager: "kubectl-rollout"})
you can use kubectl
with --v=6 to see the logs, for example kubectl get pods --v=6
, and build a request use go-client.您可以使用带有 --v=6 的
kubectl
查看日志,例如kubectl get pods --v=6
,并使用 go-client 构建请求。
As we can read in the Kubernetes docs Pausing and Resuming a Deployment .正如我们在 Kubernetes 文档暂停和恢复部署中看到的那样。
You can pause a Deployment before triggering one or more updates and then resume it.
您可以在触发一个或多个更新之前暂停部署,然后恢复它。 This allows you to apply multiple fixes in between pausing and resuming without triggering unnecessary rollouts.
这允许您在暂停和恢复之间应用多个修复,而不会触发不必要的部署。
Updating a Deployment
using Go-Client is easy because you are just updating the fields that you want to change, and once done commit them.使用 Go-Client 更新
Deployment
很容易,因为您只需更新要更改的字段,并在完成后提交它们。 So as long as you don't push the changes to the cluster you can still add new updates.因此,只要您不将更改推送到集群,您仍然可以添加新的更新。
Here is a article on How to write Kubernetes custom controllers in Go and another one about Updating and rolling back a deployment .这是一篇关于如何在 Go 中编写 Kubernetes 自定义控制器的文章和另一篇关于更新和回滚部署的文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.