kubectl get pods -n payments -o jsonpath='{.items[*].metadata.name}'Print all pod names in a namespace.
JSONPath recipes, custom output patterns, jq/yq workflows, and Kustomize commands supported by kubectl.
Common JSONPath patterns for kubectl output.
kubectl get pods -n payments -o jsonpath='{.items[*].metadata.name}'Print all pod names in a namespace.
kubectl get pods -n payments -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].image}{"
"}{end}'Print pod names and container images.
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.addresses[?(@.type=="InternalIP")].address}{"
"}{end}'Print node names with internal IPs.
kubectl get svc web -n payments -o jsonpath='{range .spec.ports[*]}{.name}{":"}{.port}{"->"}{.targetPort}{"
"}{end}'Print service port mappings.
kubectl get secret app-secret -n payments -o jsonpath='{.data}'Print the secret data object keys and values.
kubectl get pods -n payments -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.containerStatuses[*].restartCount}{"
"}{end}'Print pod restart counts.
kubectl get ingress -n payments -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.rules[*].host}{"
"}{end}'Print ingress names and hosts.
kubectl get pvc -n data -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.capacity.storage}{"
"}{end}'Print PVC names and bound storage sizes.
Alternative output strategies beyond JSONPath.
Show capacity data in a concise table.
kubectl get nodes -o custom-columns=NAME:.metadata.name,CPU:.status.capacity.cpu,MEM:.status.capacity.memory,EPHEMERAL:.status.capacity.ephemeral-storageShow capacity data in a concise table.
kubectl get pods -n payments -o go-template='{{range .items}}{{.metadata.name}}{{"\t"}}{{.status.phase}}{{"
"}}{{end}}'Render output using Go templates.
kubectl get deployment web -n payments -o json | jqPipe kubectl JSON into jq for flexible filtering.
kubectl get deployment web -n payments -o yaml | yq '.spec.template.spec.containers[].image'Extract YAML fields with yq.
Preview and apply overlays and generated resources.
kubectl kustomize overlays/prodBuild a kustomization without applying it.
kubectl apply -k overlays/prodApply resources from a kustomization directory.
kubectl delete -k overlays/prodDelete resources generated by a kustomization.
kubectl diff -k overlays/prodPreview the changes from a kustomization.
Apply a kustomization and prune matching managed objects.
kubectl apply -k overlays/prod --prune -l app.kubernetes.io/managed-by=kustomizeApply a kustomization and prune matching managed objects.
Generate YAML that can be committed into Kustomize overlays.
kubectl create configmap app-config --from-file=app.env -o yaml --dry-run=clientGenerate YAML that can be committed into Kustomize overlays.