2020-10-05 08:08:22 -07:00
|
|
|
# kubectl get
|
|
|
|
|
|
|
|
> Get Kubernetes objects and resources.
|
|
|
|
> More information: <https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#get>.
|
|
|
|
|
|
|
|
- Get all namespaces in the current cluster:
|
|
|
|
|
2025-08-11 15:39:48 +03:00
|
|
|
`kubectl get {{[ns|namespaces]}}`
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Get nodes in a specified namespace:
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-08-11 15:39:48 +03:00
|
|
|
`kubectl get {{[no|nodes]}} {{[-n|--namespace]}} {{namespace}}`
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Get pods in a specified namespace:
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-08-11 15:39:48 +03:00
|
|
|
`kubectl get {{[po|pods]}} {{[-n|--namespace]}} {{namespace}}`
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Get deployments in a specified namespace:
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-08-11 15:39:48 +03:00
|
|
|
`kubectl get {{[deploy|deployments]}} {{[-n|--namespace]}} {{namespace}}`
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Get services in a specified namespace:
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-08-11 15:39:48 +03:00
|
|
|
`kubectl get {{[svc|services]}} {{[-n|--namespace]}} {{namespace}}`
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-08-11 15:39:48 +03:00
|
|
|
- Get other resources:
|
2021-10-23 19:20:43 -07:00
|
|
|
|
2025-08-13 22:32:02 +03:00
|
|
|
`kubectl get {{persistentvolumeclaims|secret|...}}`
|
2025-08-11 15:39:48 +03:00
|
|
|
|
|
|
|
- Get all resources in all namespaces:
|
|
|
|
|
|
|
|
`kubectl get all {{[-A|--all-namespaces]}}`
|
2021-10-23 19:20:43 -07:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Get Kubernetes objects defined in a YAML manifest file:
|
2020-10-05 08:08:22 -07:00
|
|
|
|
2025-08-07 01:16:37 -07:00
|
|
|
`kubectl get {{[-f|--filename]}} {{path/to/manifest.yaml}}`
|