drill
kubectl Drill Answers
Drill 1
kubectl get pods -n grokdevops
Look for STATUS != Running or READY showing 0/1.
Drill 2
kubectl logs -n grokdevops deploy/grokdevops --previous
The --previous flag shows logs from the last terminated container instance.
Drill 3
kubectl describe pod -n grokdevops -l app.kubernetes.io/name= grokdevops | grep -A 20 Events
Events show recent scheduling, pulling, probe, and container state changes.
Drill 4
kubectl get deploy grokdevops -n grokdevops \
-o jsonpath = '{.spec.template.spec.containers[0].readinessProbe}' | python3 -m json.tool
Shows httpGet path, port, and timing parameters.
Drill 5
kubectl get hpa -n grokdevops
kubectl describe hpa grokdevops -n grokdevops
Key fields: TARGETS (current%/target%), MINPODS, MAXPODS, REPLICAS.
Drill 6
kubectl top pods -n grokdevops --sort-by= cpu
Requires metrics-server to be running. Shows CPU(cores) and MEMORY(bytes).
Drill 7
kubectl get endpoints grokdevops -n grokdevops
If ENDPOINTS is <none>, no pods match the service selector.
Drill 8
kubectl rollout status deployment/grokdevops -n grokdevops --timeout= 30s
Returns exit code 1 if rollout doesn't complete within the timeout.
Drill 9
kubectl rollout history deployment/grokdevops -n grokdevops
Shows REVISION numbers and CHANGE-CAUSE annotations.
Drill 10
kubectl run dns-test --rm -it --restart= Never --image= busybox:1.36 -- \
nslookup grokdevops.grokdevops.svc.cluster.local
Expected: returns the ClusterIP address of the service.
Drill 11
kubectl get deploy grokdevops -n grokdevops \
-o jsonpath = '{.spec.template.spec.containers[0].resources}' | python3 -m json.tool
Shows requests and limits for cpu and memory.
Drill 12
kubectl get pods -n grokdevops -o json | \
python3 -c "import sys,json; pods=json.load(sys.stdin)['items']; [print(p['metadata']['name']) for p in pods for cs in p.get('status',{}).get('containerStatuses',[]) if cs.get('lastState',{}).get('terminated',{}).get('reason')=='OOMKilled']"
Or simpler: kubectl describe pods -n grokdevops | grep -B5 OOMKilled
Drill 13
kubectl get networkpolicy -n grokdevops
kubectl describe networkpolicy -n grokdevops
Check podSelector, ingress rules (from), and egress rules (to).
Drill 14
kubectl port-forward -n grokdevops svc/grokdevops 8080 :8000
Access via http://localhost:8080.
Drill 15
kubectl get deploy grokdevops -n grokdevops \
-o jsonpath = '{.spec.template.spec.containers[0].image}'
Returns image:tag string.
Drill 16
kubectl get configmaps -n grokdevops
kubectl describe configmap <name> -n grokdevops
Or: kubectl get configmap <name> -n grokdevops -o yaml
Drill 17
kubectl get servicemonitor -n monitoring
kubectl get servicemonitor -n monitoring -o yaml | grep -A5 selector
The selector.matchLabels must match the target service's labels.
Drill 18
kubectl scale deployment grokdevops -n grokdevops --replicas= 3
kubectl rollout status deployment/grokdevops -n grokdevops --timeout= 60s
Drill 19
kubectl get pods -n grokdevops -l app.kubernetes.io/name= grokdevops -o name | head -1 | \
xargs kubectl get -n grokdevops -o yaml
Drill 20
kubectl auth can-i list pods -n grokdevops --as= system:serviceaccount:grokdevops:default
Returns yes or no.
Drill 21
kubectl get events -n grokdevops --watch
Drill 22
kubectl get pods -n grokdevops -o custom-columns= 'NAME:.metadata.name,RESTARTS:.status.containerStatuses[0].restartCount'
Drill 23
kubectl get ingress -n grokdevops
kubectl describe ingress -n grokdevops
Check RULES: host, path, backend service, and port.
Drill 24
kubectl exec -it -n grokdevops deploy/grokdevops -- /bin/sh
Use /bin/sh if /bin/bash is not available (common in slim images).
Drill 25
kubectl diff -f devops/helm/grokdevops/
Or compare Helm's declared state: helm get values grokdevops -n grokdevops vs actual pod spec.
March 27, 2026 01:19:38
March 5, 2026 02:13:16