Kubernetes (k8s) Commands

Type a Kubernetes command that matches the task. Some answers will only have one correct prompt; however, there are a few that accept common equivalents (where they make sense) Studying for the CKA or CKAD? This is a good drill....at least I think so....
Quiz by
jpm100eb
Rate:
Last updated: February 18, 2026
You have not attempted this quiz yet.
First submittedFebruary 18, 2026
Times taken8
Average score37.0%
Report this quizReport
5:00
0
 / 27 guessed
The quiz is paused. You have remaining.
Scoring
You scored / = %
This beats or equals % of test takers also scored 100%
The average score is
Your high score is
Your fastest time is
Keep scrolling down for answers and more stats ...
Hint
Answer
List all nodes (in the current namespace)
kubectl get nodes
Show all pods in the current namespace
kubectl get pods
Show all pods in ALL namespaces
kubectl get pods -A
Describe a pod named nginx
kubectl describe pod nginx
Describe all pods (in the current namespace)
kubectl describe pods
Output the YAML for pod named nginx
kubectl get pod nginx -o yaml
Watch pods (in current namespace)
kubectl get pods -w
Create from a manifest file called app.yaml (hint: use apply)
kubectl apply -f app.yaml
Delete from a manifest file app.yaml
kubectl delete -f app.yaml
List all namespaces
kubectl get namespaces
Create a namespace named dev
kubectl create ns dev
Switch context namespace to dev
kubectl config set-context --current --namespace=dev
Create a deployment "web" using image nginx:1.25
kubectl create deploy web --image=nginx1.25
Scale deployment "web" to 3 replicas
kubectl scale deploy web --replicas=3
Update a deployment image (rolling update). Set "web" container nginx to nginx:1.26
kubectl set image deploy/web nginx=nginx:1.26
Check rollout status of the "web" deployment
kubectl rollout status deploy/web
Roll back a deployment of "web"
kubectl rollout undo deploy/web
Expose a deployment called "web" as a service on port 80 as ClusterIP
kubectl expose deploy web --port=80
Port Forwarding: Forward Local port 8080 to pod nginx on port 80
kubectl port-forward pod/nginx 8080:80
Exec into a pod. Get a shell in pod nginx.
kubectl exec -it nginx -- sh
View logs for pod nginx
kubectl logs nginx
View logs for a specific container. Pod is app, container is api
kubectl logs app -c api
Create a configmap (literal) app-cm with key=value
kubectl create cm app-cm --from-literal=key=value
Create a secret db with user=admin
kubectl create secret generic db --from-literal=user=admin
Create a service account
kubectl create sa build-bot
Get Events (sorted)
kubectl get events --sort-by=.metadata.creationTimestamp
Show wide pod details
kubectl get pods -o wide
Save Your Stats
Your Next Quiz
Name all 50 states in the USA. Easy, right?
Drag the flag onto the correct country. Careful, though! One wrong move and the game ends.
Click the animals that live in Africa without clicking any of the ones that don't!
Drag the pin onto the correct country. Careful, though! Three wrong moves and the game ends.
Comments have been disabled on this page.