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

OPTIONS INHERITED FROM PARENT COMMANDS

125       --as=""      Username to impersonate for the operation. User could be a
126       regular user or a service account in a namespace.
127
128
129       --as-group=[]       Group  to  impersonate for the operation, this flag
130       can be repeated to specify multiple groups.
131
132
133       --as-uid=""      UID to impersonate for the operation.
134
135
136       --azure-container-registry-config=""      Path to the  file  containing
137       Azure container registry configuration information.
138
139
140       --cache-dir="/builddir/.kube/cache"      Default cache directory
141
142
143       --certificate-authority=""      Path to a cert file for the certificate
144       authority
145
146
147       --client-certificate=""      Path to a client certificate file for TLS
148
149
150       --client-key=""      Path to a client key file for TLS
151
152
153       --cluster=""      The name of the kubeconfig cluster to use
154
155
156       --context=""      The name of the kubeconfig context to use
157
158
159       --insecure-skip-tls-verify=false      If true, the server's certificate
160       will not be checked for validity. This will make your HTTPS connections
161       insecure
162
163
164       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
165       quests.
166
167
168       --match-server-version=false        Require  server  version  to  match
169       client version
170
171
172       -n, --namespace=""      If present, the namespace scope  for  this  CLI
173       request
174
175
176       --password=""      Password for basic authentication to the API server
177
178
179       --profile="none"         Name   of   profile   to   capture.   One   of
180       (none|cpu|heap|goroutine|threadcreate|block|mutex)
181
182
183       --profile-output="profile.pprof"      Name of the  file  to  write  the
184       profile to
185
186
187       --request-timeout="0"       The length of time to wait before giving up
188       on a single server request. Non-zero values  should  contain  a  corre‐
189       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
190       out requests.
191
192
193       -s, --server=""      The address and port of the Kubernetes API server
194
195
196       --tls-server-name=""      Server name to  use  for  server  certificate
197       validation.  If  it  is  not provided, the hostname used to contact the
198       server is used
199
200
201       --token=""      Bearer token for authentication to the API server
202
203
204       --user=""      The name of the kubeconfig user to use
205
206
207       --username=""      Username for basic authentication to the API server
208
209
210       --version=false      Print version information and quit
211
212
213       --warnings-as-errors=false      Treat warnings received from the server
214       as errors and exit with a non-zero exit code
215
216
217

EXAMPLE

219                # Update pod 'foo' with the label 'unhealthy' and the value 'true'
220                kubectl label pods foo unhealthy=true
221
222                # Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value
223                kubectl label --overwrite pods foo status=unhealthy
224
225                # Update all pods in the namespace
226                kubectl label pods --all status=unhealthy
227
228                # Update a pod identified by the type and name in "pod.json"
229                kubectl label -f pod.json status=unhealthy
230
231                # Update pod 'foo' only if the resource is unchanged from version 1
232                kubectl label pods foo status=unhealthy --resource-version=1
233
234                # Update pod 'foo' by removing a label named 'bar' if it exists
235                # Does not require the --overwrite flag
236                kubectl label pods foo bar-
237
238
239
240

SEE ALSO

242       kubectl(1),
243
244
245

HISTORY

247       January  2015,  Originally compiled by Eric Paris (eparis at redhat dot
248       com) based on the kubernetes source material, but hopefully  they  have
249       been automatically generated since!
250
251
252
253Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum