简体   繁体   中英

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.

As we can read in the Kubernetes docs Pausing and Resuming a Deployment .

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. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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