1KUBERNETES(1)                      Jan 2015                      KUBERNETES(1)
2
3
4

NAME

6       kubectl label - Update the labels on a resource
7
8
9

SYNOPSIS

11       kubectl label [OPTIONS]
12
13
14

DESCRIPTION

16       Update the labels on a resource.
17
18       0
19
20              item  A  label key and value must begin with a letter or number,
21              and may contain letters,  numbers,  hyphens,  dots,  and  under‐
22              scores, up to  63 characters each.  item Optionally, the key can
23              begin with a DNS subdomain prefix and a single '/',  like  exam‐
24              ple.com/my-app item If --overwrite is true, then existing labels
25              can be overwritten, otherwise attempting to  overwrite  a  label
26              will  result  in an error.  item If --resource-version is speci‐
27              fied, then updates will use this resource version, otherwise the
28              existing resource-version will be used.
29
30

OPTIONS

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

OPTIONS INHERITED FROM PARENT COMMANDS

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

EXAMPLE

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

SEE ALSO

429       kubectl(1),
430
431
432

HISTORY

434       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
435       com)  based  on the kubernetes source material, but hopefully they have
436       been automatically generated since!
437
438
439
440Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum