These three questions cover some of the most frequently tested topics in the CKAD exam: imperative pod creation, scaling, and configuration management. The exam is hands-on, so speed with kubectl is everything.
Question 1
What is the correct command to create a pod named web-server using the image nginx:1.17 in the default namespace?
- A)
kubectl create pod web-server --image=nginx:1.17 - B)
kubectl run web-server --image=nginx:1.17 - C)
kubectl apply -f web-server.yaml - D)
kubectl new web-server --image=nginx:1.17
Answer: B: kubectl run web-server --image=nginx:1.17
kubectl run is the imperative command for creating a standalone pod. kubectl create pod is not valid syntax; create works for higher-level resources like deployments, services, and configmaps, but not pods directly. Option C is correct YAML-based approach but requires you to have a manifest file ready. Option D does not exist.
Pro tip for the exam: Generate YAML files quickly with --dry-run=client -o yaml:
kubectl run web-server --image=nginx:1.17 --dry-run=client -o yaml > pod.yaml
Then edit pod.yaml before applying, which is much faster than writing from scratch.
Question 2
What is the correct command to scale a deployment named app-deployment to 5 replicas?
- A)
kubectl edit deployment app-deployment --replicas=5 - B)
kubectl set replicas app-deployment 5 - C)
kubectl scale deployment app-deployment --replicas=5 - D)
kubectl update deployment app-deployment --replicas=5
Answer: C: kubectl scale deployment app-deployment --replicas=5
kubectl scale is the dedicated command for adjusting replica counts. Options A, B, and D use subcommands or flags that don't exist in kubectl.
kubectl edit can update replicas but requires you to open an editor and manually find/change the value, which is slow and error-prone under exam conditions.
Know multiple ways to scale:
# Imperative (fastest in exam)
kubectl scale deployment app-deployment --replicas=5
# Patch (handy for scripting)
kubectl patch deployment app-deployment -p '{"spec":{"replicas":5}}'
</details>
Question 3
What is the correct command to create a ConfigMap named app-config from a file called config.properties?
- A)
kubectl create configmap app-config --from-file=config.properties - B)
kubectl create cm app-config --from-config=config.properties - C)
kubectl apply configmap app-config --file=config.properties - D)
kubectl new configmap app-config config.properties
Answer: A: kubectl create configmap app-config --from-file=config.properties
--from-file reads the file contents and creates a ConfigMap key named after the file. Option B uses the correct alias cm but the wrong flag (--from-config doesn't exist). Options C and D are invalid syntax.
Three ways to create a ConfigMap you must know:
# From a file (key = filename, value = file contents)
kubectl create configmap app-config --from-file=config.properties
# From literal key-value pairs
kubectl create configmap app-config --from-literal=DB_HOST=postgres --from-literal=DB_PORT=5432
# From an env file (one KEY=VALUE per line)
kubectl create configmap app-config --from-env-file=config.env
</details>
Key Takeaways
kubectl runcreates pods;kubectl create deploymentcreates deploymentskubectl scaleis the fastest way to adjust replicas- ConfigMaps can be created from files (
--from-file), literals (--from-literal), or env files (--from-env-file) - Always use
--dry-run=client -o yamlto generate YAML templates quickly during the exam