<p>I would like to roll back the deployment to a certain revision( rollout history) using client-go library of k8s. But so far I havent found a solution. I could onyl fetch resource revision but not 'deployment revision' that I get using kebctl </p>

<pre><code>kubectl rollout history deployment/nginx_dep
</code></pre>

<p>Here is the code using client-go api :</p>

<pre><code>config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)

clientset, err := kubernetes.NewForConfig(config)

dp, err := clientset.ExtensionsV1beta1Client.Deployments("default").Get("nginx-deployment", metav1.GetOptions{})
</code></pre>

<p><strong><em>Using client-go api:
How do I get the existing revision for the given deployment.? I want to roll back the deployment to use this revision. Can anyone tell me how I should do that??</em></strong></p>

<p>Here is the list of dependecies in my project:</p>

<pre><code>[[constraint]]
  name = "k8s.io/client-go"
  version = "3.0.0"

[[override]]
  name = "k8s.io/apimachinery"
  branch = "release-1.6"
</code></pre>

<p>Thank you in advance</p>

<p>Assuming you already had a look at the <a href="https://github.com/kubernetes/client-go/tree/master/examples/create-update-delete-deployment" rel="nofollow noreferrer">update example</a>?</p>

<p>In any case, the <code>dp</code> variable here contains all you need:</p>

<pre><code>dp, err := clientset.ExtensionsV1beta1Client.Deployments("default").Get("nginx-deployment", metav1.GetOptions{})
</code></pre>

<p>So <code>dp</code> is of type <code>v1beta1.Deployment</code> which contains a variable of type <code>metav1.ObjectMeta</code> which has the <code>ResourceVersion</code>.</p>
