Kubernetes - kubectl Essential CommandsYou want to list all pods in the namespace 'dev' with label 'tier=frontend' showing node and IP. Which command is correct?Akubectl get pods -n dev --label=tier=frontend -o jsonBkubectl get pods -n dev --selector=tier=frontend -o wideCkubectl get pods --all-namespaces --selector=tier=frontend -o wideDkubectl get pods -n dev --selector=tier=frontendCheck Answer
Step-by-Step SolutionSolution:Step 1: Use namespace flag correctlyUse '-n dev' to specify the 'dev' namespace.Step 2: Filter pods by label with --selectorUse '--selector=tier=frontend' to filter pods with that label.Step 3: Add '-o wide' to show node and IP detailsThe '-o wide' option adds extra columns like node and IP.Final Answer:kubectl get pods -n dev --selector=tier=frontend -o wide -> Option BQuick Check:Namespace + selector + wide output = kubectl get pods -n dev --selector=tier=frontend -o wide [OK]Quick Trick: Combine -n, --selector, and -o wide for filtered detailed list [OK]Common Mistakes:Using --label instead of --selectorUsing --all-namespaces instead of specific namespace
Master "kubectl Essential Commands" in Kubernetes9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kubernetes Quizzes Kubernetes Fundamentals - Desired state vs actual state reconciliation - Quiz 8hard Kubernetes Fundamentals - Control plane components (API server, scheduler, controller manager, etcd) - Quiz 1easy Kubernetes Fundamentals - Node components (kubelet, kube-proxy, container runtime) - Quiz 9hard Labels and Selectors - Organizing with recommended labels - Quiz 6medium Namespaces - Creating custom namespaces - Quiz 7medium Namespaces - Switching namespace context - Quiz 3easy Pods - Init containers - Quiz 15hard ReplicaSets and Deployments - Why ReplicaSets ensure availability - Quiz 14medium ReplicaSets and Deployments - Deployment as higher-level abstraction - Quiz 15hard Services - Endpoints and endpoint slices - Quiz 9hard