KUBERNETES(1)(kubernetes)
β¨ KUBERNETES(1) β bestie edition β¨
okay so you opened the manual for kubectl get (that's section 1 of the kubernetes manual, iykyk) and honestly? you came to the right place. sit down, grab a strawberry π, let's go.
πΈ NAME πΈ
kubectl get β displays one or many resources. that's it, that's the whole vibe. π
π¦ SYNOPSIS π¦
kubectl get [OPTIONS]
π DESCRIPTION π
Display one or many resources.
It prints you a lil table of the most important information about whatever resources you asked for. you can filter that list with a label selector and the --selector flag. and heads up bestie: if the resource type you want is namespaced, you're only gonna see results in the current namespace unless you actually specify a namespace. no cap.
If you set the output to 'template' and hand a Go template over as the value of the --template flag, you can filter the attributes of the fetched resources. yes, you can basically build your own lil view. iconic.
And if you ever need the full list of supported resources? run kubectl api-resources. that's your master list. π
π OPTIONS π
-A,--all-namespaces=falseβ if present, list the requested object(s) across all namespaces. the namespace in the current context gets ignored, even if you specified one with--namespace. she does not care.--allow-missing-template-keys=trueβ if true, ignore any errors in templates when a field or map key is missing in the template. only applies togolangandjsonpathoutput formats.--chunk-size=500β return large lists in chunks rather than all at once. pass0to disable.--field-selector=""β selector (field query) to filter on. supports'=','==', and'!='. e.g.--field-selector key1=value1,key2=value2. the server only supports a limited number of field queries per type, so don't get too wild.-f,--filename=[]β filename, directory, or URL to files identifying the resource to get from a server.--ignore-not-found=falseβ if set to true, suppresses theNotFounderror for specific objects that don't exist. and note: using this flag with commands that query for collections of resources has no effect when no resources are found.-k,--kustomize=""β process the kustomization directory. > this flag can't be used together with-for-R. pick a lane bestie.-L,--label-columns=[]β accepts a comma separated list of labels that are going to be presented as columns. names are case-sensitive. you can also use multiple flag options like-L label1 -L label2... stack 'em.--no-headers=falseβ when using the default or custom-column output format, don't print headers (default does print headers).-o,--output=""β output format. one of: (json,yaml,kyaml,name,go-template,go-template-file,template,templatefile,jsonpath,jsonpath-as-json,jsonpath-file,custom-columns,custom-columns-file,wide). see custom columns [https://kubernetes.io/docs/reference/kubectl/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [https://kubernetes.io/docs/reference/kubectl/jsonpath/].--output-watch-events=falseβ output watch event objects when--watchor--watch-onlyis used. existing objects are output as initialADDEDevents.--raw=""β raw URI to request from the server. uses the transport specified by the kubeconfig file.-R,--recursive=falseβ process the directory used in-f,--filenamerecursively. super useful when you want to manage related manifests organized within the same directory.-l,--selector=""β selector (label query) to filter on. supports'=','==','!=','in','notin'. e.g.-l key1=value1,key2=value2,key3 in (value3). matching objects must satisfy all of the specified label constraints. no partial credit.--server-print=trueβ if true, have the server return the appropriate table output. supports extension APIs and CRDs.--show-kind=falseβ if present, list the resource type for the requested object(s).--show-labels=falseβ when printing, show all labels as the last column (default: hide labels column).--show-managed-fields=falseβ if true, keep themanagedFieldswhen printing objects in JSON or YAML format.--sort-by=""β if non-empty, sort list types using this field specification. the field specification is expressed as a JSONPath expression (e.g.'{.metadata.name}'). the field in the API resource specified by this JSONPath expression must be an integer or a string.--subresource=""β if specified, gets the subresource of the requested object.--template=""β template string or path to template file to use when-o=go-template,-o=go-template-file. the template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].-w,--watch=falseβ after listing/getting the requested object, watch for changes.--watch-only=falseβ watch for changes to the requested object(s), without listing/getting first.
π OPTIONS INHERITED FROM PARENT COMMANDS π
these came from the parent command, so they're giving family reunion energy. π«Ά
--as=""β username to impersonate for the operation. user could be a regular user or a service account in a namespace.--as-group=[]β group to impersonate for the operation. this flag can be repeated to specify multiple groups.--as-uid=""β UID to impersonate for the operation.--as-user-extra=[]β user extras to impersonate for the operation. this flag can be repeated to specify multiple values for the same key.--cache-dir="/home/username/.kube/cache"β default cache directory.--certificate-authority=""β path to a cert file for the certificate authority.--client-certificate=""β path to a client certificate file for TLS.--client-key=""β path to a client key file for TLS.--cluster=""β the name of the kubeconfig cluster to use.--context=""β the name of the kubeconfig context to use.--disable-compression=falseβ if true, opt-out of response compression for all requests to the server.--insecure-skip-tls-verify=falseβ if true, the server's certificate will not be checked for validity. > this will make your HTTPS connections insecure. like, actually insecure. we said it, it's real. β οΈ--kubeconfig=""β path to the kubeconfig file to use for CLI requests.--kuberc=""β path to the kuberc file to use for preferences. this can be disabled by exportingKUBECTL_KUBERC=falsefeature gate or turning off the featureKUBERC=off.--match-server-version=falseβ require server version to match client version.-n,--namespace=""β if present, the namespace scope for this CLI request.--password=""β password for basic authentication to the API server.--profile="none"β name of profile to capture. one of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace).--profile-output="profile.pprof"β name of the file to write the profile to.--proxy-url=""β proxy URL to use for requests to the API server.--request-timeout="0"β the length of time to wait before giving up on a single server request. non-zero values should contain a corresponding time unit (e.g.1s,2m,3h). a value of zero means don't timeout requests.-s,--server=""β the address and port of the Kubernetes API server.--tls-server-name=""β server name to use for server certificate validation. if it is not provided, the hostname used to contact the server is used.--token=""β bearer token for authentication to the API server.--user=""β the name of the kubeconfig user to use.--username=""β username for basic authentication to the API server.--version=falseβ--version,--version=rawprints version information and quits;--version=vX.Y.Z...sets the reported version.--warnings-as-errors=falseβ treat warnings received from the server as errors and exit with a non-zero exit code.
π₯ EXAMPLE π₯
here's the whole lil cookbook, copied exactly because we do not play with commands around here:
# List all pods in ps output format
kubectl get pods
# List all pods in ps output format with more information (such as node name)
kubectl get pods -o wide
# List a single replication controller with specified NAME in ps output format
kubectl get replicationcontroller web
# List deployments in JSON output format, in the "v1" version of the "apps" API group
kubectl get deployments.v1.apps -o json
# List a single pod in JSON output format
kubectl get -o json pod web-pod-13je7
# List a pod identified by type and name specified in "pod.yaml" in JSON output format
kubectl get -f pod.yaml -o json
# List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml
kubectl get -k dir/
# Return only the phase value of the specified pod
kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
# List resource information in custom columns
kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
# List all replication controllers and services together in ps output format
kubectl get rc,services
# List one or more resources by their type and names
kubectl get rc/web service/frontend pods/web-pod-13je7
# List the 'status' subresource for a single pod
kubectl get pod web-pod-13je7 --subresource status
# List all deployments in namespace 'backend'
kubectl get deployments.apps --namespace backend
# List all pods existing in all namespaces
kubectl get pods --all-namespaces
π§ SEE ALSO π§
π HISTORY π
January 2015, originally compiled by Eric Paris (eparis at redhat dot com) based on the kubernetes source material, but hopefully they have been automatically generated since! (we love a glow-up era β¨)
that's the whole page bestie, go forth and get ur resources π
π
source/version + date, since you asked: this is from the Manuals / User collection, page KUBERNETES(1)(kubernetes), dated back to Jan 2015 (and yeah, Eric Paris is the one on the byline at the top too π). byeeee, mwah πΈπ¦
π¦ where this page comes from
- arch rolling: kubectl 1.37.2-1 Β· Apache-2.0
- fedora 43: kubernetes1.37-client 1.37.0-3.fc43
- fedora 43: kubernetes1.37-client 1.37.1-1.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause-HP AND CC-BY-4.0 AND ISC AND MIT AND MPL-2.0
- fedora 44: kubernetes1.37-client 1.37.0-3.fc44
- fedora 44: kubernetes1.37-client 1.37.1-1.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause-HP AND CC-BY-4.0 AND ISC AND MIT AND MPL-2.0
- nixpkgs unstable: kubectl 1.37.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms