title: How to evict or delete pods from Kubernetes using golang client
body: <p>I want to evict all pods from a Kubernetes node by using the client-go package. Similar to <code>kubectl drain &lt;Node&gt;</code>. Possibly ignoring the <code>kube-system</code> namespace pods.</p>
  <p>I've obtained the list of pods from a node by:</p>
  <pre><code>func evictNodePods(nodeInstance string, client *kubernetes.Clientset) {
  
      pods, err := client.CoreV1().Pods(&quot;&quot;).List(metav1.ListOptions{
          FieldSelector: &quot;spec.nodeName=&quot; + nodeInstance,
      })
  
      if err != nil {
          log.Fatal(err)
      }
      for _, i := range pods.Items {
          if i.Namespace == &quot;kube-system&quot; {
              continue
          } else {
              //evict
          }
      }
  }
  </code></pre>
  <p>But im not clear on how to send a POST request to evict the pods on a given node instance</p>