Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to remove the label from the Kubernetes cluster node pool. #1312

Open
ChandanSagar opened this issue Nov 17, 2022 · 2 comments
Open
Labels

Comments

@ChandanSagar
Copy link

Unable to remove the label for the Kubernetes cluster node pool.

For adding a persistent node label to the Kubernetes worker nodes, we need to label the node pool using doctl. Once the label has been added how to remove it?

The documentation says the omitted labels will be removed. But how to remove the last label?

For example, if we use the below command to add 3 labels to the node pool.

doctl kubernetes cluster node-pool update <cluster name> <pool name/id> --label key1=value1,key2=value2,key3=value3

We can remove the label key2=value2,key3=value3 using the below command
doctl kubernetes cluster node-pool update <cluster name> <pool name/id> --label key1=value1

But how to remove key1=value1 label? The below command doesn't work.
doctl kubernetes cluster node-pool update <cluster name> <pool name/id> --label

The label can be removed using the API call but using doctl it seems there isn't a way.

curl -X PUT \                                                                
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{"name": "<node pool name> ","count": 3, "tags":["null"], "labels": {}}' \     
  "https://api.digitalocean.com/v2/kubernetes/clusters/<cluster ID>/node_pools/<node pool id>"
@timoreimann
Copy link
Contributor

timoreimann commented Nov 17, 2022

There is a related CLI flag --taint where we solved this in one particular way. We could copy the pattern for labels.

@timoreimann
Copy link
Contributor

Some extra context: the issue is that we use a map[string]string with an omitempty JSON tag in godo, meaning that an empty label map is not encoded.

A fix that does not involve a breaking change would require something like an extra field and/or a customer json.Marshaler implementation to handle the clear label case (possibly accompanied by a helper method). Details are to be determined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants