title: Patching deployments via kubernetes/client-go
body: <p>Having trouble figuring out what is wrong. I have a remote kubernetes cluster up and have copied the config locally. I know it is correct because I have gotten other commands to work for me.</p>
  <p>The one I can't get to work is a deployment patch. My code:</p>
  <pre class="lang-golang prettyprint-override"><code>const namespace = &quot;default&quot;
      
  var clientset *kubernetes.Clientset
  
  func init() {
      kubeconfig := &quot;/Users/$USER/go/k8s-api/config&quot;
      config, err := clientcmd.BuildConfigFromFlags(&quot;&quot;, kubeconfig)
      if err != nil {
          log.Fatal(err)
      }
  
      // create the clientset
      clientset, err = kubernetes.NewForConfig(config)
      if err != nil {
          panic(err.Error())
      }
  }
  
  func main() {
      deploymentsClient := clientset.ExtensionsV1beta1().Deployments(&quot;default&quot;)
  
      patch := []byte(`[{&quot;spec&quot;:{&quot;template&quot;:{&quot;spec&quot;:{&quot;containers&quot;:[{&quot;name&quot;:&quot;my-deploy-test&quot;,&quot;image&quot;:&quot;$ORG/$REPO:my-deploy0.0.1&quot;}]}}}}]`)
      res, err := deploymentsClient.Patch(&quot;my-deploy&quot;, types.JSONPatchType, patch)
      if err != nil {
          panic(err)
      }
      fmt.Println(res)
  
  }
  </code></pre>
  <p>All I get back is:
  <code>panic: the server rejected our request due to an error in our request</code></p>
  <p>Any help appreciated, thanks!</p>