kubectl get
and
Syntax
kubectl get <resource> [name] [flags]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
-o wide |
(IP, and more) | kubectl get pods -o wide |
Common |
-o yaml |
YAML | kubectl get pod nginx -o yaml |
Common |
-o json |
JSON | kubectl get svc -o json |
Common |
-n --namespace |
kubectl get pods -n kube-system |
Common | |
-A --all-namespaces |
kubectl get pods -A |
Common | |
-l --selector |
kubectl get pods -l app=nginx |
Common | |
-w --watch |
kubectl get pods -w |
Advanced |
Examples
Pod
kubectl get pods
Pod
Pod
kubectl get pods -A
Pod
kubectl get nodes -o wide
IP, and more
kubectl get pods -l app=web,env=prod
kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase
Common Errors
No resources found in default namespace, -A Parameters
the server doesn't have a resource type, kubectl api-resources
Tips
- kubectl get all, ConfigMap, Secret and more
- -w Parameters Pod,