1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl get - Display one or many resources
10
11
12

SYNOPSIS

14       kubectl get [OPTIONS]
15
16
17

DESCRIPTION

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

OPTIONS

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       --show-managed-fields=false      If true, keep the  managedFields  when
123       printing objects in JSON or YAML format.
124
125
126       --sort-by=""      If non-empty, sort list types using this field speci‐
127       fication.  The field specification is expressed as a  JSONPath  expres‐
128       sion (e.g. '{.metadata.name}'). The field in the API resource specified
129       by this JSONPath expression must be an integer or a string.
130
131
132       --template=""      Template string or path to template file to use when
133       -o=go-template, -o=go-template-file. The template format is golang tem‐
134       plates [http://golang.org/pkg/text/template/#pkg-overview].
135
136
137       --use-openapi-print-columns=false        If    true,    use    x-kuber‐
138       netes-print-column  metadata  (if  present) from the OpenAPI schema for
139       displaying a resource.
140
141
142       -w, --watch=false       After  listing/getting  the  requested  object,
143       watch for changes. Uninitialized objects are excluded if no object name
144       is provided.
145
146
147       --watch-only=false      Watch for changes to the  requested  object(s),
148       without listing/getting first.
149
150
151

OPTIONS INHERITED FROM PARENT COMMANDS

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

EXAMPLE

431                # List all pods in ps output format.
432                kubectl get pods
433
434                # List all pods in ps output format with more information (such as node name).
435                kubectl get pods -o wide
436
437                # List a single replication controller with specified NAME in ps output format.
438                kubectl get replicationcontroller web
439
440                # List deployments in JSON output format, in the "v1" version of the "apps" API group:
441                kubectl get deployments.v1.apps -o json
442
443                # List a single pod in JSON output format.
444                kubectl get -o json pod web-pod-13je7
445
446                # List a pod identified by type and name specified in "pod.yaml" in JSON output format.
447                kubectl get -f pod.yaml -o json
448
449                # List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml.
450                kubectl get -k dir/
451
452                # Return only the phase value of the specified pod.
453                kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
454
455                # List resource information in custom columns.
456                kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
457
458                # List all replication controllers and services together in ps output format.
459                kubectl get rc,services
460
461                # List one or more resources by their type and names.
462                kubectl get rc/web service/frontend pods/web-pod-13je7
463
464
465
466

SEE ALSO

468       kubectl(1),
469
470
471

HISTORY

473       January  2015,  Originally compiled by Eric Paris (eparis at redhat dot
474       com) based on the kubernetes source material, but hopefully  they  have
475       been automatically generated since!
476
477
478
479Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum