1KUBERNETES(1)(kubernetes) KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7
9 kubectl get - Display one or many resources
10
11
12
14 kubectl get [OPTIONS]
15
16
17
19 Display one or many resources
20
21
22 Prints a table of the most important information about the specified
23 resources. You can filter the list using a label selector and the --se‐
24 lector flag. If the desired resource type is namespaced you will only
25 see results in your current namespace unless you pass --all-namespaces.
26
27
28 Uninitialized objects are not shown unless --include-uninitialized is
29 passed.
30
31
32 By specifying the output as 'template' and providing a Go template as
33 the value of the --template flag, you can filter the attributes of the
34 fetched resources.
35
36
37 Use "kubectl api-resources" for a complete list of supported resources.
38
39
40
42 -A, --all-namespaces=false If present, list the requested ob‐
43 ject(s) across all namespaces. Namespace in current context is ignored
44 even if specified with --namespace.
45
46
47 --allow-missing-template-keys=true If true, ignore any errors in
48 templates when a field or map key is missing in the template. Only ap‐
49 plies to golang and jsonpath output formats.
50
51
52 --chunk-size=500 Return large lists in chunks rather than all at
53 once. Pass 0 to disable. This flag is beta and may change in the fu‐
54 ture.
55
56
57 --field-selector="" Selector (field query) to filter on, supports
58 '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2).
59 The server only supports a limited number of field queries per type.
60
61
62 -f, --filename=[] Filename, directory, or URL to files identifying
63 the resource to get from a server.
64
65
66 --ignore-not-found=false If the requested object does not exist
67 the command will return exit code 0.
68
69
70 -k, --kustomize="" Process the kustomization directory. This flag
71 can't be used together with -f or -R.
72
73
74 -L, --label-columns=[] Accepts a comma separated list of labels
75 that are going to be presented as columns. Names are case-sensitive.
76 You can also use multiple flag options like -L label1 -L label2...
77
78
79 --no-headers=false When using the default or custom-column output
80 format, don't print headers (default print headers).
81
82
83 -o, --output="" Output format. One of: json|yaml|wide|name|cus‐
84 tom-columns=...|custom-columns-file=...|go-template=...|go-tem‐
85 plate-file=...|jsonpath=...|jsonpath-file=... See custom columns
86 [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-col‐
87 umns], golang template [http://golang.org/pkg/text/template/#pkg-over‐
88 view] and jsonpath template [http://kubernetes.io/docs/user-guide/json‐
89 path].
90
91
92 --output-watch-events=false Output watch event objects when
93 --watch or --watch-only is used. Existing objects are output as initial
94 ADDED events.
95
96
97 --raw="" Raw URI to request from the server. Uses the transport
98 specified by the kubeconfig file.
99
100
101 -R, --recursive=false Process the directory used in -f, --filename
102 recursively. Useful when you want to manage related manifests organized
103 within the same directory.
104
105
106 -l, --selector="" Selector (label query) to filter on, supports
107 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
108
109
110 --server-print=true If true, have the server return the appropri‐
111 ate table output. Supports extension APIs and CRDs.
112
113
114 --show-kind=false If present, list the resource type for the re‐
115 quested object(s).
116
117
118 --show-labels=false When printing, show all labels as the last
119 column (default hide labels column)
120
121
122 --sort-by="" If non-empty, sort list types using this field speci‐
123 fication. The field specification is expressed as a JSONPath expres‐
124 sion (e.g. '{.metadata.name}'). The field in the API resource specified
125 by this JSONPath expression must be an integer or a string.
126
127
128 --template="" Template string or path to template file to use when
129 -o=go-template, -o=go-template-file. The template format is golang tem‐
130 plates [http://golang.org/pkg/text/template/#pkg-overview].
131
132
133 --use-openapi-print-columns=false If true, use x-kuber‐
134 netes-print-column metadata (if present) from the OpenAPI schema for
135 displaying a resource.
136
137
138 -w, --watch=false After listing/getting the requested object,
139 watch for changes. Uninitialized objects are excluded if no object name
140 is provided.
141
142
143 --watch-only=false Watch for changes to the requested object(s),
144 without listing/getting first.
145
146
147
149 --add-dir-header=false If true, adds the file directory to the
150 header of the log messages
151
152
153 --alsologtostderr=false log to standard error as well as files
154
155
156 --application-metrics-count-limit=100 Max number of application
157 metrics to store (per container)
158
159
160 --as="" Username to impersonate for the operation
161
162
163 --as-group=[] Group to impersonate for the operation, this flag
164 can be repeated to specify multiple groups.
165
166
167 --azure-container-registry-config="" Path to the file containing
168 Azure container registry configuration information.
169
170
171 --boot-id-file="/proc/sys/kernel/random/boot_id" Comma-separated
172 list of files to check for boot-id. Use the first one that exists.
173
174
175 --cache-dir="/builddir/.kube/cache" Default cache directory
176
177
178 --certificate-authority="" Path to a cert file for the certificate
179 authority
180
181
182 --client-certificate="" Path to a client certificate file for TLS
183
184
185 --client-key="" Path to a client key file for TLS
186
187
188 --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
189 CIDRs opened in GCE firewall for L7 LB traffic proxy health
190 checks
191
192
193 --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
194 CIDRs opened in GCE firewall for L4 LB traffic proxy health
195 checks
196
197
198 --cluster="" The name of the kubeconfig cluster to use
199
200
201 --container-hints="/etc/cadvisor/container_hints.json" location of
202 the container hints file
203
204
205 --containerd="/run/containerd/containerd.sock" containerd endpoint
206
207
208 --containerd-namespace="k8s.io" containerd namespace
209
210
211 --context="" The name of the kubeconfig context to use
212
213
214 --default-not-ready-toleration-seconds=300 Indicates the tolera‐
215 tionSeconds of the toleration for notReady:NoExecute that is added by
216 default to every pod that does not already have such a toleration.
217
218
219 --default-unreachable-toleration-seconds=300 Indicates the tolera‐
220 tionSeconds of the toleration for unreachable:NoExecute that is added
221 by default to every pod that does not already have such a toleration.
222
223
224 --disable-root-cgroup-stats=false Disable collecting root Cgroup
225 stats
226
227
228 --docker="unix:///var/run/docker.sock" docker endpoint
229
230
231 --docker-env-metadata-whitelist="" a comma-separated list of envi‐
232 ronment variable keys matched with specified prefix that needs to be
233 collected for docker containers
234
235
236 --docker-only=false Only report docker containers in addition to
237 root stats
238
239
240 --docker-root="/var/lib/docker" DEPRECATED: docker root is read
241 from docker info (this is a fallback, default: /var/lib/docker)
242
243
244 --docker-tls=false use TLS to connect to docker
245
246
247 --docker-tls-ca="ca.pem" path to trusted CA
248
249
250 --docker-tls-cert="cert.pem" path to client certificate
251
252
253 --docker-tls-key="key.pem" path to private key
254
255
256 --enable-load-reader=false Whether to enable cpu load reader
257
258
259 --event-storage-age-limit="default=0" Max length of time for which
260 to store events (per type). Value is a comma separated list of key val‐
261 ues, where the keys are event types (e.g.: creation, oom) or "default"
262 and the value is a duration. Default is applied to all non-specified
263 event types
264
265
266 --event-storage-event-limit="default=0" Max number of events to
267 store (per type). Value is a comma separated list of key values, where
268 the keys are event types (e.g.: creation, oom) or "default" and the
269 value is an integer. Default is applied to all non-specified event
270 types
271
272
273 --global-housekeeping-interval=1m0s Interval between global house‐
274 keepings
275
276
277 --housekeeping-interval=10s Interval between container housekeep‐
278 ings
279
280
281 --insecure-skip-tls-verify=false If true, the server's certificate
282 will not be checked for validity. This will make your HTTPS connections
283 insecure
284
285
286 --kubeconfig="" Path to the kubeconfig file to use for CLI re‐
287 quests.
288
289
290 --log-backtrace-at=:0 when logging hits line file:N, emit a stack
291 trace
292
293
294 --log-cadvisor-usage=false Whether to log the usage of the cAdvi‐
295 sor container
296
297
298 --log-dir="" If non-empty, write log files in this directory
299
300
301 --log-file="" If non-empty, use this log file
302
303
304 --log-file-max-size=1800 Defines the maximum size a log file can
305 grow to. Unit is megabytes. If the value is 0, the maximum file size is
306 unlimited.
307
308
309 --log-flush-frequency=5s Maximum number of seconds between log
310 flushes
311
312
313 --logtostderr=true log to standard error instead of files
314
315
316 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
317 Comma-separated list of files to check for machine-id. Use the
318 first one that exists.
319
320
321 --match-server-version=false Require server version to match
322 client version
323
324
325 -n, --namespace="" If present, the namespace scope for this CLI
326 request
327
328
329 --one-output=false If true, only write logs to their native sever‐
330 ity level (vs also writing to each lower severity level
331
332
333 --password="" Password for basic authentication to the API server
334
335
336 --profile="none" Name of profile to capture. One of
337 (none|cpu|heap|goroutine|threadcreate|block|mutex)
338
339
340 --profile-output="profile.pprof" Name of the file to write the
341 profile to
342
343
344 --referenced-reset-interval=0 Reset interval for referenced bytes
345 (container_referenced_bytes metric), number of measurement cycles after
346 which referenced bytes are cleared, if set to 0 referenced bytes are
347 never cleared (default: 0)
348
349
350 --request-timeout="0" The length of time to wait before giving up
351 on a single server request. Non-zero values should contain a corre‐
352 sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
353 out requests.
354
355
356 -s, --server="" The address and port of the Kubernetes API server
357
358
359 --skip-headers=false If true, avoid header prefixes in the log
360 messages
361
362
363 --skip-log-headers=false If true, avoid headers when opening log
364 files
365
366
367 --stderrthreshold=2 logs at or above this threshold go to stderr
368
369
370 --storage-driver-buffer-duration=1m0s Writes in the storage driver
371 will be buffered for this duration, and committed to the non memory
372 backends as a single transaction
373
374
375 --storage-driver-db="cadvisor" database name
376
377
378 --storage-driver-host="localhost:8086" database host:port
379
380
381 --storage-driver-password="root" database password
382
383
384 --storage-driver-secure=false use secure connection with database
385
386
387 --storage-driver-table="stats" table name
388
389
390 --storage-driver-user="root" database username
391
392
393 --tls-server-name="" Server name to use for server certificate
394 validation. If it is not provided, the hostname used to contact the
395 server is used
396
397
398 --token="" Bearer token for authentication to the API server
399
400
401 --update-machine-info-interval=5m0s Interval between machine info
402 updates.
403
404
405 --user="" The name of the kubeconfig user to use
406
407
408 --username="" Username for basic authentication to the API server
409
410
411 -v, --v=0 number for the log level verbosity
412
413
414 --version=false Print version information and quit
415
416
417 --vmodule= comma-separated list of pattern=N settings for
418 file-filtered logging
419
420
421 --warnings-as-errors=false Treat warnings received from the server
422 as errors and exit with a non-zero exit code
423
424
425
427 # List all pods in ps output format.
428 kubectl get pods
429
430 # List all pods in ps output format with more information (such as node name).
431 kubectl get pods -o wide
432
433 # List a single replication controller with specified NAME in ps output format.
434 kubectl get replicationcontroller web
435
436 # List deployments in JSON output format, in the "v1" version of the "apps" API group:
437 kubectl get deployments.v1.apps -o json
438
439 # List a single pod in JSON output format.
440 kubectl get -o json pod web-pod-13je7
441
442 # List a pod identified by type and name specified in "pod.yaml" in JSON output format.
443 kubectl get -f pod.yaml -o json
444
445 # List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml.
446 kubectl get -k dir/
447
448 # Return only the phase value of the specified pod.
449 kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
450
451 # List resource information in custom columns.
452 kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
453
454 # List all replication controllers and services together in ps output format.
455 kubectl get rc,services
456
457 # List one or more resources by their type and names.
458 kubectl get rc/web service/frontend pods/web-pod-13je7
459
460
461
462
464 kubectl(1),
465
466
467
469 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
470 com) based on the kubernetes source material, but hopefully they have
471 been automatically generated since!
472
473
474
475Manuals User KUBERNETES(1)(kubernetes)