Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

CKA essential commands: the enriched cheat sheet

By updated

Improve this page

Logo Kubernetes

This page is an operational reference for the CKA. It holds the essential commands organized by exam domain, with the usage context and the pitfalls to avoid.

For detailed explanations, see the dedicated guides (kubeadm, etcd, RBAC, etc.). Here, the goal is to memorize the commands and the reflexes.

What you will learn

This reference gathers the commands the CKA expects you to type without hesitation. By going through it, you will be able to:

  • find the cluster administration commands, sorted by exam domain;
  • run an upgrade with kubeadm and a backup or a restore with etcdctl and etcdutl;
  • apply a troubleshooting method, from the node to the control plane component;
  • tell what you learn by heart from what you look up in the documentation on exam day.

Initial setup

In the exam, each task is carried out on a designated host, and kubectl, the k alias and completion are already ready there (official CKA and CKAD tips, retrieved on November 13, 2026): do not waste minutes setting them up. The block below is for your practice cluster. It adds two personal shortcuts, kn and do, to type again on the task host if you want them.

Terminal window
# Core aliases
alias k=kubectl
alias kn='kubectl config set-context --current --namespace'
export do="--dry-run=client -o yaml"
# Autocompletion
source <(kubectl completion bash)
complete -F __start_kubectl k
# Editor
export KUBE_EDITOR=vim

The first reflex for each question is to read the task box: it gives the ssh command of the host where the task is carried out. You connect to it, you work, then you go back to the base host with exit, with no nested ssh (official CKA and CKAD tips, retrieved on November 13, 2026).

Terminal window
# The exact command is in the task box
ssh <task-host>
# ... work on the host, kubectl is already installed there ...
# Back to the base host
exit

The kubectl config commands are used to read a kubeconfig on your practice cluster. They are not part of the exam routine.

Reflexes by situation

This table is your quick diagnostic tool. Faced with a symptom, apply the first reflex.

SituationFirst reflexCommand
Pod in errorDescribe + previous logskubectl describe pod X then kubectl logs X --previous
Node NotReadyDescribe + kubelet logskubectl describe node X then journalctl -u kubelet
Service does not answerCheck the EndpointSliceskubectl get endpointslice -l kubernetes.io/service-name=X
PVC PendingCheck PV and SCkubectl get pv,pvc,sc then kubectl describe pvc X
Scheduling failsPod eventskubectl describe pod X → Events section
Broken clusterGlobal statekubectl get nodes + kubectl get pods -n kube-system
API server downStatic podscrictl ps or check /etc/kubernetes/manifests/
etcd brokenetcd logskubectl logs -n kube-system etcd-master
DNS does not resolveCoreDNS up?kubectl get pods -n kube-system -l k8s-app=kube-dns
Permissions deniedRBAC testkubectl auth can-i <verb> <resource> --as=<user>

What to know by heart

These items come up constantly. Do not look them up during the exam.

Critical paths

These locations are those of a cluster installed by kubeadm. The first one matters most when troubleshooting: moving a file out of /etc/kubernetes/manifests/ is enough to stop the matching component. The kubelet re-reads this directory every 20 seconds by default (fileCheckFrequency) and therefore notices the removal within that delay at the latest. The stop was measured at 1 to 31 seconds depending on the component.

Terminal window
# Static pods (control plane)
/etc/kubernetes/manifests/
# PKI certificates
/etc/kubernetes/pki/
# etcd certificates
/etc/kubernetes/pki/etcd/
# kubelet configuration
/var/lib/kubelet/config.yaml
/etc/kubernetes/kubelet.conf
# Admin kubeconfig
/etc/kubernetes/admin.conf
~/.kube/config

Cluster upgrade order

The order is not negotiable: the API server must never be older than the kubelets that connect to it. Workers go one at a time, each one framed by a drain and an uncordon, so that applications stay available during the operation.

  1. kubeadm on the control plane
  2. kube-apiserver, scheduler, controller-manager (automatic through kubeadm)
  3. kubelet and kubectl on the control plane
  4. Drain the first worker
  5. kubeadm, kubelet and kubectl on that worker
  6. Uncordon that worker
  7. Repeat for each worker

Differences between cordon / drain / uncordon

The confusion is about cordon, which forbids the arrival of new pods but leaves the ones already there running. Only drain really evacuates the node, and it stops until DaemonSet pods or emptyDir volumes have been explicitly accepted with an option.

ActionSchedulingExisting pods
cordonBlockedStay
drainBlockedEvacuated
uncordonAllowednot applicable

Differences between Role / ClusterRole

The third row is the one that traps people: a ClusterRole tied to a RoleBinding only grants rights in the namespace of the binding. This setup is used to reuse a definition of permissions without copying it namespace by namespace.

TypeScopeResources
Role + RoleBinding1 namespacePods, Deployments, Secrets...
ClusterRole + ClusterRoleBindingWhole clusterNodes, PVs, Namespaces + everything
ClusterRole + RoleBinding1 namespaceReuse of a ClusterRole, limited

PSA labels (Pod Security Admission)

Pod Security Admission is enabled by a simple namespace label, with nothing to install. The enforce, audit and warn modes are independent: only enforce really rejects a non-compliant pod.

Terminal window
# Apply the Restricted policy
kubectl label ns production pod-security.kubernetes.io/enforce=restricted

What to look up in the docs

These items are more complex. Copy them from kubernetes.io on exam day.

  • Complete syntax of an Ingress with TLS
  • Advanced fields of a NetworkPolicy (namespaceSelector, ipBlock)
  • Advanced kubeadm init options (HA, --upload-certs)
  • EncryptionConfiguration for etcd secrets
  • PodDisruptionBudget syntax

Recommended bookmarks:

  • kubernetes.io/docs/reference/kubectl/quick-reference/
  • kubernetes.io/docs/concepts/security/
  • kubernetes.io/docs/tasks/administer-cluster/

Commands by domain

The tabs follow the split of the exam domains. Each one groups the commands actually used in the test, followed by the pitfalls flagged under the blocks: they are what costs points, rarely the basic syntax.

The kubeadm, apt-get, systemctl and etcd commands run as root on the node concerned: open a root shell with sudo -i, or prefix them with sudo, as the restore blocks do.

kubeadm, initialization and upgrade

kubeadm init installs the control plane but leaves the cluster without a network: nodes stay NotReady until a CNI is deployed. The value of --pod-network-cidr must match the one that CNI expects.

Terminal window
# Initialize the control plane
kubeadm init --pod-network-cidr=10.244.0.0/16
# Configure kubectl after init
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# Generate the join command
kubeadm token create --print-join-command
# Check the upgrade plan
kubeadm upgrade plan
# Apply the upgrade (adapt the version)
kubeadm upgrade apply v1.X.0
# Upgrade a worker
kubeadm upgrade node

The classic pitfall is forgetting systemctl daemon-reload && systemctl restart kubelet after upgrading the kubelet.

Complete upgrade of a worker

The sequence alternates between two machines: drain and uncordon run from the control plane, the package installation on the worker. kubeadm upgrade node updates the local configuration but does not replace the kubelet package, hence the apt-get line that follows. Packages installed following the official procedure are frozen by apt-mark hold: without apt-mark unhold first, apt-get install -y refuses to change them, and you freeze them again afterwards.

Terminal window
# On the control plane
kubectl drain worker1 --ignore-daemonsets --delete-emptydir-data
# On the worker
apt-mark unhold kubeadm kubelet kubectl
apt-get install -y kubeadm=1.X.0-1.1
kubeadm upgrade node
apt-get install -y kubelet=1.X.0-1.1 kubectl=1.X.0-1.1
apt-mark hold kubeadm kubelet kubectl
systemctl daemon-reload
systemctl restart kubelet
# On the control plane
kubectl uncordon worker1

For the complete procedure, see the detailed kubeadm guide, which covers installation and administration.

Troubleshooting (30% of the exam)

Questions in this domain rarely hinge on an isolated command: you must locate the failure before fixing it. The approach goes down from the cluster to the node and then to the pod, each level having its own tools, kubectl on one side, journalctl and crictl on the other when the API no longer answers.

Methodology

These five steps rule out a costly mistake in the test: fixing at random without having read the events. The level identified at the second step drives the tools: a kubelet fault leaves no trace in kubectl logs.

  1. Identify the symptom: what exactly is happening?
  2. Locate the level: Pod, Node or Cluster?
  3. Collect information with describe, logs and events.
  4. Form a hypothesis: what could the cause be?
  5. Fix, then verify.

Cluster state

cluster-info confirms that the API server answers, get nodes that the kubelets register with it. The --raw='/readyz?verbose' call details each internal check of the server and points to the failing subsystem.

Terminal window
# Overview
kubectl cluster-info
kubectl get nodes
kubectl get pods -n kube-system
# Health check
kubectl get --raw='/readyz?verbose'

Pod diagnosis

describe comes before logs: the Events section explains failures that happened before the container even started, image not found or volume not mounted, cases where no log exists. The --previous option is the only way to read the output of a container that has already restarted.

Terminal window
# State
kubectl get pod mypod -o wide
# Details (ESSENTIAL)
kubectl describe pod mypod
# Logs
kubectl logs mypod
kubectl logs mypod --previous # After a crash
kubectl logs mypod -c container # Multi-container
# Shell
kubectl exec -it mypod -- /bin/sh

Node diagnosis

A NotReady node is diagnosed from the machine itself: describe node lists the reported conditions, but the cause is in the kubelet journal. Filtering by time window avoids digging up errors unrelated to the current incident.

Terminal window
# From the control plane
kubectl describe node worker1
# On the problem node
systemctl status kubelet
journalctl -u kubelet | tail -50
journalctl -u kubelet --since "10 minutes ago" | grep -i error

Control plane component diagnosis

These components run as static pods, driven by the kubelet and not by the API. When kubectl no longer answers, crictl ps and the files in /var/log/pods/ become the only sources of information available on the node.

Terminal window
# Static pod logs
kubectl logs -n kube-system kube-apiserver-master
kubectl logs -n kube-system etcd-master
kubectl logs -n kube-system kube-scheduler-master
kubectl logs -n kube-system kube-controller-manager-master
# Or directly on the node
crictl ps
cat /var/log/pods/kube-system_kube-apiserver-*/kube-apiserver/*.log

Common problems and solutions

This table reads from the symptom to the cause: the state shown by kubectl get pods already narrows the hypotheses a lot. CreateContainerConfigError and ImagePullBackOff are told apart right away: the first comes from a missing ConfigMap or Secret, the second from the registry.

SymptomProbable causeSolution
Pod PendingNo eligible nodeCheck taints, resources, nodeSelector
Pod ImagePullBackOffImage does not exist or credentialsCheck image name, registry secret
Pod CrashLoopBackOffApp crashkubectl logs --previous
Pod CreateContainerConfigErrorMissing ConfigMap/Secretkubectl describe pod → Events
Node NotReadykubelet downsystemctl restart kubelet
Node MemoryPressureRAM saturatedEvict Pods
Service not reachableEmpty EndpointSliceCheck selector vs Pod labels
DNS timeoutCoreDNS downCheck kube-dns Pods
kubectl timeoutAPI server downCheck /etc/kubernetes/manifests/

Quick YAML generation

The $do variable defined at the start of the page adds --dry-run=client -o yaml: the resource is not created, its manifest goes to standard output. It is a very profitable technique in the test: producing a valid skeleton and then editing it costs far less time than writing the YAML from memory.

Terminal window
# Pod
kubectl run nginx --image=nginx:1.30@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb $do > pod.yaml
# Deployment
kubectl create deploy webapp --image=nginx:1.30@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb --replicas=3 $do > deploy.yaml
# Service
kubectl expose deploy webapp --port=80 $do > svc.yaml
# Job
kubectl create job myjob --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- /bin/sh -c "echo hello" $do
# CronJob
kubectl create cronjob mycron --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e --schedule="*/5 * * * *" -- date $do
# ConfigMap
kubectl create cm myconfig --from-literal=key=value $do
# Secret
kubectl create secret generic mysecret --from-literal=password=secret $do
# Role
kubectl create role myrole --verb=get,list --resource=pods $do
# RoleBinding
kubectl create rolebinding mybinding --role=myrole --user=jane $do
# ServiceAccount
kubectl create sa mysa $do

Condensed cheat sheet

This block gathers the commands of the previous sections for a quick review before the test. The values between angle brackets are to be replaced, and the ellipses of etcdctl hide the certificate options which, for their part, cannot be omitted.

Terminal window
# === HOST AND NAMESPACE ===
ssh <task-host> # command given by the task box
kubectl config set-context --current --namespace=<ns>
exit # back to the base host
# === CLUSTER ===
kubeadm init --pod-network-cidr=10.244.0.0/16
kubeadm token create --print-join-command
kubeadm upgrade plan && kubeadm upgrade apply v1.X.0
# === ETCD === save with etcdctl, status and restore with etcdutl
# restore: manifests moved out first, etcd.yaml hostPath repointed, manifests put back after
etcdctl snapshot save /backup/snap.db --endpoints=... --cacert=... --cert=... --key=...
etcdutl snapshot status /backup/snap.db --write-out=table
etcdutl snapshot restore /backup/snap.db --name=... --initial-cluster=... --initial-advertise-peer-urls=... --data-dir=/var/lib/etcd-restaure
# === NODES ===
kubectl cordon/drain/uncordon <node>
kubectl taint node <node> key=value:NoSchedule
kubectl label node <node> disktype=ssd
# === RBAC ===
kubectl create role <name> --verb=get,list --resource=pods
kubectl create rolebinding <name> --role=<role> --user=<user>
kubectl auth can-i create pods --as=jane
# === TROUBLESHOOT ===
kubectl describe pod/node/svc <name>
kubectl logs <pod> --previous
journalctl -u kubelet | grep error
systemctl restart kubelet

Key takeaways

The first two points hold before you even read the question: do not waste time setting up k and completion, and handle each task on the designated host. The rest is retained through practice, not through rereading.

  1. On the exam task hosts, the k alias and completion are already ready.
  2. Read the box of each task: it gives the ssh command to the task host, where you work before coming back with exit.
  3. Memorize the etcd certificate path, /etc/kubernetes/pki/etcd/: etcdctl backs up, etcdutl verifies and restores.
  4. For an upgrade, the control plane goes first, then each worker, with drain and uncordon.
  5. A Role applies to a namespace, a ClusterRole to the cluster.
  6. Troubleshooting weighs 30% of the exam: master describe, logs, events and journalctl.
  7. The static Pod manifests are in /etc/kubernetes/manifests/.
  8. To produce a manifest, use $do systematically.

Test your knowledge

Seven questions on what this page asks you to know by heart: the order of operations, the paths you do not look up on exam day, and the distinctions that cost points.

Knowledge check

Check what you have learned with this interactive quiz

7 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer