1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl label - Update the labels on a resource
10
11
12

SYNOPSIS

14       kubectl label [OPTIONS]
15
16
17

DESCRIPTION

19       Update the labels on a resource.
20
21
22              • A  label key and value must begin with a letter or number, and
23                may contain letters, numbers, hyphens, dots, and  underscores,
24                up to  63 characters each.
25
26              • Optionally,  the key can begin with a DNS subdomain prefix and
27                a single '/', like example.com/my-app
28
29              • If --overwrite is true, then existing labels can be  overwrit‐
30                ten,  otherwise attempting to overwrite a label will result in
31                an error.
32
33              • If --resource-version is specified, then updates will use this
34                resource version, otherwise the existing resource-version will
35                be used.
36
37
38
39

OPTIONS

41       --all=false      Select all resources, including uninitialized ones, in
42       the namespace of the specified resource types
43
44
45       --allow-missing-template-keys=true       If  true, ignore any errors in
46       templates when a field or map key is missing in the template. Only  ap‐
47       plies to golang and jsonpath output formats.
48
49
50       --dry-run="none"       Must be "none", "server", or "client". If client
51       strategy, only print the object that would be sent, without sending it.
52       If  server  strategy, submit server-side request without persisting the
53       resource.
54
55
56       --field-manager="kubectl-label"      Name of the manager used to  track
57       field ownership.
58
59
60       --field-selector=""       Selector (field query) to filter on, supports
61       '=', '==', and  '!='.(e.g.  --field-selector  key1=value1,key2=value2).
62       The server only supports a limited number of field queries per type.
63
64
65       -f, --filename=[]      Filename, directory, or URL to files identifying
66       the resource to update the labels
67
68
69       -k, --kustomize=""      Process the kustomization directory. This  flag
70       can't be used together with -f or -R.
71
72
73       --list=false      If true, display the labels for a given resource.
74
75
76       --local=false       If  true, label will NOT contact api-server but run
77       locally.
78
79
80       -o, --output=""       Output  format.  One  of:  json|yaml|name|go-tem‐
81       plate|go-template-file|template|templatefile|jsonpath|json‐
82       path-as-json|jsonpath-file.
83
84
85       --overwrite=false      If true, allow labels to be overwritten,  other‐
86       wise reject label updates that overwrite existing labels.
87
88
89       --record=false       Record current kubectl command in the resource an‐
90       notation. If set to false, do not record the command. If set  to  true,
91       record  the command. If not set, default to updating the existing anno‐
92       tation value only if one already exists.
93
94
95       -R, --recursive=false      Process the directory used in -f, --filename
96       recursively. Useful when you want to manage related manifests organized
97       within the same directory.
98
99
100       --resource-version=""      If non-empty, the labels  update  will  only
101       succeed  if  this  is the current resource-version for the object. Only
102       valid when specifying a single resource.
103
104
105       -l, --selector=""      Selector (label query) to filter on, not includ‐
106       ing   uninitialized   ones,  supports  '=',  '==',  and  '!='.(e.g.  -l
107       key1=value1,key2=value2).
108
109
110       --template=""      Template string or path to template file to use when
111       -o=go-template, -o=go-template-file. The template format is golang tem‐
112       plates [http://golang.org/pkg/text/template/#pkg-overview].
113
114
115

OPTIONS INHERITED FROM PARENT COMMANDS

117       --add-dir-header=false      If true, adds the  file  directory  to  the
118       header of the log messages
119
120
121       --alsologtostderr=false      log to standard error as well as files
122
123
124       --application-metrics-count-limit=100       Max  number  of application
125       metrics to store (per container)
126
127
128       --as=""      Username to impersonate for the operation
129
130
131       --as-group=[]      Group to impersonate for the  operation,  this  flag
132       can be repeated to specify multiple groups.
133
134
135       --azure-container-registry-config=""       Path  to the file containing
136       Azure container registry configuration information.
137
138
139       --boot-id-file="/proc/sys/kernel/random/boot_id"        Comma-separated
140       list of files to check for boot-id. Use the first one that exists.
141
142
143       --cache-dir="/builddir/.kube/cache"      Default cache directory
144
145
146       --certificate-authority=""      Path to a cert file for the certificate
147       authority
148
149
150       --client-certificate=""      Path to a client certificate file for TLS
151
152
153       --client-key=""      Path to a client key file for TLS
154
155
156       --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
157            CIDRs  opened  in  GCE  firewall  for  L7 LB traffic proxy  health
158       checks
159
160
161       --cloud-provider-gce-lb-src-cidrs=130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
162            CIDRs  opened  in  GCE  firewall  for  L4 LB traffic proxy  health
163       checks
164
165
166       --cluster=""      The name of the kubeconfig cluster to use
167
168
169       --container-hints="/etc/cadvisor/container_hints.json"      location of
170       the container hints file
171
172
173       --containerd="/run/containerd/containerd.sock"      containerd endpoint
174
175
176       --containerd-namespace="k8s.io"      containerd namespace
177
178
179       --context=""      The name of the kubeconfig context to use
180
181
182       --default-not-ready-toleration-seconds=300       Indicates  the tolera‐
183       tionSeconds of the toleration for notReady:NoExecute that is  added  by
184       default to every pod that does not already have such a toleration.
185
186
187       --default-unreachable-toleration-seconds=300      Indicates the tolera‐
188       tionSeconds of the toleration for unreachable:NoExecute that  is  added
189       by default to every pod that does not already have such a toleration.
190
191
192       --disable-root-cgroup-stats=false       Disable  collecting root Cgroup
193       stats
194
195
196       --docker="unix:///var/run/docker.sock"      docker endpoint
197
198
199       --docker-env-metadata-whitelist=""      a comma-separated list of envi‐
200       ronment  variable  keys  matched with specified prefix that needs to be
201       collected for docker containers
202
203
204       --docker-only=false      Only report docker containers in  addition  to
205       root stats
206
207
208       --docker-root="/var/lib/docker"       DEPRECATED:  docker  root is read
209       from docker info (this is a fallback, default: /var/lib/docker)
210
211
212       --docker-tls=false      use TLS to connect to docker
213
214
215       --docker-tls-ca="ca.pem"      path to trusted CA
216
217
218       --docker-tls-cert="cert.pem"      path to client certificate
219
220
221       --docker-tls-key="key.pem"      path to private key
222
223
224       --enable-load-reader=false      Whether to enable cpu load reader
225
226
227       --event-storage-age-limit="default=0"      Max length of time for which
228       to store events (per type). Value is a comma separated list of key val‐
229       ues, where the keys are event types (e.g.: creation, oom) or  "default"
230       and  the  value  is a duration. Default is applied to all non-specified
231       event types
232
233
234       --event-storage-event-limit="default=0"      Max number  of  events  to
235       store  (per type). Value is a comma separated list of key values, where
236       the keys are event types (e.g.: creation, oom)  or  "default"  and  the
237       value  is  an  integer.  Default  is applied to all non-specified event
238       types
239
240
241       --global-housekeeping-interval=1m0s      Interval between global house‐
242       keepings
243
244
245       --housekeeping-interval=10s       Interval between container housekeep‐
246       ings
247
248
249       --insecure-skip-tls-verify=false      If true, the server's certificate
250       will not be checked for validity. This will make your HTTPS connections
251       insecure
252
253
254       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
255       quests.
256
257
258       --log-backtrace-at=:0       when logging hits line file:N, emit a stack
259       trace
260
261
262       --log-cadvisor-usage=false      Whether to log the usage of the  cAdvi‐
263       sor container
264
265
266       --log-dir=""      If non-empty, write log files in this directory
267
268
269       --log-file=""      If non-empty, use this log file
270
271
272       --log-file-max-size=1800       Defines  the maximum size a log file can
273       grow to. Unit is megabytes. If the value is 0, the maximum file size is
274       unlimited.
275
276
277       --log-flush-frequency=5s       Maximum  number  of  seconds between log
278       flushes
279
280
281       --logtostderr=true      log to standard error instead of files
282
283
284       --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
285            Comma-separated  list  of  files  to check for machine-id. Use the
286       first one that exists.
287
288
289       --match-server-version=false       Require  server  version  to   match
290       client version
291
292
293       -n,  --namespace=""       If  present, the namespace scope for this CLI
294       request
295
296
297       --one-output=false      If true, only write logs to their native sever‐
298       ity level (vs also writing to each lower severity level
299
300
301       --password=""      Password for basic authentication to the API server
302
303
304       --profile="none"         Name   of   profile   to   capture.   One   of
305       (none|cpu|heap|goroutine|threadcreate|block|mutex)
306
307
308       --profile-output="profile.pprof"      Name of the  file  to  write  the
309       profile to
310
311
312       --referenced-reset-interval=0       Reset interval for referenced bytes
313       (container_referenced_bytes metric), number of measurement cycles after
314       which  referenced  bytes  are cleared, if set to 0 referenced bytes are
315       never cleared (default: 0)
316
317
318       --request-timeout="0"      The length of time to wait before giving  up
319       on  a  single  server  request. Non-zero values should contain a corre‐
320       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
321       out requests.
322
323
324       -s, --server=""      The address and port of the Kubernetes API server
325
326
327       --skip-headers=false       If  true,  avoid  header prefixes in the log
328       messages
329
330
331       --skip-log-headers=false      If true, avoid headers when  opening  log
332       files
333
334
335       --stderrthreshold=2      logs at or above this threshold go to stderr
336
337
338       --storage-driver-buffer-duration=1m0s      Writes in the storage driver
339       will be buffered for this duration, and committed  to  the  non  memory
340       backends as a single transaction
341
342
343       --storage-driver-db="cadvisor"      database name
344
345
346       --storage-driver-host="localhost:8086"      database host:port
347
348
349       --storage-driver-password="root"      database password
350
351
352       --storage-driver-secure=false      use secure connection with database
353
354
355       --storage-driver-table="stats"      table name
356
357
358       --storage-driver-user="root"      database username
359
360
361       --tls-server-name=""       Server  name  to  use for server certificate
362       validation. If it is not provided, the hostname  used  to  contact  the
363       server is used
364
365
366       --token=""      Bearer token for authentication to the API server
367
368
369       --update-machine-info-interval=5m0s       Interval between machine info
370       updates.
371
372
373       --user=""      The name of the kubeconfig user to use
374
375
376       --username=""      Username for basic authentication to the API server
377
378
379       -v, --v=0      number for the log level verbosity
380
381
382       --version=false      Print version information and quit
383
384
385       --vmodule=       comma-separated  list  of   pattern=N   settings   for
386       file-filtered logging
387
388
389       --warnings-as-errors=false      Treat warnings received from the server
390       as errors and exit with a non-zero exit code
391
392
393

EXAMPLE

395                # Update pod 'foo' with the label 'unhealthy' and the value 'true'.
396                kubectl label pods foo unhealthy=true
397
398                # Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value.
399                kubectl label --overwrite pods foo status=unhealthy
400
401                # Update all pods in the namespace
402                kubectl label pods --all status=unhealthy
403
404                # Update a pod identified by the type and name in "pod.json"
405                kubectl label -f pod.json status=unhealthy
406
407                # Update pod 'foo' only if the resource is unchanged from version 1.
408                kubectl label pods foo status=unhealthy --resource-version=1
409
410                # Update pod 'foo' by removing a label named 'bar' if it exists.
411                # Does not require the --overwrite flag.
412                kubectl label pods foo bar-
413
414
415
416

SEE ALSO

418       kubectl(1),
419
420
421

HISTORY

423       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
424       com)  based  on the kubernetes source material, but hopefully they have
425       been automatically generated since!
426
427
428
429Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum