<p>Is there a way to restart a kubernetes deployment using go-client .I have no idea how to achieve this ,help me!</p>

<p>If you run <code>kubectl rollout restart deployment/my-deploy -v=10</code> you see that kubectl actually sends a PATCH request to the APIServer and sets the <code>.spec.template.metadata.annotations</code> with something like this:</p>
<pre class="lang-yaml prettyprint-override"><code>kubectl.kubernetes.io/restartedAt: '2022-11-29T16:33:08+03:30'
</code></pre>
<p>So, you can do this with the client-go:</p>
<pre class="lang-golang prettyprint-override"><code>clientset, err :=kubernetes.NewForConfig(config)
if err != nil {
    // Do something with err
}
deploymentsClient := clientset.AppsV1().Deployments(namespace)
data := fmt.Sprintf(`{&quot;spec&quot;: {&quot;template&quot;: {&quot;metadata&quot;: {&quot;annotations&quot;: {&quot;kubectl.kubernetes.io/restartedAt&quot;: &quot;%s&quot;}}}}}`, time.Now().Format(&quot;20060102150405&quot;))
deployment, err := deploymentsClient.Patch(ctx, deployment_name, k8stypes.StrategicMergePatchType, []byte(data), v1.PatchOptions{})
if err != nil {
    // Do something with err
}
</code></pre>
