title: How to remove a node label with kubernetes API
body: <p>I'm handling kubernetes node labels in go with kubernetes API. For label add, it works. But for label delete, do not know what is the right way.</p>
  
  <p>This is the demo code that add label works:</p>
  
  <pre><code>key := "testkey"
  
  value := "testvalue"
  
  patch := `{"metadata":{"labels":{"` + key + `":"` + value + `"}}}`
  
  _, err := clientset.CoreV1().Nodes().Patch("10.x.x.x", types.StrategicMergePatchType, []byte(patch))
  </code></pre>
  
  <p>So what about the delete case?
  I have tried some answers in Stack Overflow, like:</p>
  
  <pre><code>patch := `{"metadata":{"labels":{"$patch":"delete","testkey":"testvalue"}}}
  </code></pre>
  
  <p>It will remove all the labels on this node, but not the only "testkey" label.</p>