CKA
Free CKA practice questions
10 questions from our CKA practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.
Question 1 of 10, Troubleshooting
A Pod in namespace web is stuck in CrashLoopBackOff. Which command shows the logs of the previous container instance?
- A
kubectl logs pod-name -n webShows logs of the current instance, which may be empty right after a restart. - B
kubectl logs pod-name -n web --previousCorrect answer - C
kubectl describe pod pod-name -n web --logsdescribehas no--logsflag. - D
kubectl get events -n web --previousEvents do not contain container logs and--previousis not a valid flag forget.
Answer and explanation: --previous (-p) returns logs from the last terminated container instance, which is what you need when the current container keeps restarting.
Reference: kubernetes.io
Question 2 of 10, Services and Networking. Choose 2.
Which TWO Service types make an application reachable from outside the cluster without an Ingress? (Choose 2)
- AClusterIPClusterIP is reachable only inside the cluster.
- BNodePort Correct answerCorrect — reachable via <NodeIP>:<NodePort>.
- CLoadBalancer Correct answerCorrect — the cloud provider allocates an external IP.
- DHeadless (clusterIP: None)Headless Services return Pod IPs via DNS and are internal only.
Answer and explanation: NodePort exposes the Service on a static port on every node, and LoadBalancer provisions an external load balancer (which itself builds on NodePort).
Reference: kubernetes.io
Question 3 of 10, Storage
A StorageClass must delay PersistentVolume provisioning until a pod using the claim is scheduled, so the volume is created in the same zone as the pod. Which field achieves this?
- AallowVolumeExpansion: true
- BvolumeBindingMode: WaitForFirstConsumer Correct answer
- CvolumeBindingMode: Immediate with a default allowedTopologies list
- DreclaimPolicy: Retain
Answer and explanation: WaitForFirstConsumer defers binding and provisioning until a pod is scheduled, so topology constraints from the pod are honored. Immediate (the default) provisions as soon as the PVC is created, and a static allowedTopologies list only restricts zones rather than following the pod. reclaimPolicy controls what happens after release, and allowVolumeExpansion permits resizing.
Question 4 of 10, Troubleshooting
You scale a Deployment from 2 to 5 replicas. The Deployment's spec shows 5, but kubectl get rs shows the ReplicaSet still at 2 desired and no new pods are created. The API server and scheduler are healthy. What is the MOST likely cause?
- AThe kube-scheduler is not running, so the extra pods cannot be placed on any of the worker nodes
- BA ResourceQuota is rejecting the pods, so the ReplicaSet keeps its desired count unchanged at 2
- CThe kubelet on each node is down, so the ReplicaSet cannot confirm the new pods have started
- DThe kube-controller-manager is not running, so the Deployment controller never updates the ReplicaSet Correct answer
Answer and explanation: Propagating the Deployment's replica count to the ReplicaSet is the job of the Deployment controller inside kube-controller-manager, so an unchanged ReplicaSet points there. A dead scheduler would leave created pods Pending, but the ReplicaSet's desired count would still change to 5. A quota rejection also happens after the ReplicaSet is updated and shows FailedCreate events. Kubelet health has no bearing on the ReplicaSet's desired field.
Question 5 of 10, Troubleshooting
kubectl get nodes shows all nodes Ready, but kubectl get pods and other reads take 20+ seconds and writes intermittently fail with etcdserver: request timed out. What should you check FIRST?
- AThe kube-scheduler logs, because slow scheduling delays every write sent to the API server
- Bkube-proxy iptables sync time, because API requests are routed through Service rules first
- Cetcd health and disk latency, for example with etcdctl endpoint health and endpoint status Correct answer
- DCoreDNS latency, because kubectl resolves the API server name through cluster DNS lookups
Answer and explanation: etcd timeouts surface directly in API server errors; slow disks or an unhealthy member make reads and writes slow, so check etcd endpoint health/status and fsync latency. The scheduler is not in the request path for reads or writes. kubectl resolves the API server from kubeconfig via the client's DNS, not cluster DNS. kubectl to API server traffic does not traverse kube-proxy rules on the control plane in a kubeadm setup.
Question 6 of 10, Workloads and Scheduling
A logging agent must start before the application container and keep running alongside it for the whole pod lifetime, and Jobs using it must still complete when the main container exits. Which definition achieves this on current Kubernetes?
- ADefine the agent as an ephemeral container added by kubectl
- BDefine the agent in initContainers with no restartPolicy set at all
- CDefine the agent in initContainers with restartPolicy: Always Correct answer
- DDefine the agent as a second regular container in containers
Answer and explanation: Native sidecars are init containers with restartPolicy Always: they start before app containers, keep running, and do not block Job completion. A regular second container keeps the Job pod running after the main container exits. A plain init container must finish before the app starts. Ephemeral containers are for debugging and are not part of the pod spec at creation.
Question 7 of 10, Cluster Architecture, Installation and Configuration
You are upgrading a kubeadm cluster by one minor version. On the first control-plane node you have already upgraded the kubeadm package. What is the correct next step?
- ARun kubeadm upgrade plan, then kubeadm upgrade apply with the target version Correct answer
- BDrain all worker nodes so that the control-plane components can be safely upgraded
- CRun kubeadm upgrade node to upgrade the control-plane components on this node
- DUpgrade kubelet and kubectl first, then run kubeadm upgrade apply to finish the job
Answer and explanation: On the first control-plane node you verify the plan and then run kubeadm upgrade apply to upgrade the static pods and cluster configuration. kubeadm upgrade node is used on additional control-plane nodes and on workers. The kubelet is upgraded after the control plane, never before, to respect version skew. Workers are drained one at a time later when each is upgraded, not all at once.
Question 8 of 10, Cluster Architecture, Installation and Configuration
You restored an etcd snapshot on a kubeadm control plane into /var/lib/etcd-restored. What must you do next so the cluster uses the restored data?
- ARestart the kube-apiserver with --etcd-servers pointing to the folder /var/lib/etcd-restored on the host
- BRun etcdctl member add so the restored data directory joins the running etcd cluster as a new member
- CRun kubeadm init phase etcd local so kubeadm imports the restored data into the original data directory
- DUpdate the etcd static pod manifest so the host path for the data volume points to /var/lib/etcd-restored Correct answer
Answer and explanation: The restore writes a new data directory; etcd keeps using its old one until the static pod's hostPath volume (and data-dir if changed) references the new location, after which the kubelet recreates the pod. kubeadm's etcd phase only regenerates the manifest with default paths. The API server talks to etcd over a network endpoint, never a folder. Adding a member would join the restored data into the existing cluster, defeating the restore.
Question 9 of 10, Services and Networking
You need to expose Deployment api (container port 8080) inside the cluster on port 80. Which command creates the right Service?
- Akubectl expose deployment api --port=80 --target-port=8080 Correct answer
- Bkubectl expose deployment api --port=8080 --target-port=80
- Ckubectl expose deployment api --port=80 --type=LoadBalancer
- Dkubectl create service nodeport api --tcp=8080:80
Answer and explanation: --port is the Service port clients use and --target-port is the container port, so 80 to 8080 is right, and the default type ClusterIP keeps it internal. Swapping the values sends traffic to the wrong port. In --tcp the format is port:targetPort, so 8080:80 is reversed and NodePort also exposes it externally. LoadBalancer exposes it outside the cluster and still targets port 80 in the container.
Question 10 of 10, Services and Networking
Ingress for api.example.com must terminate TLS with a certificate stored in Secret api-tls. Which statement is correct?
- AThe Secret must be type kubernetes.io/tls in the Ingress's namespace and listed under spec.tls with the host Correct answer
- BThe Secret can live in any namespace if spec.tls references it with the namespace/name format
- CThe Secret must be type Opaque with keys cert and key, referenced through an Ingress annotation
- DThe Secret must be mounted as a volume into the backend pods so they complete the TLS handshake
Answer and explanation: Ingress TLS uses spec.tls entries naming hosts and a kubernetes.io/tls Secret (tls.crt/tls.key) in the same namespace as the Ingress; the controller terminates TLS. Cross-namespace Secret references are not part of the Ingress spec. Backend pods do not need the certificate when the controller terminates TLS. The standard keys are tls.crt and tls.key, not an annotation-based Opaque Secret.