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 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
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 alpha 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 --use-openapi-print-columns=false If true, use x-kubernetes-print-
140 column metadata (if present) from the OpenAPI schema for displaying a
141 resource.
142
143
144 -w, --watch=false After listing/getting the requested object,
145 watch for changes.
146
147
148 --watch-only=false Watch for changes to the requested object(s),
149 without listing/getting first.
150
151
152
154 --as="" Username to impersonate for the operation. User could be a
155 regular user or a service account in a namespace.
156
157
158 --as-group=[] Group to impersonate for the operation, this flag
159 can be repeated to specify multiple groups.
160
161
162 --as-uid="" UID to impersonate for the operation.
163
164
165 --azure-container-registry-config="" Path to the file containing
166 Azure container registry configuration information.
167
168
169 --cache-dir="/builddir/.kube/cache" Default cache directory
170
171
172 --certificate-authority="" Path to a cert file for the certificate
173 authority
174
175
176 --client-certificate="" Path to a client certificate file for TLS
177
178
179 --client-key="" Path to a client key file for TLS
180
181
182 --cluster="" The name of the kubeconfig cluster to use
183
184
185 --context="" The name of the kubeconfig context to use
186
187
188 --disable-compression=false If true, opt-out of response compres‐
189 sion for all requests to the server
190
191
192 --insecure-skip-tls-verify=false If true, the server's certificate
193 will not be checked for validity. This will make your HTTPS connections
194 insecure
195
196
197 --kubeconfig="" Path to the kubeconfig file to use for CLI re‐
198 quests.
199
200
201 --match-server-version=false Require server version to match
202 client version
203
204
205 -n, --namespace="" If present, the namespace scope for this CLI
206 request
207
208
209 --password="" Password for basic authentication to the API server
210
211
212 --profile="none" Name of profile to capture. One of
213 (none|cpu|heap|goroutine|threadcreate|block|mutex)
214
215
216 --profile-output="profile.pprof" Name of the file to write the
217 profile to
218
219
220 --request-timeout="0" The length of time to wait before giving up
221 on a single server request. Non-zero values should contain a corre‐
222 sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
223 out requests.
224
225
226 -s, --server="" The address and port of the Kubernetes API server
227
228
229 --tls-server-name="" Server name to use for server certificate
230 validation. If it is not provided, the hostname used to contact the
231 server is used
232
233
234 --token="" Bearer token for authentication to the API server
235
236
237 --user="" The name of the kubeconfig user to use
238
239
240 --username="" Username for basic authentication to the API server
241
242
243 --version=false Print version information and quit
244
245
246 --warnings-as-errors=false Treat warnings received from the server
247 as errors and exit with a non-zero exit code
248
249
250
252 # List all pods in ps output format
253 kubectl get pods
254
255 # List all pods in ps output format with more information (such as node name)
256 kubectl get pods -o wide
257
258 # List a single replication controller with specified NAME in ps output format
259 kubectl get replicationcontroller web
260
261 # List deployments in JSON output format, in the "v1" version of the "apps" API group
262 kubectl get deployments.v1.apps -o json
263
264 # List a single pod in JSON output format
265 kubectl get -o json pod web-pod-13je7
266
267 # List a pod identified by type and name specified in "pod.yaml" in JSON output format
268 kubectl get -f pod.yaml -o json
269
270 # List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml
271 kubectl get -k dir/
272
273 # Return only the phase value of the specified pod
274 kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
275
276 # List resource information in custom columns
277 kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
278
279 # List all replication controllers and services together in ps output format
280 kubectl get rc,services
281
282 # List one or more resources by their type and names
283 kubectl get rc/web service/frontend pods/web-pod-13je7
284
285 # List status subresource for a single pod.
286 kubectl get pod web-pod-13je7 --subresource status
287
288
289
290
292 kubectl(1),
293
294
295
297 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
298 com) based on the kubernetes source material, but hopefully they have
299 been automatically generated since!
300
301
302
303Manuals User KUBERNETES(1)(kubernetes)