Output Formatting Speed Drills
Target pace: 2-3 minutes per drill (25 minutes total).
Run these after Lab 4 Part 1, when your kind-ops cluster and ops-lab workload are running.
For each drill: write your command first, run it, and note one quick verification before opening the answer.
After these drills, complete the graded checkpoint in starter/jsonpath-check.txt and validate with:
bash starter/validate-jsonpath-check.sh ./jsonpath-check.txt- List all nodes sorted by creation timestamp.
Answer command
kubectl get nodes --sort-by=.metadata.creationTimestamp- Show only node names and kubelet versions.
Answer command
kubectl get nodes -o custom-columns=NAME:.metadata.name,VERSION:.status.nodeInfo.kubeletVersion- Get all pod names in
ops-labas a space-separated list.
Answer command
kubectl get pods -n ops-lab -o jsonpath='{.items[*].metadata.name}'- Show each pod and the node it runs on in
ops-lab.
Answer command
kubectl get pods -n ops-lab -o custom-columns=POD:.metadata.name,NODE:.spec.nodeName- List pods with restart counts (ascending output; descending is a follow-up challenge).
Answer command
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.containerStatuses[0].restartCount}{"\n"}{end}'- Get the internal IP of all nodes.
Answer command
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}'- Find which node has the most allocatable CPU (start with a custom-columns view).
Answer command
kubectl get nodes -o custom-columns=NAME:.metadata.name,CPU:.status.allocatable.cpu- Get the image used by each container in
ops-lab.
Answer command
kubectl get pods -n ops-lab -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}'- List PVs sorted by capacity.
Answer command
kubectl get pv --sort-by=.spec.capacity.storage- Get service names and ClusterIPs in
ops-lab.
Answer command
kubectl get svc -n ops-lab -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.clusterIP}{"\n"}{end}'