Skip to content

Kubectl delete label support #2422

@Mert18

Description

@Mert18

Describe the bug
Kubectl.label() does not have a delete option as far as I have seen. Normally in k8s, a label can be deleted via CLI by putting "-" at the end of the label.

Ex:
kubectl label node <nodename> <labelname>=labelvalue adds the label, and
kubectl label node <nodename> <labelname>- deletes the label

But in Kubectl.label() function cannot have "-" at the end of the label name due to some restrictions. Can it be achieved?

By the way, I found a getaround with the jsonpatches and created a patch to the resource in order to achieve this functionality:

String patchString = "[{ \"op\": \"remove\", \"path\": \"/labelpath\" }]";
                V1Patch patch = new V1Patch(patchString);
                Kubectl.patch(V1Node.class).apiClient(apiClient).name(nodeName).patchContent(patch).execute();

Metadata

Metadata

Assignees

Labels

good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions