<p>Usually, we delete a label like that 'kubectl label namespace namespace_name labelname-'</p>

<p>But I want to delete it by kubernetes api,  what should I do ?   </p>

Free
<p>As far as I'm aware, you won't be able to delete the label but replace/rename it.</p>

<p>That might be doe using <code>patch</code> option which you can read about on <a href="https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/" rel="nofollow noreferrer">Update API Objects in Place Using kubectl patch</a>.</p>

<p>There is also several questions on Stack Overflow regarding this subject.
 - <a href="https://stackoverflow.com/questions/37481205/how-to-delete-a-label-for-a-kubernetes-pod">How to delete a label for a kubernetes pod</a>
 - <a href="https://stackoverflow.com/questions/47837008/kubernetes-api-how-to-add-remove-label-from-node">Kubernetes API: How to add/remove label from Node</a>
- <a href="https://stackoverflow.com/questions/55901432/how-to-remove-a-node-label-with-kubernetes-api">How to remove a node label with kubernetes API</a></p>

<p>Also here is an example how using a <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">Kubernetes Python Client</a> you could patch the label:</p>

<pre><code>from pprint import pprint
from kubernetes import client, config

config.load_kube_config()
client.configuration.debug = True

api_instance = client.CoreV1Api()

body = {
    "metadata": {
        "labels": {
            "label-name": None}
        }
}

api_response = api_instance.patch_node("minikube", body)

print(api_response)
</code></pre>
