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       --show-managed-fields=false      If true, keep the  managedFields  when
111       printing objects in JSON or YAML format.
112
113
114       --template=""      Template string or path to template file to use when
115       -o=go-template, -o=go-template-file. The template format is golang tem‐
116       plates [http://golang.org/pkg/text/template/#pkg-overview].
117
118
119

OPTIONS INHERITED FROM PARENT COMMANDS

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

EXAMPLE

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

SEE ALSO

422       kubectl(1),
423
424
425

HISTORY

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