Kubernetes Objects Questions with Answers

27 practice questions on Kubernetes Objects (DevOps & Kubernetes) with answers and step-by-step solutions. Try 10 samples below, then practise all 27 free in the AptiNest app.

Sample questions

Question 1Easy

What do PersistentVolumeClaims (PVCs) do?

  1. Limit CPU usage
  2. Request storage that outlives individual Pods
  3. Store container images
  4. Define network policies that control traffic between namespaces

Answer: B. Request storage that outlives individual Pods

Explanation

A Pod mounts a PVC; the claim binds to a PersistentVolume, often provisioned dynamically by a StorageClass.

Step-by-step solution

  1. A Pod's own storage is lost when the Pod goes away unless it uses a claim.
  2. A PersistentVolumeClaim asks for storage that is kept separate from the Pod.
  3. The correct answer is option B, request storage that outlives individual Pods.

Why the other options are wrong

  • A. CPU limits are set on the container, not by a PVC.
  • C. Container images are stored in a registry, not in a PVC.
  • D. Network policies control traffic and are unrelated to storage claims.

Tip: A PVC is a request for storage; the Pod mounts it.

Question 2Easy

kubectl apply -f deploy.yaml is called declarative because:

  1. It applies only to a single Pod at a time, never to a whole set of resources
  2. You state the desired state; controllers reconcile it
  3. It runs commands one by one in order
  4. It always deletes and recreates everything

Answer: B. You state the desired state; controllers reconcile it

Explanation

Re-applying the same file is safe; controllers converge the cluster to match the manifest.

Step-by-step solution

  1. A declarative manifest describes the desired end state.
  2. Controllers keep comparing the actual state with that description and fix any difference.
  3. The correct answer is option B, you state the desired state and controllers reconcile it.

Why the other options are wrong

  • A. Kubectl apply can handle many resources in one file, not just one Pod.
  • C. Declarative tools describe the end state, not a list of commands run in order.
  • D. Apply updates resources in place; it does not delete and recreate everything.

Tip: Declarative = describe the result, not the steps.

Question 3Easy

Which object runs a batch task until it completes successfully?

  1. Deployment
  2. Job
  3. Service
  4. Ingress

Answer: B. Job

Explanation

A Job creates Pods that run to completion; a CronJob creates Jobs on a schedule.

Step-by-step solution

  1. A Job runs Pods until the task completes.
  2. It retries failures.
  3. Deployments keep Pods running forever.

Why the other options are wrong

  • A. Deployment is for long-running apps.
  • C. Service exposes Pods.
  • D. Ingress routes traffic.

Tip: Batch = Job.

Question 4Easy

How do Deployments, ReplicaSets and Pods relate?

  1. A Deployment manages ReplicaSets, which manage Pods
  2. A ReplicaSet manages Deployments
  3. They are independent objects that only share a naming convention in kubectl output
  4. A Pod manages Deployments

Answer: A. A Deployment manages ReplicaSets, which manage Pods

Explanation

Each rollout creates a new ReplicaSet; the Deployment shifts replicas between old and new ReplicaSets.

Step-by-step solution

  1. A Deployment manages ReplicaSets.
  2. ReplicaSets manage Pods.
  3. Rolling updates create new ReplicaSets.

Why the other options are wrong

  • B. The direction is reversed.
  • C. They are related.
  • D. Pods do not manage others.

Tip: Deployment, ReplicaSet, Pod.

Question 5Medium

Which workload object is designed for databases needing stable network names and per-replica storage?

  1. Deployment
  2. Job
  3. StatefulSet
  4. DaemonSet

Answer: C. StatefulSet

Explanation

StatefulSet pods get stable identities (db-0, db-1) and their own persistent volume claims, created in order.

Step-by-step solution

  1. A database needs stable pod names and its own storage for each replica.
  2. A StatefulSet gives pods stable identities and a separate volume claim for each pod.
  3. The correct answer is option C, StatefulSet.

Why the other options are wrong

  • A. A Deployment suits stateless apps whose pods are interchangeable.
  • B. A Job runs pods until they complete; it is not for a long-running database.
  • D. A DaemonSet runs one pod per node, not one pod per replica with stable storage.

Tip: Stateful = StatefulSet; stateless = Deployment.

Question 6Medium

What happens when a container exceeds its memory limit?

  1. The node reboots
  2. Kubernetes adds more memory automatically
  3. It is OOMKilled and restarted
  4. It is throttled but keeps running

Answer: C. It is OOMKilled and restarted

Explanation

Memory cannot be throttled, so the kernel kills the process; CPU over the limit is throttled instead.

Step-by-step solution

  1. Memory limit reached triggers OOM Killer.
  2. OOMKiller terminates the container's process.
  3. Container gets restarted by Kubernetes.
  4. Final state is OOMKilled and restarted.
  5. Answer: It is OOMKilled and restarted.

Why the other options are wrong

  • A. A container exceeding its memory limit does not reboot the node; only the container is affected.
  • B. Kubernetes does not add memory when a limit is hit; the limit is a cap that stays fixed.
  • D. Going over a memory limit is not throttling; throttling is for CPU, and memory overuse ends in OOMKilled.

Tip: Remember OOMKiller kills containers over memory limits in Kubernetes.

Question 7Medium

What happens when a container tries to use more CPU than its limit?

  1. It is moved to another node
  2. Its memory limit is raised
  3. It is killed immediately
  4. It is throttled

Answer: D. It is throttled

Explanation

CPU is compressible; the container gets less CPU time but keeps running, which can raise latency.

Step-by-step solution

  1. CPU is a compressible resource.
  2. When a container reaches its CPU limit, it is throttled and gets less CPU time.
  3. It keeps running, which can raise latency. The correct answer is option D, it is throttled.

Why the other options are wrong

  • A. The container is not moved to another node because of CPU use.
  • B. The memory limit is not raised when CPU is capped.
  • C. Containers are killed for exceeding memory limits, not CPU limits.

Tip: CPU over limit = throttled; memory over limit = the container is killed.

Question 8Medium

A ConfigMap is injected into a Pod as environment variables, then the ConfigMap is edited. What happens?

  1. Running Pods keep old values until they restart
  2. Env vars update instantly in running containers
  3. The Pod is deleted automatically
  4. The ConfigMap edit is rejected while Pods use it

Answer: A. Running Pods keep old values until they restart

Explanation

Environment variables are set at container start; mounted ConfigMap files update eventually, but env vars do not.

Step-by-step solution

  1. Environment variables are set when the Pod starts.
  2. Editing the ConfigMap after startup does not change existing environment variables.
  3. Running Pods retain old values until they restart.
  4. The edit is applied to new Pods only.
  5. Final answer: Running Pods keep old values until they restart.

Why the other options are wrong

  • B. Environment variables are fixed at container start, so an edit does not reach running containers instantly.
  • C. Editing a ConfigMap does not delete Pods; they keep running with their existing environment.
  • D. The ConfigMap edit is allowed; Kubernetes does not block changes because Pods are using it.

Tip: Env vars stay as set; edits affect new Pods only.

Question 9Hard

A headless Service (clusterIP: None) is used when:

  1. You want to disable the Service's selector
  2. You want an external cloud load balancer in front of the Pods
  3. Clients need individual Pod IPs via DNS
  4. You want to hide all Pods from DNS

Answer: C. Clients need individual Pod IPs via DNS

Explanation

DNS returns Pod addresses directly instead of one virtual IP, letting clients reach specific replicas.

Step-by-step solution

  1. A normal Service gives one virtual IP and load-balances across its pods.
  2. A headless Service sets clusterIP to None.
  3. DNS then returns the individual pod addresses, so clients can reach specific replicas.
  4. The correct answer is option C, clients need individual Pod IPs via DNS.

Why the other options are wrong

  • A. A headless Service still uses its selector to find the pods.
  • B. An external cloud load balancer comes from a LoadBalancer Service, not a headless one.
  • D. A headless Service does not hide pods; DNS lists their addresses.

Tip: ClusterIP: None means DNS returns the pod IPs.

Question 10Hard

Why must containers declare CPU requests for an HPA scaling on CPU utilisation?

  1. Requests are needed to pull the image
  2. The HPA reads requests to choose which node each new replica should be placed on
  3. Without requests, Pods cannot get IP addresses
  4. Utilisation is a percentage of the request

Answer: D. Utilisation is a percentage of the request

Explanation

With no request, there is no baseline to compute a percentage from, so the HPA cannot act.

Step-by-step solution

  1. CPU utilisation is measured as a percentage.
  2. The percentage is of the container's CPU request.
  3. Without a request there is no base.

Why the other options are wrong

  • A. Pulling images is unrelated.
  • B. The scheduler uses requests for placement, not the HPA for this.
  • C. IPs are unrelated.

Tip: HPA utilisation = usage / request.

Practise all 27 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all DevOps & Kubernetes topics · All topics