1KUBERNETES(1)(kubernetes) KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7
9 kubectl label - Update the labels on a resource
10
11
12
14 kubectl label [OPTIONS]
15
16
17
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
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
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 --disable-compression=false If true, opt-out of response compres‐
160 sion for all requests to the server
161
162
163 --insecure-skip-tls-verify=false If true, the server's certificate
164 will not be checked for validity. This will make your HTTPS connections
165 insecure
166
167
168 --kubeconfig="" Path to the kubeconfig file to use for CLI re‐
169 quests.
170
171
172 --match-server-version=false Require server version to match
173 client version
174
175
176 -n, --namespace="" If present, the namespace scope for this CLI
177 request
178
179
180 --password="" Password for basic authentication to the API server
181
182
183 --profile="none" Name of profile to capture. One of
184 (none|cpu|heap|goroutine|threadcreate|block|mutex)
185
186
187 --profile-output="profile.pprof" Name of the file to write the
188 profile to
189
190
191 --request-timeout="0" The length of time to wait before giving up
192 on a single server request. Non-zero values should contain a corre‐
193 sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
194 out requests.
195
196
197 -s, --server="" The address and port of the Kubernetes API server
198
199
200 --tls-server-name="" Server name to use for server certificate
201 validation. If it is not provided, the hostname used to contact the
202 server is used
203
204
205 --token="" Bearer token for authentication to the API server
206
207
208 --user="" The name of the kubeconfig user to use
209
210
211 --username="" Username for basic authentication to the API server
212
213
214 --version=false Print version information and quit
215
216
217 --warnings-as-errors=false Treat warnings received from the server
218 as errors and exit with a non-zero exit code
219
220
221
223 # Update pod 'foo' with the label 'unhealthy' and the value 'true'
224 kubectl label pods foo unhealthy=true
225
226 # Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value
227 kubectl label --overwrite pods foo status=unhealthy
228
229 # Update all pods in the namespace
230 kubectl label pods --all status=unhealthy
231
232 # Update a pod identified by the type and name in "pod.json"
233 kubectl label -f pod.json status=unhealthy
234
235 # Update pod 'foo' only if the resource is unchanged from version 1
236 kubectl label pods foo status=unhealthy --resource-version=1
237
238 # Update pod 'foo' by removing a label named 'bar' if it exists
239 # Does not require the --overwrite flag
240 kubectl label pods foo bar-
241
242
243
244
246 kubectl(1),
247
248
249
251 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
252 com) based on the kubernetes source material, but hopefully they have
253 been automatically generated since!
254
255
256
257Manuals User KUBERNETES(1)(kubernetes)