1"use strict";(self.webpackChunktigera_docs=self.webpackChunktigera_docs||[]).push([["348"],{43878:function(e,n,l){l.r(n),l.d(n,{frontMatter:()=>r,toc:()=>s,default:()=>h,metadata:()=>o,assets:()=>a,contentTitle:()=>i});var o=JSON.parse('{"id":"reference/calicoctl/label","title":"calicoctl label","description":"Command to change labels for workload endpoints or nodes.","source":"@site/calico_versioned_docs/version-3.28/reference/calicoctl/label.mdx","sourceDirName":"reference/calicoctl","slug":"/reference/calicoctl/label","permalink":"/calico/3.28/reference/calicoctl/label","draft":false,"unlisted":false,"editUrl":"https://github.com/tigera/docs/edit/main/calico_versioned_docs/version-3.28/reference/calicoctl/label.mdx","tags":[],"version":"3.28","frontMatter":{"description":"Command to change labels for workload endpoints or nodes."},"sidebar":"calicoSidebar","previous":{"title":"calicoctl patch","permalink":"/calico/3.28/reference/calicoctl/patch"},"next":{"title":"calicoctl convert","permalink":"/calico/3.28/reference/calicoctl/convert"}}'),c=l(37937),t=l(17869);let r={description:"Command to change labels for workload endpoints or nodes."},i="calicoctl label",a={},s=[{value:"Displaying the help text for 'calicoctl label' command",id:"displaying-the-help-text-for-calicoctl-label-command",level:2},{value:"Examples",id:"examples",level:3},{value:"Options",id:"options",level:3},{value:"General options",id:"general-options",level:3},{value:"See also",id:"see-also",level:2}];function d(e){let n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,t.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n.header,{children:(0,c.jsx)(n.h1,{id:"calicoctl-label",children:"calicoctl label"})}),"\n",(0,c.jsxs)(n.p,{children:["This section describes the ",(0,c.jsx)(n.code,{children:"calicoctl label"})," command."]}),"\n",(0,c.jsxs)(n.p,{children:["Read the ",(0,c.jsx)(n.a,{href:"/calico/3.28/reference/calicoctl/overview",children:"calicoctl command line interface user reference"}),"\nfor a full list of calicoctl commands."]}),"\n",(0,c.jsx)(n.admonition,{type:"note",children:(0,c.jsxs)(n.p,{children:["The available actions for a specific resource type may be\nlimited based on the datastore used for Calico (etcdv3 / Kubernetes API).\nPlease refer to the\n",(0,c.jsx)(n.a,{href:"/calico/3.28/reference/resources/overview",children:"Resources section"}),"\nfor details about each resource type."]})}),"\n",(0,c.jsx)(n.h2,{id:"displaying-the-help-text-for-calicoctl-label-command",children:"Displaying the help text for 'calicoctl label' command"}),"\n",(0,c.jsxs)(n.p,{children:["Run ",(0,c.jsx)(n.code,{children:"calicoctl label --help"})," to display the following help menu for the\ncommand."]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{children:"Usage:\n calicoctl label (<KIND> <NAME>\n ( <key>=<value> [--overwrite] |\n <key> --remove )\n [--config=<CONFIG>] [--namespace=<NS>])\n\nExamples:\n # Label a workload endpoint\n calicoctl label workloadendpoints nginx --namespace=default app=web\n\n # Label a node and overwrite the original value of key 'cluster'\n calicoctl label nodes node1 cluster=frontend --overwrite\n\n # Remove label with key 'cluster' of the node\n calicoctl label nodes node1 cluster --remove\n\nOptions:\n -h --help Show this screen.\n -c --config=<CONFIG> Path to the file containing connection\n configuration in YAML or JSON format.\n [default: /etc/calico/calicoctl.cfg]\n -n --namespace=<NS> Namespace of the resource.\n Only applicable to NetworkPolicy, NetworkSet, and WorkloadEndpoint.\n Uses the default namespace if not specified.\n --overwrite If true, overwrite the value when the key is already\n present in labels. Otherwise reports error when the\n labeled resource already have the key in its labels.\n Can not be used with --remove.\n --remove If true, remove the specified key in labels of the\n resource. Reports error when specified key does not\n exist. Can not be used with --overwrite.\n --context=<context> The name of the kubeconfig context to use.\n\nDescription:\n The label command is used to add or update a label on a resource. Resource types\n that can be labeled are:\n\n * bgpConfiguration\n * bgpPeer\n * felixConfiguration\n * globalNetworkPolicy\n * globalNetworkSet\n * hostEndpoint\n * ipPool\n * networkPolicy\n * networkSet\n * node\n * profile\n * workloadEndpoint\n\n The resource type is case-insensitive and may be pluralized.\n\n Attempting to label resources that do not exist will get an error.\n\n Attempting to remove a label that does not exist in the resource will get an error.\n\n When labeling a resource on an existing key:\n - gets an error if option --overwrite is not provided.\n - value of the key updates to specified value if option --overwrite is provided.\n"})}),"\n",(0,c.jsx)(n.h3,{id:"examples",children:"Examples"}),"\n",(0,c.jsxs)(n.ol,{children:["\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsx)(n.p,{children:"Label a node."}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-bash",children:"calicoctl label nodes node1 cluster
1=backend\n"})}),"\n",(0,c.jsx)(n.p,{children:"Results indicate that label was successfully applied."}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{children:"Successfully set label cluster on nodes node1\n"})}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:["Label a node and overwrite the original value of key ",(0,c.jsx)(n.code,{children:"cluster"}),"."]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-bash",children:"calicoctl label nodes node1 cluster=frontend --overwrite\n"})}),"\n",(0,c.jsx)(n.p,{children:"Results indicate that label was successfully overwritten."}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{children:"Successfully updated label cluster on nodes node1\n"})}),"\n"]}),"\n",(0,c.jsxs)(n.li,{children:["\n",(0,c.jsxs)(n.p,{children:["Remove label with key ",(0,c.jsx)(n.code,{children:"cluster"})," from the node."]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-bash",children:"calicoctl label nodes node1 cluster --remove\n"})}),"\n",(0,c.jsx)(n.p,{children:"Results indicate that the label was successfully removed."}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{children:"Successfully removed label cluster from nodes node1.\n"})}),"\n"]}),"\n"]}),"\n",(0,c.jsx)(n.h3,{id:"options",children:"Options"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{children:" -n --namespace=<NS> Namespace of the resource.\n Only applicable to NetworkPolicy and WorkloadEndpoint.\n Uses the default namespace if not specified.\n --overwrite If true, overwrite the value when the key is already\n present in labels. Otherwise reports error when the\n labeled resource already have the key in its labels.\n Can not be used with --remove.\n --remove If true, remove the specified key in labels of the\n resource. Reports error when specified key does not\n exist. Can not be used with --overwrite.\n"})}),"\n",(0,c.jsx)(n.h3,{id:"general-options",children:"General options"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{children:" -c --config=<CONFIG> Path to the file containing connection\n configuration in YAML or JSON format.\n [default: /etc/calico/calicoctl.cfg]\n"})}),"\n",(0,c.jsx)(n.h2,{id:"see-also",children:"See also"}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:(0,c.jsx)(n.a,{href:"/calico/3.28/operations/calicoctl/install",children:"Installing calicoctl"})}),"\n",(0,c.jsxs)(n.li,{children:[(0,c.jsx)(n.a,{href:"/calico/3.28/reference/resources/overview",children:"Resources"})," for details on all valid resources, including file format\nand schema"]}),"\n"]})]})}function h(e={}){let{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(d,{...e})}):d(e)}},17869:function(e,n,l){l.d(n,{R:()=>r,x:()=>i});var o=l(82645);let c={},t=o.createContext(c);function r(e){let n=o.useContext(t);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:r(e.components),o.createElement(t.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.