kubectl get pods -o jsonpath='{.items[*].metadata.name}'kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.capacity.cpu}{"\n"}{end}'
2. Using Custom Columns
kubectl get pods -o custom-columns=\NAME:.metadata.name,\NODE:.spec.nodeName,\STATUS:.status.phase,\IP:.status.podIP
3. Formatting Output
-o flag
Use
yaml / json
Full spec
wide
Extended columns
name
Only resource names
jsonpath / go-template
Scripted extraction
custom-columns-file
Reusable column spec
4. Using Field Selectors
kubectl get pods --field-selector status.phase=Runningkubectl get events --field-selector type=Warning,involvedObject.kind=Pod
5. Using Label Selectors
kubectl get pods -l 'app=web,tier=frontend'kubectl get pods -l 'env in (prod,stage),!canary'
6. Performing Bulk Operations
kubectl delete pods -l app=tmpkubectl get pods -A -l app=web -o name | xargs -I{} kubectl restart {}kubectl annotate pods --all owner=platform --overwrite
7. Using kubectl patch
kubectl patch deploy web --type=merge -p '{"spec":{"replicas":5}}'kubectl patch deploy web --type=json \ -p '[{"op":"replace","path":"/spec/template/spec/containers/0/image","value":"nginx:1.27"}]'kubectl patch deploy web --type=strategic -p '{"spec":{"template":{"spec":{"containers":[{"name":"web","image":"nginx:1.27"}]}}}}'