The CKAD kubectl cheat sheet: imperative commands for v1.37
The commands and flags that save minutes on a hands-on exam: generate YAML, create config objects, change running apps, roll out and back, expose, grant access and debug. Every flag below is in the Kubernetes v1.37 kubectl reference or the Helm documentation. Print it or save it as a PDF for practice.

1. Generate YAML instead of typing it
| Task | Command |
|---|---|
| Pod manifest to edit | kubectl run web --image=nginx:1.27 --port=80 --dry-run=client -o yaml > pod.yaml |
| Pod with env, labels and a command | kubectl run job1 --image=busybox:1.36 --restart=Never --env=MODE=batch --labels=app=job1 --command -- sleep 3600 |
| Throwaway test Pod | kubectl run tmp --image=busybox:1.36 --rm -it --restart=Never -- wget -qO- http://web:80 |
| Deployment with replicas and port | kubectl create deployment api --image=registry.example.com/api:2.1 -r 3 --port=8080 --dry-run=client -o yaml > deploy.yaml |
| Job | kubectl create job report --image=busybox:1.36 -- echo done |
| Run a CronJob now | kubectl create job report-now --from=cronjob/report |
| CronJob | kubectl create cronjob report --image=busybox:1.36 --schedule="*/5 * * * *" -- echo done |
| Apply, then check without changing | kubectl apply -f deploy.yaml · kubectl apply -f deploy.yaml --dry-run=server |
| Look up a field | kubectl explain deployment.spec.strategy · kubectl explain pods --recursive |
Work in the task's namespace: add -n NAMESPACE to every command, or switch with kubectl config set-context --current --namespace=NAMESPACE.
2. ConfigMaps, Secrets, ServiceAccounts, quotas
| Task | Command |
|---|---|
| ConfigMap from literals | kubectl create configmap app-cfg --from-literal=MODE=prod --from-literal=LOG=info |
| ConfigMap from files | kubectl create configmap app-cfg --from-file=app.properties · --from-env-file=app.env |
| Generic Secret | kubectl create secret generic db --from-literal=user=app --from-literal=password=s3cret |
| TLS Secret | kubectl create secret tls web-tls --cert=tls.crt --key=tls.key |
| Registry Secret for imagePullSecrets | kubectl create secret docker-registry regcred --docker-server=registry.example.com --docker-username=ci --docker-password=$TOKEN |
| ServiceAccount and a token | kubectl create serviceaccount build-bot · kubectl create token build-bot --duration=1h |
| ResourceQuota | kubectl create quota team-q --hard=cpu=2,memory=2Gi,pods=10 |
Secret values in data are only base64-encoded, and Secrets are stored unencrypted in etcd by default. stringData takes plain text.
3. Change running applications
| Task | Command |
|---|---|
| New image | kubectl set image deployment/api api=registry.example.com/api:2.2 |
| Environment from a ConfigMap or Secret | kubectl set env deployment/api --from=configmap/app-cfg · --from=secret/db |
| Requests and limits | kubectl set resources deployment/api -c api --requests=cpu=100m,memory=128Mi --limits=cpu=500m,memory=256Mi |
| ServiceAccount | kubectl set serviceaccount deployment/api build-bot |
| Scale | kubectl scale deployment/api --replicas=5 |
| Labels | kubectl label pod web tier=frontend · kubectl label pod web tier=backend --overwrite |
| Switch a Service selector (blue/green) | kubectl patch service shop -p '{"spec":{"selector":{"app":"shop","version":"green"}}}' |
4. Rollouts
| Task | Command |
|---|---|
| Watch a rollout (exits non-zero if it fails) | kubectl rollout status deployment/api |
| History, and one revision's template | kubectl rollout history deployment/api · kubectl rollout history deployment/api --revision=2 |
| Roll back | kubectl rollout undo deployment/api · kubectl rollout undo deployment/api --to-revision=2 |
| Restart Pods without changing the spec | kubectl rollout restart deployment/api |
| Batch several changes into one rollout | kubectl rollout pause deployment/api … changes … kubectl rollout resume deployment/api |
Defaults worth knowing: maxSurge and maxUnavailable are 25%, revisionHistoryLimit is 10, and scaling does not create a new revision.
5. Services, Ingress and access
| Task | Command |
|---|---|
| Expose a Deployment | kubectl expose deployment api --port=80 --target-port=8080 --name=api-svc |
| NodePort Service | kubectl expose deployment api --port=80 --target-port=8080 --type=NodePort |
| ClusterIP Service by hand | kubectl create service clusterip api --tcp=80:8080 |
| Ingress with a Prefix path | kubectl create ingress shop --class=nginx --rule="shop.example.com/api*=api:8080" |
| Ingress with TLS | kubectl create ingress shop --class=nginx --rule="shop.example.com/*=web:80,tls=web-tls" |
| Check endpoints behind a Service | kubectl get endpointslices -l kubernetes.io/service-name=api |
| Reach a Service from your terminal | kubectl port-forward service/api 8080:80 |
In --rule, a path ending in * becomes pathType: Prefix. targetPort defaults to port. NetworkPolicies have no imperative command: write the YAML.
6. RBAC
| Task | Command |
|---|---|
| Role that only reads Pods | kubectl create role pod-reader --verb=get,list,watch --resource=pods |
| Bind it to a ServiceAccount | kubectl create rolebinding pod-reader-bot --role=pod-reader --serviceaccount=shop-prod:build-bot |
| Bind a ClusterRole in one namespace | kubectl create rolebinding view-bot --clusterrole=view --serviceaccount=shop-prod:build-bot |
| Test a permission as the ServiceAccount | kubectl auth can-i list pods --as=system:serviceaccount:shop-prod:build-bot -n shop-prod |
| List what you can do | kubectl auth can-i --list |
A Role holds rules; subjects are attached separately with a RoleBinding. A binding's roleRef cannot be changed: delete and recreate it.
7. Observe and debug
| Task | Command |
|---|---|
| Pods with node, IP and labels | kubectl get pods -o wide --show-labels · kubectl get pods -L version |
| Only Pods that are not Running | kubectl get pods --field-selector=status.phase!=Running |
| Name and image of every Pod | kubectl get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[*].image}{"\n"}{end}' |
| Events for one object | kubectl events --for pod/web · kubectl describe pod web |
| Logs of the crashed container | kubectl logs web -c api --previous |
| Last lines with timestamps | kubectl logs web -c api --tail=20 --timestamps |
| Logs from every Pod of an app | kubectl logs -l app=api --all-containers |
| CPU and memory per container | kubectl top pod web --containers |
| Shell in one container | kubectl exec -it web -c api -- sh |
| Debug a distroless container | kubectl debug -it web --image=busybox:1.36 --target=api |
| Debug a copy of the Pod | kubectl debug web -it --image=busybox:1.36 --copy-to=web-debug |
| Which API versions are served | kubectl api-resources --api-group=apps · kubectl api-versions |
kubectl top needs the Metrics API. -l on kubectl logs shows only the last 10 lines per Pod unless you set --tail.
8. Kustomize and Helm
| Task | Command |
|---|---|
| Render an overlay | kubectl kustomize overlays/prod |
| Apply or compare an overlay | kubectl apply -k overlays/prod · kubectl diff -k overlays/prod |
| Add and refresh a chart repository | helm repo add myrepo https://charts.example.com · helm repo update |
| Find chart versions and defaults | helm search repo myrepo/nginx --versions · helm show values myrepo/nginx |
| Install a pinned version | helm install web myrepo/nginx -n web --create-namespace --version 1.2.3 -f values.yaml --set replicaCount=2 |
| Upgrade keeping earlier values | helm upgrade web myrepo/nginx -n web --reuse-values --set image.tag=1.27 |
| History and rollback | helm history web -n web · helm rollback web 2 -n web |
| Releases and their values | helm list -n web · helm list -A · helm get values web -n web --all |
| Render or download without installing | helm template web myrepo/nginx · helm pull myrepo/nginx --untar |
| Remove a release | helm uninstall web -n web |
The Helm version on the exam hosts is not published, so these are commands that work the same in Helm 3 and Helm 4. Avoid flags that changed in Helm 4: --atomic (now --rollback-on-failure), --force (now --force-replace) and --wait with a value. Repository URL and versions are examples.
9. Traps: commands that do not work in v1.37
| Old habit | What happens | Use instead |
|---|---|---|
kubectl run web --image=nginx --replicas=3 | kubectl run has no --replicas; it creates Pods only | kubectl create deployment web --image=nginx -r 3 |
kubectl run ... --serviceaccount=bot | No such flag in v1.37 | serviceAccountName in the YAML, or kubectl set serviceaccount on a Deployment |
kubectl run ... --requests=... --limits=... | No such flags in v1.37 | kubectl set resources, or edit the generated YAML |
kubectl run -f pod.yaml | Deprecated in v1.37 | kubectl apply -f pod.yaml |
kubectl convert -f old.yaml | Not part of kubectl; it is the separate kubectl-convert plugin | Rewrite to the served API version, checked with kubectl explain |
kubectl create secret regcred --docker-server=... | Missing the Secret type | kubectl create secret docker-registry regcred ... |
apiVersion: batch/v1beta1 CronJob, networking.k8s.io/v1beta1 Ingress | No longer served | batch/v1 and networking.k8s.io/v1 |
360 questions on the decisions behind CKAD tasks
Six timed multiple-choice exams for a hands-on exam: 94 command questions, 116 manifests and 53 debugging exhibits on Kubernetes v1.37, every option explained.
CKAD cheat sheet FAQ
Is there a CKAD cheat sheet PDF?
Use this page: press the print button and choose Save as PDF. You cannot bring it into the exam, where only the Kubernetes docs, the Kubernetes blog, the Helm docs and task-linked docs are allowed; it is for practice.
Which kubectl flags no longer work?
In Kubernetes v1.37, kubectl run has no --replicas, --serviceaccount, --requests, --limits or --generator. Use kubectl create deployment -r for replicas, kubectl set serviceaccount and kubectl set resources instead. kubectl convert is a separate plugin.
Why use imperative commands on the CKAD?
The CKAD is hands-on: 15-20 tasks in live clusters in 2 hours, with no multiple choice. Generating YAML with --dry-run=client -o yaml and editing it is much faster than typing a manifest from scratch, and less error-prone.
Which Helm commands are safe to learn?
The Helm version on the exam hosts is not published, so learn commands that work the same in Helm 3 and Helm 4: repo add and update, search repo, show values, install, upgrade, history, rollback, list, get values, template, pull and uninstall.
More guides: Free CKAD practice questions · CKAD exam format 2026 · CKA vs CKAD · Free Terraform Associate 004 questions · all guides