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

OPTIONS

38       --all=false
39           Select all resources, including uninitialized ones, in the
40       namespace of the specified resource types
41
42
43       --allow-missing-template-keys=true
44           If true, ignore any errors in templates when a field or map key is
45       missing in the template. Only applies to golang and jsonpath output
46       formats.
47
48
49       --dry-run="none"
50           Must be "none", "server", or "client". If client strategy, only
51       print the object that would be sent, without sending it. If server
52       strategy, submit server-side request without persisting the resource.
53
54
55       --field-selector=""
56           Selector (field query) to filter on, supports '=', '==', and
57       '!='.(e.g. --field-selector key1=value1,key2=value2). The server only
58       supports a limited number of field queries per type.
59
60
61       -f, --filename=[]
62           Filename, directory, or URL to files identifying the resource to
63       update the labels
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:
81       json|yaml|name|go-template|go-template-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
92       command. 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
115       -o=go-template, -o=go-template-file. The template format is golang
116       templates [ ⟨http://golang.org/pkg/text/template/#pkg-overview⟩].
117
118
119

OPTIONS INHERITED FROM PARENT COMMANDS

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

EXAMPLE

423                # Update pod 'foo' with the label 'unhealthy' and the value 'true'.
424                kubectl label pods foo unhealthy=true
425
426                # Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value.
427                kubectl label --overwrite pods foo status=unhealthy
428
429                # Update all pods in the namespace
430                kubectl label pods --all status=unhealthy
431
432                # Update a pod identified by the type and name in "pod.json"
433                kubectl label -f pod.json status=unhealthy
434
435                # Update pod 'foo' only if the resource is unchanged from version 1.
436                kubectl label pods foo status=unhealthy --resource-version=1
437
438                # Update pod 'foo' by removing a label named 'bar' if it exists.
439                # Does not require the --overwrite flag.
440                kubectl label pods foo bar-
441
442
443
444

SEE ALSO

446       kubectl(1),
447
448
449

HISTORY

451       January 2015, Originally compiled by Eric Paris (eparis at redhat dot
452       com) based on the kubernetes source material, but hopefully they have
453       been automatically generated since!
454
455
456
457Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum