Skip to main content
Calico Open Source 3.33 (latest) documentation

calicoctl label

This section describes the calicoctl label command.

Read the calicoctl command line interface user reference for a full list of calicoctl commands.

note

The available actions for a specific resource type may be limited based on the datastore used for Calico (etcdv3 / Kubernetes API). Please refer to the Resources section for details about each resource type.

Displaying the help text for 'calicoctl label' command​

Run calicoctl label --help to display the following help menu for the command.

Add, update, or remove labels on an existing Calico resource. Set a label with
key=value (add --overwrite to replace an existing value), or remove one by
passing the key with --remove.

Usage:
calicoctl label KIND NAME [key=value | key] [flags]

Examples:
# Add a label to a node.
calicoctl label nodes node1 cluster=frontend

# Overwrite an existing label value.
calicoctl label nodes node1 cluster=backend --overwrite

# Remove a label.
calicoctl label nodes node1 cluster --remove

Flags:
-c, --config string Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")
-h, --help help for label
-n, --namespace string Namespace of the resource.
--overwrite Overwrite the value when the key is already present in labels.
--remove Remove the specified key from labels.

Global Flags:
--allow-version-mismatch Allow client and cluster versions mismatch
--context string The name of the kubeconfig context to use
-l, --log-level string Set the log level (panic, fatal, error, warn, info, debug) (default "panic")

Examples​

  1. Label a node.

    calicoctl label nodes node1 cluster=backend

    Results indicate that label was successfully applied.

    Successfully set label cluster on nodes node1
  2. Label a node and overwrite the original value of key cluster.

    calicoctl label nodes node1 cluster=frontend --overwrite

    Results indicate that label was successfully overwritten.

    Successfully updated label cluster on nodes node1
  3. Remove label with key cluster from the node.

    calicoctl label nodes node1 cluster --remove

    Results indicate that the label was successfully removed.

    Successfully removed label cluster from nodes node1.

Options​

-n, --namespace string Namespace of the resource.
--overwrite Overwrite the value when the key is already present in labels.
--remove Remove the specified key from labels.

General options​

-c, --config string Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")

See also​