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       By specifying the output as 'template' and providing a Go  template  as
29       the  value of the --template flag, you can filter the attributes of the
30       fetched resources.
31
32
33       Use "kubectl api-resources" for a complete list of supported resources.
34
35
36

OPTIONS

38       -A, --all-namespaces=false      If  present,  list  the  requested  ob‐
39       ject(s)  across all namespaces. Namespace in current context is ignored
40       even if specified with --namespace.
41
42
43       --allow-missing-template-keys=true      If true, ignore any  errors  in
44       templates  when a field or map key is missing in the template. Only ap‐
45       plies to golang and jsonpath output formats.
46
47
48       --chunk-size=500      Return large lists in chunks rather than  all  at
49       once.  Pass  0  to disable. This flag is beta and may change in the fu‐
50       ture.
51
52
53       --field-selector=""      Selector (field query) to filter on,  supports
54       '=',  '==',  and  '!='.(e.g. --field-selector key1=value1,key2=value2).
55       The server only supports a limited number of field queries per type.
56
57
58       -f, --filename=[]      Filename, directory, or URL to files identifying
59       the resource to get from a server.
60
61
62       --ignore-not-found=false       If  the  requested object does not exist
63       the command will return exit code 0.
64
65
66       -k, --kustomize=""      Process the kustomization directory. This  flag
67       can't be used together with -f or -R.
68
69
70       -L,  --label-columns=[]       Accepts  a comma separated list of labels
71       that are going to be presented as columns.  Names  are  case-sensitive.
72       You can also use multiple flag options like -L label1 -L label2...
73
74
75       --no-headers=false       When using the default or custom-column output
76       format, don't print headers (default print headers).
77
78
79       -o, --output=""      Output format. One of: (json, yaml, name,  go-tem‐
80       plate, go-template-file, template, templatefile, jsonpath, jsonpath-as-
81       json, jsonpath-file, custom-columns,  custom-columns-file,  wide).  See
82       custom  columns  [https://kubernetes.io/docs/reference/kubectl/#custom-
83       columns],  golang  template  [http://golang.org/pkg/text/template/#pkg-
84       overview]   and  jsonpath  template  [https://kubernetes.io/docs/refer
85       ence/kubectl/jsonpath/].
86
87
88       --output-watch-events=false       Output  watch  event   objects   when
89       --watch or --watch-only is used. Existing objects are output as initial
90       ADDED events.
91
92
93       --raw=""      Raw URI to request from the server.  Uses  the  transport
94       specified by the kubeconfig file.
95
96
97       -R, --recursive=false      Process the directory used in -f, --filename
98       recursively. Useful when you want to manage related manifests organized
99       within the same directory.
100
101
102       -l,  --selector=""       Selector  (label query) to filter on, supports
103       '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Matching objects
104       must satisfy all of the specified label constraints.
105
106
107       --server-print=true       If true, have the server return the appropri‐
108       ate table output. Supports extension APIs and CRDs.
109
110
111       --show-kind=false      If present, list the resource type for  the  re‐
112       quested object(s).
113
114
115       --show-labels=false       When  printing,  show  all labels as the last
116       column (default hide labels column)
117
118
119       --show-managed-fields=false      If true, keep the  managedFields  when
120       printing objects in JSON or YAML format.
121
122
123       --sort-by=""      If non-empty, sort list types using this field speci‐
124       fication.  The field specification is expressed as a  JSONPath  expres‐
125       sion (e.g. '{.metadata.name}'). The field in the API resource specified
126       by this JSONPath expression must be an integer or a string.
127
128
129       --subresource=""      If specified, gets the  subresource  of  the  re‐
130       quested  object.  Must  be one of [status scale]. This flag is beta and
131       may change in the future.
132
133
134       --template=""      Template string or path to template file to use when
135       -o=go-template, -o=go-template-file. The template format is golang tem‐
136       plates [http://golang.org/pkg/text/template/#pkg-overview].
137
138
139       -w, --watch=false       After  listing/getting  the  requested  object,
140       watch for changes.
141
142
143       --watch-only=false       Watch  for changes to the requested object(s),
144       without listing/getting first.
145
146
147

OPTIONS INHERITED FROM PARENT COMMANDS

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

EXAMPLE

247                # List all pods in ps output format
248                kubectl get pods
249
250                # List all pods in ps output format with more information (such as node name)
251                kubectl get pods -o wide
252
253                # List a single replication controller with specified NAME in ps output format
254                kubectl get replicationcontroller web
255
256                # List deployments in JSON output format, in the "v1" version of the "apps" API group
257                kubectl get deployments.v1.apps -o json
258
259                # List a single pod in JSON output format
260                kubectl get -o json pod web-pod-13je7
261
262                # List a pod identified by type and name specified in "pod.yaml" in JSON output format
263                kubectl get -f pod.yaml -o json
264
265                # List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml
266                kubectl get -k dir/
267
268                # Return only the phase value of the specified pod
269                kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
270
271                # List resource information in custom columns
272                kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
273
274                # List all replication controllers and services together in ps output format
275                kubectl get rc,services
276
277                # List one or more resources by their type and names
278                kubectl get rc/web service/frontend pods/web-pod-13je7
279
280                # List status subresource for a single pod.
281                kubectl get pod web-pod-13je7 --subresource status
282
283
284
285

SEE ALSO

287       kubectl(1),
288
289
290

HISTORY

292       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
293       com)  based  on the kubernetes source material, but hopefully they have
294       been automatically generated since!
295
296
297
298Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum