kubectl get — getting information about resources.
1# Basic commands2kubectl get pods3kubectl get services4kubectl get deployments5kubectl get nodes6kubectl get namespaces78# Output format9kubectl get pods -o wide # Detailed output10kubectl get pods -o yaml # YAML format11kubectl get pods -o json # JSON format12kubectl get pods -o name # Names only13kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase1415# Filtering16kubectl get pods -l app=myapp # By label17kubectl get pods -l "app in (frontend, backend)"18kubectl get pods --field-selector status.phase=Running19kubectl get pods -n production2021# All namespaces22kubectl get pods -A23kubectl get pods --all-namespaces2425# Watch26kubectl get pods -w27kubectl get pods --watch2829# Watch with filtering30kubectl get pods -l app=myapp -w31kubectl get pods -n production -w32kubectl get pods --field-selector status.phase=Running -w3334# Sorting35kubectl get pods --sort-by=.metadata.creationTimestamp36kubectl get pods --sort-by=.status.startTime37kubectl get pods --sort-by=.status.containerStatuses[0].restartCount3839# All resource types40kubectl api-resources41kubectl api-versions4243# Help44kubectl get --help45kubectl get pods --help
Tips:
-o wide for detailed information.-o yaml for debugging.-w for real-time monitoring.