Courseiva

Certified Kubernetes Application Developer CKAD (CKAD) — Questions 226–300

826 questions total · 12pages · All types, answers revealed

Page 3

Page 4 of 12

Page 5
226
MCQmedium

You have a headless Service for a StatefulSet. The DNS query for the service returns no A records. What is the most likely cause?

A.The Service selector does not match any pod labels
B.The Service has clusterIP set to an IP address
C.The Service is of type ExternalName
D.The StatefulSet is using a volumeClaimTemplate
AnswerA

For a headless Service to publish A records, its selector must match the pod labels of the StatefulSet's Pods; the DNS entries are generated from the Service's endpoints. If the selector matches no Pods, the endpoints list is empty and the cluster's DNS resolver returns NXDOMAIN (or no A record) for the fully-qualified domain name. So even with clusterIP set to None, you get no DNS results, which is exactly why this is the correct answer.

Why this answer

A headless Service (clusterIP: None) relies on DNS A records to return the IP addresses of the Pods selected by its selector. If the selector does not match any Pod labels, the Service has no endpoints, and the DNS lookup returns no A records. This is the most common cause for a headless Service returning empty DNS results.

Exam trap

The trap here is that candidates often confuse headless Services with regular Services, assuming that a headless Service always returns A records for the Service name itself, when in fact it returns A records for the individual Pod IPs only if the selector matches Pods.

How to eliminate wrong answers

Option B is wrong because a headless Service explicitly sets clusterIP to None, not to an IP address; setting clusterIP to an IP address would make it a regular Service, not headless, and would still return A records for the Service IP. Option C is wrong because an ExternalName Service returns a CNAME record, not A records, and the question states the DNS query returns no A records, which is expected for ExternalName but not the cause of the issue. Option D is wrong because a volumeClaimTemplate in a StatefulSet is unrelated to DNS resolution; it defines persistent storage and does not affect whether the Service selector matches Pod labels.

227
Multi-Selectmedium

Which TWO are valid Service types? (Choose two.)

Select 2 answers
A.NodePort
B.Headless
C.Ingress
D.ClusterIP
E.Pod
AnswersA, D

Valid type.

Why this answer

A is correct because NodePort is a standard Kubernetes Service type that exposes a Service on a static port (30000-32767) on each Node's IP address, allowing external traffic to reach the Service. It works by opening that port on every node and routing traffic to the ClusterIP Service, which then forwards to the Pods.

Exam trap

The trap here is that candidates confuse Ingress or Headless as separate Service types, when in fact Ingress is a separate resource and Headless is a ClusterIP variant, not a distinct type.

228
MCQmedium

You need to configure a container to shut down gracefully when it receives a SIGTERM signal, with a timeout of 30 seconds before force kill. Which field in the Pod spec should you set?

A.activeDeadlineSeconds
B.livenessProbe.periodSeconds
C.restartPolicy
D.terminationGracePeriodSeconds
AnswerD

terminationGracePeriodSeconds is the correct Pod-level setting that determines how long Kubernetes waits between sending SIGTERM and the forced SIGKILL when a Pod is being terminated. This gives the main container process time to flush state, close connections, and complete cleanup. It is configurable per Pod in the Pod spec and defaults to 30 seconds; setting it appropriately is essential for graceful shutdown.

Why this answer

The `terminationGracePeriodSeconds` field in a Pod spec defines the duration (in seconds) that Kubernetes waits after sending a SIGTERM signal to the container's main process before forcefully killing it with SIGKILL. Setting this to 30 seconds allows the container to perform graceful shutdown tasks (e.g., closing connections, flushing data) within that window, meeting the requirement.

Exam trap

The trap here is confusing `terminationGracePeriodSeconds` with `activeDeadlineSeconds` (which limits Pod runtime) or assuming `restartPolicy` affects shutdown behavior, when in fact only `terminationGracePeriodSeconds` controls the SIGTERM-to-SIGKILL timeout.

How to eliminate wrong answers

Option A is wrong because `activeDeadlineSeconds` sets a hard time limit for the Pod's overall runtime (e.g., for Jobs), not the grace period for shutdown after SIGTERM. Option B is wrong because `livenessProbe.periodSeconds` controls how often the kubelet checks if the container is alive, not the termination behavior. Option C is wrong because `restartPolicy` determines whether containers are restarted after exit (Always, OnFailure, Never), and has no effect on the SIGTERM-to-SIGKILL timeout.

229
Multi-Selecteasy

Which TWO of the following are required to create a Role and RoleBinding that grants read access to Pods in the 'development' namespace? (Choose two.)

Select 2 answers
A.A NetworkPolicy that allows traffic to Pods
B.A ClusterRole with the same rules
C.A RoleBinding that binds the Role to a subject (User or ServiceAccount)
D.A ClusterRoleBinding that binds the Role to a subject
E.A Role with apiGroups: [""], resources: ["pods"], verbs: ["get", "list", "watch"]
AnswersC, E

A RoleBinding is the mandatory link that assigns the Role's permissions to a subject, such as a User, Group, or ServiceAccount, within a namespace. Without it, the Role exists in isolation and grants nothing. It also allows binding a ClusterRole, but here it binds the Role you created, completing the RBAC grant.

Why this answer

A RoleBinding is the Kubernetes resource that binds a Role (which defines permissions) to a specific subject (User, Group, or ServiceAccount) within a namespace. Without a RoleBinding, the permissions defined in the Role are not granted to any identity, making it a required component for granting access.

Exam trap

The trap here is that candidates often confuse RoleBindings with ClusterRoleBindings, thinking a ClusterRoleBinding is needed for a Role, or they mistakenly believe a NetworkPolicy is part of RBAC, when it is a separate network security mechanism.

230
MCQeasy

A Deployment has 3 replicas. You run 'kubectl scale deployment mydeploy --replicas=5'. What happens?

A.The command fails because you must edit the YAML directly.
B.A new Deployment is created with 5 replicas.
C.The Deployment is updated to have 5 replicas, and the ReplicaSet creates 2 additional pods.
D.The current ReplicaSet is deleted and a new one is created with 5 replicas.
AnswerC

When you run kubectl scale deployment demo --replicas=5, the Deployment's scale subresource is updated, and the Deployment controller reconciles by adjusting the desired replicas on the currently active ReplicaSet. Because the pod template is unchanged, no new ReplicaSet is created or replaced; the existing ReplicaSet's spec.replicas is set to 5, and its controller creates exactly two new pods to go from 3 to 5 running instances.

Why this answer

`kubectl scale` updates the Deployment's `spec.replicas` field to 5, which triggers the existing ReplicaSet to adjust its pod count. The ReplicaSet controller creates 2 additional pods to match the desired state, resulting in a total of 5 pods. The Deployment itself is not replaced, and no new ReplicaSet is created unless the pod template changes.

Exam trap

The trap here is that candidates often confuse scaling with rolling updates, assuming a new ReplicaSet is always created, but scaling only changes the replica count on the existing ReplicaSet unless the pod template is modified.

How to eliminate wrong answers

Option A is wrong because `kubectl scale` is a valid imperative command for changing replica counts without editing YAML directly. Option B is wrong because scaling does not create a new Deployment; it modifies the existing one. Option D is wrong because the current ReplicaSet is not deleted; it is updated to manage the new replica count, and a new ReplicaSet is only created if the pod template (e.g., container image) changes.

231
Multi-Selectmedium

Which TWO of the following are valid fields in a CronJob spec? (Select 2)

Select 2 answers
A.restartPolicy
B.concurrencyPolicy
C.completions
D.schedule
E.parallelism
AnswersB, D

concurrencyPolicy is a legitimate CronJob.spec field that controls how the controller handles Jobs that should be created while another Job from the same CronJob is still active. It accepts Allow, Forbid, or Replace; Allow starts a new Job immediately, Forbid skips the new run until the next schedule, and Replace cancels the active Job before starting a new one. This is a top-level scheduling-policy field, not something inherited from the Pod or Job template.

Why this answer

B is correct because `concurrencyPolicy` is a valid field in a CronJob spec that controls how concurrent executions of the job are handled. It can be set to `Allow`, `Forbid`, or `Replace`, which determines whether a new job can start while a previous one is still running.

Exam trap

CNCF often tests the distinction between CronJob spec fields and Job spec fields, trapping candidates who confuse `completions` and `parallelism` (Job-level) with CronJob-level fields like `schedule` and `concurrencyPolicy`.

232
MCQeasy

Which Service type is used to expose a Service externally using a cloud provider's load balancer?

A.NodePort
B.LoadBalancer
C.ExternalName
D.ClusterIP
AnswerB

LoadBalancer is correct because it instructs the cloud provider (e.g., AWS, GCP, Azure) to provision an external load balancer and assign a stable, publicly reachable IP address or DNS name. This traffic is automatically forwarded to the Service's backend pods, abstracting away node IPs and providing health checks and auto-scaling of the underlying infrastructure. It is the standard way to expose a Service to internet-facing external clients.

Why this answer

The LoadBalancer service type provisions an external load balancer from the underlying cloud provider (e.g., AWS ELB, GCP TCP/UDP Load Balancer) and assigns a public IP or DNS name to route external traffic to the Service's ClusterIP and NodePort. This is the correct choice because it directly exposes the Service externally via the cloud provider's infrastructure, unlike other types that either expose internally or require manual configuration.

Exam trap

The trap here is that candidates often confuse NodePort with LoadBalancer, thinking NodePort provides external exposure via a cloud load balancer, but NodePort only opens a port on each node's IP and does not integrate with cloud provider load balancers automatically.

How to eliminate wrong answers

Option A is wrong because NodePort exposes the Service on a static port on each node's IP address, requiring the client to know a node's IP and port, and does not automatically provision a cloud load balancer. Option C is wrong because ExternalName maps a Service to an external DNS name (via CNAME) without any proxying or load balancing, and does not expose the Service externally via a cloud load balancer. Option D is wrong because ClusterIP exposes the Service only on a cluster-internal IP, making it unreachable from outside the cluster without additional components like an ingress or proxy.

233
MCQhard

A StatefulSet named 'mysql' is deployed with 3 replicas. The administrator wants to create a headless Service so that each pod gets a unique DNS entry. Which Service specification should be used?

A.apiVersion: v1 kind: Service metadata: name: mysql spec: type: NodePort selector: app: mysql ports: - port: 3306
B.apiVersion: v1 kind: Service metadata: name: mysql spec: clusterIP: None selector: app: mysql ports: - port: 3306
C.apiVersion: v1 kind: Service metadata: name: mysql spec: type: ClusterIP selector: app: mysql ports: - port: 3306
D.apiVersion: v1 kind: Service metadata: name: mysql spec: clusterIP: "" selector: app: mysql ports: - port: 3306
AnswerB

Setting clusterIP: None creates a headless Service, which publishes the individual pod IPs and DNS names for a StatefulSet. When the selector matches the pods, Kubernetes creates A records like mysql-0.mysql.namespace.svc.cluster.local for each replica, enabling clients to address a specific pod. This is the correct way to provide stable network identities for stateful applications, which is exactly what a StatefulSet requires.

Why this answer

Setting `clusterIP: None` creates a headless Service, which is required for StatefulSets to provide stable network identities and unique DNS entries for each pod. A headless Service does not load-balance traffic; instead, it returns the pod IPs directly, enabling DNS resolution to individual pod hostnames like `mysql-0.mysql.default.svc.cluster.local`.

Exam trap

The trap here is that candidates often confuse setting `clusterIP: None` with leaving `clusterIP` empty or using an invalid value like `""`, or they mistakenly think a NodePort or default ClusterIP Service can provide per-pod DNS entries for StatefulSets.

How to eliminate wrong answers

Option A is wrong because `type: NodePort` creates a regular Service with a cluster IP and external port mapping, not a headless Service, so pods do not get unique DNS entries. Option C is wrong because `type: ClusterIP` (default) assigns a virtual IP for load balancing, which prevents per-pod DNS resolution; a headless Service requires `clusterIP: None`. Option D is wrong because setting `clusterIP: ""` is invalid syntax; Kubernetes requires the literal string `None` to designate a headless Service, and an empty string may cause an error or be ignored.

234
MCQhard

You are a platform engineer managing a Kubernetes cluster version 1.28. A development team has deployed a microservice application called 'order-processor' in the 'prod' namespace. The application consists of a frontend Pod 'frontend' and a backend Pod 'backend', each with a single container. The frontend needs to communicate with the backend using a headless Service named 'backend-svc' that selects Pods with label 'app:backend'. The backend Pods are expected to scale horizontally, and the frontend uses a DNS lookup to discover all backend Pod IPs for client-side load balancing. However, after deploying, the frontend is unable to resolve 'backend-svc' to any IP addresses. The backend Pod is running and has the correct label 'app:backend'. The Service 'backend-svc' is defined as a ClusterIP with clusterIP: None. The frontend container has the 'default' DNS policy. What is the most likely cause of the failure?

A.The headless Service must have the 'publishNotReadyAddresses: true' field to include not-ready Pods.
B.The Service and frontend are in different namespaces; the DNS name must be fully qualified.
C.The backend Pod does not have a readiness probe defined, so it is not considered ready and not added to DNS records.
D.The frontend Pod's DNS policy is set to 'None' which disables DNS resolution.
AnswerA

In a headless Service (`clusterIP: None`), DNS records are generated per ready Pod rather than for a single virtual IP. By default, Kubernetes excludes Pods whose readiness condition is false from DNS A/AAAA record lists, which means a not-ready backend Pod will not appear as a DNS entry and the frontend cannot reach it by name. Adding `publishNotReadyAddresses: true` to the Service spec instructs the cluster DNS to publish the addresses of all backing Pods regardless of readiness, enabling the frontend to discover even not-ready backends. This is the only correct option because it identifies the missing configuration attribute that directly affects DNS population.

Why this answer

A headless Service (clusterIP: None) creates DNS A/AAAA records only for Pods that are in the Ready state. If the backend Pod is running but not ready (e.g., due to a failing readiness probe or other conditions), the Service excludes it from DNS. Setting publishNotReadyAddresses: true on the Service would include all matching Pods regardless of readiness, allowing the frontend to discover the backend IPs.

Since the frontend cannot resolve any IPs, the most likely cause is that the Service is not configured to serve not-ready Pods.

Exam trap

The trap here is that candidates assume a headless Service always returns all matching Pod IPs regardless of readiness, but Kubernetes only publishes ready Pods to DNS unless explicitly configured otherwise.

How to eliminate wrong answers

Option A is wrong because 'publishNotReadyAddresses: true' is a legacy field (deprecated in 1.25) that forces inclusion of not-ready Pods in DNS; it is not required for headless Services and is not the default cause of the issue. Option B is wrong because the question states both the frontend and backend are in the 'prod' namespace, so no cross-namespace DNS qualification is needed; a simple service name resolves within the same namespace. Option D is wrong because the frontend container has the 'default' DNS policy (not 'None'), so DNS resolution is enabled and not disabled.

235
MCQhard

You have a Helm chart that deploys a web application. You want to conditionally include a ConfigMap in the release based on a value 'config.enabled'. Which template syntax correctly implements this?

A.{% if .Values.config.enabled %} (ConfigMap YAML) {% endif %}
B.{{- if .Values.config.enabled }} (ConfigMap YAML) {{- end }}
C.{{- when .Values.config.enabled }} (ConfigMap YAML) {{- end }}
D.{{#if .Values.config.enabled}} (ConfigMap YAML) {{/if}}
AnswerB

This is the correct Helm conditional: `{{- if` trims all whitespace before it so the ConfigMap YAML sits directly at the intended indentation level, and `{{- end }}` trims the trailing whitespace after the block. Helm checks whether `.Values.config.enabled` evaluates to a truthy value (true for booleans, non-empty for strings/lists/maps) and renders the enclosed YAML only in that case. The dash (`-`) is critical for producing clean YAML without stray blank lines that can break resource parsing.

Why this answer

Helm uses Go's text/template engine, where conditionals are written as {{ if ... }} ... {{ end }}. The {{- syntax trims preceding whitespace, which is idiomatic in Helm charts to avoid stray blank lines in rendered YAML. Option B correctly uses this Go template syntax with .Values.config.enabled as the condition.

Exam trap

CKAD often tests whether candidates confuse Helm's Go template syntax with Jinja2, Handlebars, or Ansible syntax — the delimiters {{ }} with 'if/end' are the giveaway for Helm.

How to eliminate wrong answers

Option A is wrong because {% if %} is Jinja2/Ansible syntax, not Go template syntax used by Helm. Option C is wrong because 'when' is not a Go template keyword — Helm uses 'if', not 'when' (that's Ansible). Option D is wrong because {{#if}}...{{/if}} is Handlebars/Mustache syntax, which Helm does not use.

236
MCQhard

A pod is running with a service account that has been granted a Role to get pods. The pod's code uses the Kubernetes API from within the container. However, the API call fails with a 403 Forbidden error. Which file should the pod read to obtain the authentication token?

A./var/run/secrets/kubernetes.io/serviceaccount/token
B./etc/kubernetes/admin.conf
C./var/run/secrets/kubernetes.io/serviceaccount/namespace
D./var/run/secrets/kubernetes.io/serviceaccount/ca.crt
AnswerA

Kubernetes projects the service account token into every pod at a fixed projected volume path. Reading /var/run/secrets/kubernetes.io/serviceaccount/token supplies the bearer token the pod presents to the API server, resolving the 403 caused by missing authentication.

Why this answer

The pod's service account token is automatically mounted at /var/run/secrets/kubernetes.io/serviceaccount/token. This token is a signed JWT that the pod uses to authenticate to the Kubernetes API server. Without reading this file, the pod cannot present valid credentials, resulting in a 403 Forbidden error.

Exam trap

CNCF often tests the distinction between the token file, the CA certificate, and the namespace file — candidates confuse the token with the CA cert or think the admin kubeconfig is accessible inside the pod.

How to eliminate wrong answers

Option B is wrong because /etc/kubernetes/admin.conf is the kubeconfig file for the cluster administrator, not for a pod's service account; it contains admin-level credentials and is not mounted inside pods. Option C is wrong because /var/run/secrets/kubernetes.io/serviceaccount/namespace contains only the namespace name, not an authentication token. Option D is wrong because /var/run/secrets/kubernetes.io/serviceaccount/ca.crt is the CA certificate used to verify the API server's TLS certificate, not an authentication token.

237
MCQmedium

A pod with the following security context is in CrashLoopBackOff. The container image runs as user 1000. securityContext: runAsUser: 2000 runAsGroup: 3000 fsGroup: 4000 What is the most likely cause?

A.runAsUser is set to 2000, but the container expects to run as user 1000
B.runAsGroup is set to 3000, but the container expects group 1000
C.The pod does not have enough CPU resources
D.fsGroup is set to 4000, causing volume mount permission issues
AnswerA

When runAsUser overrides the image's declared USER to 2000 while the application's files and configuration expect uid 1000, the process can't read or write its own runtime files, often encountering 'permission denied' at startup. This manifests as the container exiting immediately with a non-zero code, which Kubernetes reports as CrashLoopBackOff. The fix is to set runAsUser to 1000 or adjust file ownership to match 2000.

Why this answer

The container image is built to run as user 1000, but the Pod's securityContext overrides this with runAsUser: 2000. When the container starts, it attempts to access files or resources that require user 1000 permissions, causing it to fail and enter CrashLoopBackOff. The mismatch between the image's default user and the securityContext's runAsUser is the most direct cause of the crash.

Exam trap

CNCF often tests the nuance that runAsUser overrides the container image's default user, and candidates may incorrectly attribute the crash to group or volume issues without checking the actual user mismatch.

How to eliminate wrong answers

Option B is wrong because runAsGroup: 3000 does not conflict with the container expecting group 1000; the container image specifies a user (UID 1000), not a group, and group mismatches typically cause permission errors on files, not immediate crashes. Option C is wrong because insufficient CPU resources would manifest as a different error (e.g., OOMKilled or container pending), not a CrashLoopBackOff with a security context mismatch. Option D is wrong because fsGroup: 4000 affects volume mount permissions, but the question does not mention any volumes; without volumes, fsGroup has no effect, and even with volumes, it would cause permission errors on mounted files, not a crash on startup.

238
Multi-Selecteasy

Which TWO of the following are valid service types in Kubernetes?

Select 2 answers
A.NodePort
B.Headless
C.Ingress
D.Gateway
E.ClusterIP
AnswersA, E

NodePort is a valid Kubernetes Service type that builds on ClusterIP by additionally opening a static port (30000–32767 by default) on every node. Traffic sent to that nodePort is forwarded to the ClusterIP, then to backend Pods via the Service's selector. It is used when external clients need to reach a Service without a cloud load balancer, though it exposes the Service on each node's IP address and thus requires knowing node addresses and handling potential port collisions.

Why this answer

NodePort is a valid Kubernetes service type that exposes a service on a static port on each node's IP address, allowing external traffic to reach the service. It builds on top of ClusterIP by creating a cluster-wide port mapping that forwards traffic from the node's port to the service's ClusterIP and target port.

Exam trap

The CKAD exam often tests the distinction between core service types and other networking objects like Ingress or Gateway, leading candidates to mistakenly classify Ingress or Headless as service types when they are separate concepts.

239
MCQeasy

To create a service that will be accessible from outside the cluster using a cloud provider's load balancer, what type should be used?

A.NodePort
B.ClusterIP
C.ExternalName
D.LoadBalancer
AnswerD

A Service of type LoadBalancer instructs the cloud provider's controller to provision an external load balancer and route traffic to the backing pods. This satisfies the requirement for external accessibility through the provider's load balancer, unlike ClusterIP or NodePort.

Why this answer

The LoadBalancer service type (D) provisions an external load balancer from the cloud provider (e.g., AWS ELB, GCP TCP/UDP Load Balancer) and assigns a public IP or DNS name, making the service accessible from outside the cluster. This is the correct choice when the requirement explicitly states using a cloud provider's load balancer for external access.

Exam trap

The trap here is that candidates often confuse NodePort with LoadBalancer, thinking NodePort alone provides external access via a cloud load balancer, but NodePort only opens a port on each node and requires manual configuration of an external load balancer or direct node access.

How to eliminate wrong answers

Option A (NodePort) is wrong because it exposes the service on a static port on each node's IP, requiring the client to know a node's IP and port, and does not integrate with a cloud provider's load balancer. Option B (ClusterIP) is wrong because it exposes the service only on a cluster-internal IP, making it unreachable from outside the cluster. Option C (ExternalName) is wrong because it maps the service to an external DNS name (via CNAME) and does not expose any ports or provide external access through a load balancer.

240
MCQeasy

Which command shows resource usage (CPU/memory) of pods in the default namespace?

A.kubectl get pods -o wide
B.kubectl logs pod
C.kubectl top pod
D.kubectl describe pod
AnswerC

kubectl top pod is the correct command because it queries the metrics API (typically backed by metrics-server) to retrieve and display live CPU and memory usage for each pod. It shows current resource consumption at the container and pod level, and optionally displays per-container details with the --containers flag. This makes it the standard command for quick, immediate resource observation.

Why this answer

`kubectl top pod` is the Kubernetes command that displays real-time CPU and memory usage metrics for pods, leveraging the metrics server to collect resource utilization data. This command is essential for monitoring pod performance and is part of the Application Observability and Maintenance domain.

Exam trap

The trap here is that candidates often confuse `kubectl get pods -o wide` or `kubectl describe pod` with resource monitoring commands, but neither provides live CPU/memory metrics, which only `kubectl top pod` (with the Metrics Server) can deliver.

How to eliminate wrong answers

Option A is wrong because `kubectl get pods -o wide` shows pod details like node IP and pod IP, but does not include CPU or memory usage metrics. Option B is wrong because `kubectl logs pod` retrieves container logs, not resource usage statistics. Option D is wrong because `kubectl describe pod` provides detailed configuration and status information, but does not display live CPU or memory consumption data.

241
Multi-Selecthard

Which THREE of the following are valid fields in a PodSecurityContext that affect container security? (Select 3)

Select 3 answers
A.capabilities
B.runAsUser
C.runAsGroup
D.privileged
E.fsGroup
AnswersB, C, E

runAsUser is a valid field in PodSecurityContext, specifying the numeric UID that all containers in the pod must run with. It overrides any user defined in the container image, enforcing a non-root user consistently across the pod. This field is also available at the container level, but when set at the pod level it applies to every container unless an individual container overrides it.

Why this answer

(runAsUser) is correct because it is a valid field in a PodSecurityContext that specifies the user ID (UID) under which all containers in the pod run. This field directly affects container security by controlling privilege levels and access to host resources, overriding the container's default user.

Exam trap

The trap here is that candidates often confuse PodSecurityContext fields (which affect all containers in the pod) with container-level SecurityContext fields (which affect only a single container), leading them to incorrectly select 'capabilities' or 'privileged' as pod-level options.

242
MCQhard

A ClusterIP service named 'svc' has no endpoints. Which command can you use to debug why the service is not routing traffic?

A.kubectl get endpoints svc
B.kubectl describe service svc
C.kubectl logs svc
D.kubectl exec -it svc -- /bin/sh
AnswerA

This command directly queries the Endpoints API object that shares the Service's name, displaying the backend pod IPs and ports that the ClusterIP Service routes to. When the selector no longer matches any pods, the output shows `<none>` for the endpoints list, confirming there is no backing set of pods. It is the canonical way to verify the existence (or absence) of endpoints for a Service.

Why this answer

`kubectl get endpoints svc` directly shows the list of pod IPs and ports that the ClusterIP service is routing traffic to. If the service has no endpoints, this command will return an empty list, confirming that no pods match the service's selector, which is the most common reason for traffic not being routed.

Exam trap

The trap here is that candidates often assume `kubectl describe service` is sufficient to debug endpoint issues, but it only shows the selector, not the actual endpoints, so you must explicitly check the endpoints object to confirm the routing target is missing.

How to eliminate wrong answers

Option B is wrong because `kubectl describe service svc` provides details like the service type, cluster IP, selector, and port mapping, but it does not show the actual endpoints; it only shows the selector labels, which may be misconfigured but does not directly confirm the absence of endpoints. Option C is wrong because `kubectl logs svc` is invalid; services are not pods and do not have logs to retrieve — this command would fail with an error. Option D is wrong because `kubectl exec -it svc -- /bin/sh` attempts to execute a command inside a service, which is not a running container; services are virtual resources and cannot be exec'd into.

243
MCQeasy

A pod needs to run as a non-root user. Which securityContext field should be set to enforce this?

A.runAsGroup: 3000
B.runAsUser: 1000
C.readOnlyRootFilesystem: true
D.runAsNonRoot: true
AnswerD

runAsNonRoot: true is a securityContext validation that ensures the container will not start if it is configured to run as root. Kubernetes checks the user defined in the image metadata (or the runtime user) and refuses to launch the pod if the UID is 0 or unspecified. This directly enforces the non-root requirement, providing a hard guarantee that the container runs with an unprivileged user ID. It is the only option that actively prevents root execution, making it the correct choice for this question.

Why this answer

Setting `runAsNonRoot: true` in the pod's securityContext explicitly enforces that the container must not run as the root user (UID 0). If the container image attempts to run as root, the Pod will fail to start, ensuring compliance with non-root security policies.

Exam trap

The trap here is that candidates often confuse `runAsUser: 1000` with enforcing non-root execution, but it only sets a user ID and does not prevent the container from running as root if the image's entrypoint ignores the UID setting.

How to eliminate wrong answers

Option A is wrong because `runAsGroup: 3000` only sets the primary group ID for the container's processes, not the user ID, so it does not prevent running as root. Option B is wrong because `runAsUser: 1000` sets a specific user ID (1000) but does not enforce that the container cannot run as root; if the image runs as root, this field is ignored unless the image respects the user ID override. Option C is wrong because `readOnlyRootFilesystem: true` makes the root filesystem read-only but does not restrict the user ID, so the container could still run as root.

244
MCQhard

A Kubernetes Job with parallelism=3 and completions=6 is created. How many pods will run concurrently at most?

A.3
B.9
C.6
D.1
AnswerA

In Kubernetes Jobs, the 'parallelism' field specifies the maximum number of Pods that may run concurrently. Here it is explicitly set to 3, so at most three Pods will be active at any given time, regardless of how many have completed. Completions only sets the total number of successful Pods required (6), not the concurrency limit.

Why this answer

The `parallelism` field in a Kubernetes Job specifies the maximum number of pods that can run concurrently. With `parallelism=3`, at most 3 pods will run at the same time, regardless of the total number of completions required.

Exam trap

The trap here is confusing `parallelism` (max concurrent pods) with `completions` (total successful pods needed), leading candidates to multiply or add the two values incorrectly.

How to eliminate wrong answers

Option B is wrong because 9 would be the product of parallelism and completions, but Kubernetes does not multiply these values; parallelism caps concurrent pods, not total pods. Option C is wrong because completions=6 sets the total number of successful pod completions needed, not the concurrency limit. Option D is wrong because 1 would be the default parallelism if not set, but here parallelism is explicitly set to 3.

245
MCQhard

A deployment 'api-deploy' has resource limits set but is frequently being OOMKilled. The team suspects the memory limit is too low. Which approach should be taken to confirm this without causing downtime?

A.Create a new pod with a higher memory limit and delete the old pods manually.
B.Set the memory limit to unlimited by removing the limit section and restart the pod.
C.Use 'kubectl set resources' to increase the limit on the running pod dynamically.
D.Increase the memory limit in the deployment spec and apply the change; the rollout will automatically restart pods.
AnswerD

Editing the Deployment's pod template and applying the manifest updates the desired state, which makes the Deployment controller create a new ReplicaSet while scaling down the old one according to the configured strategy (default RollingUpdate). New pods are launched with the increased memory limit, and old pods are terminated only once the new ones are Healthy, keeping the service available throughout. Because the Pod spec is immutable, the template change is the declarative, supported path to alter resources without manual pod handling.

Why this answer

Updating the deployment spec triggers a rolling update, which replaces pods with new ones having the increased memory limit without downtime. This approach leverages Kubernetes' deployment controller to manage the rollout automatically, ensuring service continuity while adjusting resource limits.

Exam trap

The trap here is that candidates confuse 'kubectl set resources' with a dynamic in-place update, not realizing it modifies the deployment spec and requires a rollout to take effect, similar to editing the YAML directly.

How to eliminate wrong answers

Option A is wrong because manually creating and deleting pods bypasses the deployment's desired state management, risking configuration drift and potential downtime if not coordinated properly. Option B is wrong because removing the memory limit entirely can lead to resource starvation for other pods and violates Kubernetes best practices; it also requires restarting the pod, causing downtime. Option C is wrong because 'kubectl set resources' modifies the deployment spec, not the running pod directly; the pod must be recreated to apply the new limits, and the command triggers a rollout, not a dynamic in-place update.

246
MCQmedium

You want to set environment variable 'DB_URL' in a pod from the key 'url' in ConfigMap 'db-config'. Which YAML snippet is correct?

A.envFrom: - configMapRef: name: db-config
B.env: - name: DB_URL valueFrom: configMapKeyRef: name: db-config key: url
C.env: - name: DB_URL valueFrom: secretKeyRef: name: db-config key: url
D.env: - name: DB_URL valueFrom: configMap: name: db-config key: url
AnswerB

This is the correct syntax for referencing a single key from a ConfigMap. The valueFrom.configMapKeyRef field tells Kubernetes to look up the ConfigMap named db-config, read the value stored under the key url, and assign it to the environment variable DB_URL. This enables precise, selective injection of configuration data without importing the entire ConfigMap.

Why this answer

It uses the `configMapKeyRef` field under `valueFrom` to inject a specific key ('url') from a ConfigMap ('db-config') into the environment variable 'DB_URL'. This is the precise syntax required to reference a single key from a ConfigMap in a pod's environment variable definition.

Exam trap

CNCF often tests the distinction between `envFrom` (inject all keys) and `env` with `configMapKeyRef` (inject a single key), and the trap here is that candidates confuse `configMapKeyRef` with the invalid `configMap` or mistakenly use `secretKeyRef` for ConfigMap data.

How to eliminate wrong answers

Option A is wrong because `envFrom` with `configMapRef` injects all key-value pairs from the ConfigMap as environment variables, not a single specific key into a named variable. Option C is wrong because `secretKeyRef` is used to reference keys from a Secret, not a ConfigMap; using it here would cause a runtime error or fail to resolve the value. Option D is wrong because `configMap` is not a valid field under `valueFrom`; the correct field is `configMapKeyRef`.

247
MCQeasy

Which of the following is a valid Pod Security Admission standard?

A.Privileged, Default
B.Default
C.Restricted
D.Secure
AnswerC

Restricted is a valid Pod Security Admission standard, representing the most stringent level. It enforces namespaces and pods to follow best practices such as disallowing privileged containers, dropping all capabilities, and setting a non-root user. This standard is often chosen for sensitive production workloads to minimize container escape risks.

Why this answer

The Pod Security Admission (PSA) standard defines three levels: Privileged, Baseline, and Restricted. Option C is correct because 'Restricted' is one of the three valid standards, designed to enforce the most restrictive pod security policies.

Exam trap

The trap here is that candidates may confuse 'Default' with the 'Baseline' standard, or assume 'Secure' is a valid level, when in fact only Privileged, Baseline, and Restricted are defined in the Kubernetes documentation.

How to eliminate wrong answers

Option A is wrong because 'Default' is not a valid Pod Security Admission standard; the three standards are Privileged, Baseline, and Restricted. Option B is wrong because 'Default' alone is not a valid standard; the valid standards are Privileged, Baseline, and Restricted. Option D is wrong because 'Secure' is not a valid Pod Security Admission standard; the valid standards are Privileged, Baseline, and Restricted.

248
Multi-Selectmedium

Which TWO statements about Kustomize are true?

Select 2 answers
A.Kustomize can be used to perform canary deployments.
B.Kustomize supports overlays that allow different configurations for different environments.
C.Kustomize requires Helm to manage dependencies.
D.Kustomize uses a file named kustomization.yaml to define resources and customizations.
E.Kustomize can only be used with kubectl apply -k.
AnswersB, D

Kustomize's overlay mechanism layers environment-specific patches on top of a base kustomization, allowing you to modify replicas, images, or namespaces per environment. The base directory holds common resources, and overlays reference it via a `kustomization.yaml` with fields like `resources` and `patchesStrategicMerge`. This avoids duplicating manifests and keeps a single source of truth across dev, staging, and production.

Why this answer

Kustomize supports overlays, which are layered patches applied on top of a base configuration. This allows you to define a common base set of Kubernetes resources and then use different overlay directories (e.g., dev, staging, prod) to customize settings like replicas, image tags, or namespaces for each environment without duplicating the entire manifest.

Exam trap

CNCF often tests the misconception that Kustomize is a deployment strategy tool (like for canaries) rather than a configuration customization tool, and that it is tightly coupled to kubectl or Helm, when in fact it is a standalone declarative customization engine.

249
MCQeasy

Which kubectl command can be used to see the rollout status of a Deployment named 'web-app'?

A.kubectl rollout history deployment web-app
B.kubectl describe deployment web-app
C.kubectl status deployment web-app
D.kubectl rollout status deployment web-app
AnswerD

`kubectl rollout status deployment web-app` is the correct command to monitor a Deployment's rollout progress. It blocks and repeatedly polls the Deployment's status, providing real-time updates until the rollout completes successfully, or it exits with an error if the rollout gets stuck. This command is specifically designed to report the rollout state, waiting for the new ReplicaSet to become fully available.

Why this answer

`kubectl rollout status deployment web-app` is the dedicated command to monitor the rollout progress of a Deployment, showing whether the new ReplicaSet has been fully rolled out or if the rollout is still in progress. It provides real-time updates on the status of the rollout, such as waiting for pods to become ready or successfully completing the update.

Exam trap

The trap here is that candidates may confuse `kubectl rollout status` with `kubectl rollout history` or mistakenly think `kubectl describe` provides the same real-time rollout progress, when in fact `describe` only shows a snapshot of conditions without actively waiting for completion.

How to eliminate wrong answers

Option A is wrong because `kubectl rollout history deployment web-app` displays the revision history of the Deployment (i.e., previous rollout revisions), not the current rollout status. Option B is wrong because `kubectl describe deployment web-app` shows the current configuration and state of the Deployment, including conditions like Available and Progressing, but it does not provide a live, streaming rollout status or indicate whether a rollout is still in progress. Option C is wrong because `kubectl status deployment web-app` is not a valid kubectl command; the correct verb for checking rollout status is `rollout status`, not `status`.

250
Multi-Selectmedium

Which TWO statements about kubectl apply vs kubectl create are correct? (Select two)

Select 2 answers
A.kubectl create can update existing resources if the --force flag is used
B.kubectl apply only works with Deployments
C.kubectl apply can update existing resources; kubectl create will error if resource exists
D.kubectl create can be used to update resources by providing the full YAML
E.kubectl apply maintains a last-applied-configuration annotation; kubectl create does not
AnswersC, E

kubectl apply computes a patch between the desired configuration in your file and the current live object, then merges changes into the existing resource, thus it can update resources. In contrast, kubectl create sends a POST request to the API server and expects to create a brand-new object; if the resource already exists, the API server returns a 409 Conflict error. This fundamental difference makes apply the preferred tool for declarative updates.

Why this answer

C is correct because `kubectl apply` uses a declarative approach: it creates a resource if it does not exist and updates it if it already exists, merging changes based on the last-applied-configuration annotation. In contrast, `kubectl create` is imperative and will return an error if the resource already exists, as it expects to create a new resource from scratch.

Exam trap

The trap here is that candidates often confuse the imperative `kubectl create` with the declarative `kubectl apply`, mistakenly believing `create` can update resources or that `apply` is limited to specific resource types.

251
Drag & Dropmedium

Sequence the steps to troubleshoot a Pod stuck in CrashLoopBackOff state.

Drag or tap steps into the slots.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4

Why this order

Start by checking status, then inspect logs and events to diagnose. Fix the issue, then restart the Pod.

252
MCQeasy

Which kubectl command creates a ConfigMap named 'app-config' from a file 'config.properties'?

A.kubectl create configmap app-config --from-file=config.properties
B.kubectl create configmap app-config --file config.properties
C.kubectl create configmap app-config --from-env-file config.properties
D.kubectl create configmap app-config --from-literal config.properties
AnswerA

This command is correct because `--from-file=config.properties` instructs kubectl to create a ConfigMap whose data contains a single key `config.properties` (the file basename) with the file's full contents as its value. This is the standard, documented way to import a file verbatim into a ConfigMap, and it does not require any extra flags or formatting assumptions about the file's internal structure.

Why this answer

`kubectl create configmap` with the `--from-file` flag creates a ConfigMap from a file, using the filename as the key and the file content as the value. This is the standard Kubernetes method to import configuration data from a local file into a ConfigMap resource.

Exam trap

The trap here is confusing `--from-file` (which stores the entire file as a single entry) with `--from-env-file` (which parses key-value pairs), leading candidates to choose option C when they need to preserve the file's original format.

How to eliminate wrong answers

Option B is wrong because `--file` is not a valid flag for `kubectl create configmap`; the correct flag is `--from-file`. Option C is wrong because `--from-env-file` imports the file as environment variables (key=value pairs per line), not as a single key-value entry, which changes the data structure. Option D is wrong because `--from-literal` is used to specify key-value pairs directly on the command line (e.g., `--from-literal=key=value`), not to reference a file.

253
MCQeasy

You are a Kubernetes administrator responsible for a production cluster. A development team has deployed a Pod named 'app-pod' that runs a container with a PostgreSQL database. The team reports that the Pod is failing to start with an error: 'Error: container has runAsNonRoot and image will run as root (runtime error)'. The Pod YAML is as follows: ```yaml apiVersion: v1 kind: Pod metadata: name: app-pod spec: containers: - name: db image: postgres:latest securityContext: runAsNonRoot: true ``` The team wants to ensure the container runs securely without running as root. What is the BEST course of action?

A.Add `runAsUser: 999` to the container's securityContext to run the container as the postgres user.
B.Remove `runAsNonRoot: true` from the securityContext to allow the container to run as root.
C.Increase the Pod's resource limits because the error is due to insufficient memory.
D.Create a PodSecurityPolicy that allows running as root.
AnswerA

Setting `runAsUser: 999` explicitly instructs the kubelet to start the container process with UID 999, which is non-zero. This satisfies the `runAsNonRoot: true` validation because the runtime verifies that the effective UID is not 0. Since the Postgres image commonly defines a `postgres` user with UID 999, this aligns with the image's intended user and avoids running as root. This is the standard, least-privilege fix for a `runAsNonRoot` enforcement failure.

Why this answer

The PostgreSQL official image runs as the 'postgres' user with UID 999 by default. Adding `runAsUser: 999` to the container's securityContext overrides the user to a non-root UID, satisfying the `runAsNonRoot: true` constraint and allowing the container to start without the runtime error.

Exam trap

The trap here is that candidates may think removing `runAsNonRoot` is the simplest fix, but the question explicitly requires the container to run securely without root, so the correct action is to specify a non-root user ID rather than disabling the security constraint.

How to eliminate wrong answers

Option B is wrong because removing `runAsNonRoot: true` would allow the container to run as root, which violates the security requirement to run securely without running as root. Option C is wrong because the error message explicitly states a security context violation (runAsNonRoot vs. root image), not a resource constraint; increasing resource limits would not resolve a security context error. Option D is wrong because a PodSecurityPolicy (PSP) is a cluster-level admission controller that can enforce policies, but it does not change the container's user ID; the immediate fix is to set a non-root user in the Pod spec, and PSPs are deprecated in Kubernetes 1.21+ and removed in 1.25.

254
MCQeasy

Which command creates a ConfigMap named 'app-config' with two keys: 'key1=value1' and 'key2=value2'?

A.kubectl create configmap app-config --from-literal key1=value1 --from-literal key2=value2
B.kubectl create configmap app-config --from-literal=key1=value1,key2=value2
C.kubectl create configmap app-config --from-file key1=value1 --from-file key2=value2
D.kubectl create configmap app-config --from-env-file=key1=value1 --from-env-file=key2=value2
AnswerA

Using `kubectl create configmap app-config --from-literal key1=value1 --from-literal key2=value2` is correct because the `--from-literal` flag is designed to accept exactly one `key=value` pair, and repeating the flag accumulates each pair into the ConfigMap's `data` field. This is the canonical CLI syntax for defining inline literals directly from the command line, with no dependency on files or external input.

Why this answer

`kubectl create configmap` with the `--from-literal` flag allows you to specify key-value pairs directly on the command line. Each `--from-literal` flag creates one entry in the ConfigMap, so using two separate flags correctly creates a ConfigMap named 'app-config' with keys 'key1' and 'key2' mapped to 'value1' and 'value2' respectively.

Exam trap

The trap here is that candidates confuse `--from-literal` with `--from-file` or `--from-env-file`, or incorrectly assume that `--from-literal` accepts comma-separated syntax, leading them to choose options that either attempt to read nonexistent files or create a single malformed key.

How to eliminate wrong answers

Option B is wrong because `--from-literal` does not accept comma-separated key-value pairs; it expects a single key=value argument per flag, and using a comma would create a single key named 'key1=value1,key2=value2' instead of two separate keys. Option C is wrong because `--from-file` is used to load data from files on disk, not to specify literal key-value pairs; using it with 'key1=value1' would attempt to read a file named 'key1=value1' which does not exist. Option D is wrong because `--from-env-file` is used to load multiple key-value pairs from a file formatted as environment variables (e.g., a .env file), not to specify individual literals on the command line.

255
MCQeasy

Which of the following is the correct way to scale a Deployment named 'api' to 5 replicas using kubectl?

A.kubectl scale deployment api --replicas=5
B.kubectl scale deploy api 5
C.kubectl update deployment api --replicas=5
D.kubectl set replicas deployment api 5
AnswerA

The `kubectl scale` command is the canonical Kubernetes imperative operation for altering the desired replica count of a resource. Using `deployment api --replicas=5` explicitly identifies the resource type and name while supplying the target count through the mandatory `--replicas` flag. This triggers the scale subresource of the Deployment, updating its `spec.replicas`, and the corresponding ReplicaSet controller then adjusts pods to match. This syntax is correct because every required argument is provided and no invalid flags are used.

Why this answer

`kubectl scale deployment api --replicas=5` is the standard kubectl command to change the replica count of a Deployment. The `scale` subcommand directly modifies the `.spec.replicas` field in the Deployment's manifest, instructing the ReplicaSet controller to adjust the number of Pods to match the desired count.

Exam trap

The trap here is that candidates may confuse `kubectl scale` with other imperative commands like `kubectl set` or incorrectly assume positional arguments work for the replica count, leading them to choose options that resemble valid but non-existent syntax.

How to eliminate wrong answers

Option B is wrong because `kubectl scale deploy api 5` omits the `--replicas` flag; the `scale` command requires the `--replicas` flag (or `--replicas=` syntax) to specify the target count, and positional arguments are not accepted for the replica count. Option C is wrong because `kubectl update` is not a valid kubectl subcommand; the correct command to modify a resource is `kubectl edit`, `kubectl patch`, or `kubectl apply`, not `update`. Option D is wrong because `kubectl set replicas` is not a valid command; the correct subcommand for scaling is `kubectl scale`, and `kubectl set` is used for other purposes like `kubectl set image` or `kubectl set resources`, not for setting replica counts.

256
Multi-Selecteasy

Which TWO of the following are true about headless services? (Select 2)

Select 2 answers
A.DNS returns multiple A records, one for each pod's IP
B.They set 'clusterIP: None' in the service spec
C.They provide a stable virtual IP for load balancing
D.They cannot have a selector
E.They are used exclusively with Deployments
AnswersA, B

In a headless service, no cluster IP is allocated, so the DNS name for the service resolves directly to the set of pod IPs that match its selector. Kubernetes DNS, typically CoreDNS, returns a separate A record for each matching pod IP, allowing clients to discover and connect to each pod independently. This behavior is essential for peer discovery in StatefulSet-based distributed systems, where each replica must be addressed individually.

Why this answer

Headless services (with clusterIP: None) cause DNS to return multiple A records, one for each pod's IP address, rather than a single virtual IP. This allows direct pod-to-pod DNS resolution, which is essential for stateful applications like databases that need to discover individual pod endpoints.

Exam trap

A common misconception is that headless services cannot have selectors, but they can; the key difference is that without a selector, you must manually manage Endpoints or use ExternalName, while with a selector, DNS returns pod IPs directly.

257
MCQmedium

A Deployment named 'web-app' has 4 replicas. You need to perform a rolling update with a maxSurge of 50% and maxUnavailable of 25%. Which YAML snippet configures this correctly?

A.strategy: rollingUpdate: surge: 50% unavailable: 25%
B.strategy: rollingUpdate: maxSurge: 50% maxUnavailable: 25%
C.strategy: rollingUpdate: maxSurge: 2 maxUnavailable: 1
D.strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 50%
AnswerB

This correctly sets `maxSurge: 50%` and `maxUnavailable: 25%`, which are the exact fields and values requested for managing the rolling update. With four replicas, 50% surge translates to two extra pods (rounded up), allowing up to six pods, while 25% unavailable translates to one pod down (rounded down), guaranteeing at least three pods remain available during the update. This is the valid YAML representation of a rolling update with a 50% surge and 25% maximum unavailability.

Why this answer

Ly uses the fields maxSurge and maxUnavailable with the required percentages (50% and 25%). Option A uses incorrect field names (surge, unavailable). Option C uses absolute numbers instead of percentages.

Option D swaps the values (maxSurge: 25%, maxUnavailable: 50%). Therefore, option B is the correct configuration for the rolling update.

258
MCQmedium

A ClusterRole named 'pod-reader' allows get, list, and watch on pods. A RoleBinding 'read-pods' in namespace 'default' binds this ClusterRole to user 'jane'. Which statement is true?

A.User 'jane' can read pods in all namespaces because ClusterRole is cluster-scoped
B.The RoleBinding must be changed to a ClusterRoleBinding for it to work
C.User 'jane' can read pods and also delete them because ClusterRole gives full access
D.User 'jane' can read pods only in the 'default' namespace
AnswerD

A RoleBinding always grants permissions only in the namespace where the binding itself is defined, regardless of whether it references a Role or a ClusterRole. Here, the ClusterRole supplies the pod read rules (get, list, watch), but the RoleBinding limits those rules to the 'default' namespace. As a result, Jane can read pods only in that namespace, not in any other.

Why this answer

A RoleBinding in a specific namespace binds a ClusterRole to a subject only within that namespace. Since the RoleBinding 'read-pods' is in the 'default' namespace, user 'jane' receives the permissions defined in the 'pod-reader' ClusterRole (get, list, watch on pods) only within the 'default' namespace, not across all namespaces.

Exam trap

The trap here is that candidates often assume a ClusterRole always grants cluster-wide permissions, forgetting that a RoleBinding scopes those permissions to a single namespace, while a ClusterRoleBinding is needed for true cluster-wide access.

How to eliminate wrong answers

Option A is wrong because a RoleBinding binds a ClusterRole to a subject only within the namespace where the RoleBinding exists, not across all namespaces; a ClusterRoleBinding would be required for cluster-wide access. Option B is wrong because a RoleBinding can bind a ClusterRole to a subject within a specific namespace, so it works correctly as is; no change to a ClusterRoleBinding is needed. Option C is wrong because the 'pod-reader' ClusterRole only grants get, list, and watch permissions on pods, not delete; a ClusterRole does not imply full access, only the permissions explicitly defined in its rules.

259
MCQeasy

Which command shows resource usage (CPU and memory) for pods in a namespace?

A.kubectl top node
B.kubectl top pod -n <namespace>
C.kubectl top pods
D.kubectl get pods --show-labels
AnswerB

This is the correct command because it directly queries the metrics API for pod-level CPU and memory usage from the Metrics Server. The `-n` flag scopes the output to a specific namespace, and when combined with a pod name or label selector it shows live resource consumption for those pods. Without `-n`, it defaults to the current namespace, but specifying it explicitly ensures you are viewing the intended namespace.

Why this answer

The `kubectl top pod` command is the correct way to view real-time CPU and memory usage for pods in a specific namespace. The `-n <namespace>` flag targets the desired namespace, and the command relies on the metrics-server to collect resource usage data from the kubelet's cAdvisor endpoint.

Exam trap

The trap here is that candidates often confuse `kubectl top pod` (which requires the metrics-server) with `kubectl describe pod` (which shows resource requests/limits, not actual usage), or they omit the `-n` flag and assume it works across all namespaces.

How to eliminate wrong answers

Option A is wrong because `kubectl top node` shows resource usage for nodes (the entire worker machine), not for individual pods within a namespace. Option C is wrong because `kubectl top pods` without a namespace flag defaults to the current context's namespace (often `default`), not the specified namespace, and is incomplete without `-n`. Option D is wrong because `kubectl get pods --show-labels` only lists pod metadata and labels, not CPU or memory usage metrics.

260
MCQhard

You apply the following Ingress manifest: apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: app-ingress spec: ingressClassName: nginx rules: - host: example.com http: paths: - path: /api pathType: Prefix backend: service: name: api-service port: number: 80 The Ingress controller logs show a 404 error when accessing 'http://example.com/api'. The service 'api-service' exists and is reachable via ClusterIP. What is the most likely cause?

A.The service 'api-service' is in a different namespace
B.The service port (80) does not match the container port
C.The IngressClass 'nginx' is not installed or configured
D.The path '/api' should be pathType: Exact
AnswerC

This is the correct explanation. The Ingress resource specifies 'ingressClassName: nginx', but if no IngressClass named 'nginx' exists, or the NGINX Ingress controller is not installed and configured to watch that class, the Ingress will have no active controller to reconcile it. As a result, no forwarding rules are programmed into any reverse proxy, and requests to '/api' produce a 404. Without a matching IngressClass and running controller, the Ingress is effectively inert.

Why this answer

The Ingress controller logs a 404 error because the Ingress resource references `ingressClassName: nginx`, but the NGINX Ingress Controller is not installed or its IngressClass resource is not configured in the cluster. Without a matching IngressClass, the controller ignores this Ingress, so no routing rules are applied, and the default backend (if any) or the controller itself returns a 404. The service exists and is reachable, but the Ingress controller never processes the rules.

Exam trap

The CKAD exam often tests the misconception that a 404 error from an Ingress controller implies a missing service or wrong path, when in fact the Ingress resource itself is not being processed due to a missing or misconfigured IngressClass.

How to eliminate wrong answers

Option A is wrong because Ingress resources can route traffic to services in any namespace, and the question does not specify a namespace mismatch; the service is reachable via ClusterIP, so namespace is not the issue. Option B is wrong because the service port (80) is used for routing within the cluster, and the container port is irrelevant as long as the service targets the correct pod port; the error is a 404 from the Ingress controller, not a connection timeout or refused connection. Option D is wrong because pathType: Prefix with path /api correctly matches requests starting with /api, and changing to Exact would only match the literal path /api, which would still not resolve the 404 if the Ingress controller is not processing the resource.

261
MCQmedium

You need to view the logs of a container that previously crashed and has been restarted. Which flag do you use with 'kubectl logs'?

A.--all-containers
B.--tail
C.--previous
D.-f
AnswerC

The --previous flag specifically tells kubectl to display logs from the prior container instance that ran in the pod, typically one that has terminated due to a crash or a restart. The kubelet retains the terminated container's logs in a separate file, and this flag directs kubectl to that historical log while ignoring the current container's output. This is exactly what you need to diagnose why a container previously crashed, as it shows the last output before the failure.

Why this answer

The `--previous` flag is used with `kubectl logs` to view logs from the previous instance of a container that has crashed and been restarted. This allows you to inspect the logs of the terminated container before the restart, which is essential for debugging crash loops.

Exam trap

CNCF often tests the distinction between flags that affect log output formatting (`--tail`, `-f`) versus flags that change which container instance's logs are accessed (`--previous`), leading candidates to confuse `--tail` or `-f` as solutions for viewing previous crash logs.

How to eliminate wrong answers

Option A is wrong because `--all-containers` is used to stream logs from all containers in a pod, not specifically from a previously crashed container. Option B is wrong because `--tail` limits the number of lines shown from the log output, but it does not retrieve logs from a previous container instance. Option D is wrong because `-f` (follow) streams logs in real-time, which is useful for live monitoring but does not access historical logs from a crashed container.

262
MCQmedium

You are implementing a blue-green deployment using Kubernetes Deployments and Services. The 'blue' Deployment runs version 1.0, and the 'green' Deployment runs version 2.0. What is the key mechanism to switch traffic from blue to green?

A.Scale down the blue Deployment to 0 replicas
B.Delete the blue Deployment
C.Change the Service type from ClusterIP to NodePort
D.Update the Service's label selector to match the green Deployment's pod labels
AnswerD

Updating the Service's label selector to match the green Deployment's pod labels is the correct control point for traffic shifting. When the selector changes, the EndpointSlice controller re-evaluates matching Pods and replaces blue pod IPs with green pod IPs, atomically switching the backend. This approach preserves the ability to instantly roll back by reverting the selector to blue labels, provided the blue Deployment remains available.

Why this answer

By updating the Service's label selector to match the green Deployment's pod labels, the Service routes traffic to the new version.

263
MCQeasy

A developer deployed a pod named 'web-pod' with a single container. Users report intermittent 502 errors. The developer wants to see CPU and memory consumption of that specific container to determine whether it is being throttled. Which command should be used?

A.kubectl describe pod web-pod
B.kubectl logs web-pod --timestamps
C.kubectl top pod web-pod --containers
D.kubectl get pod web-pod -o yaml
AnswerC

This command queries the Metrics Server through the metrics.k8s.io API and prints per-container CPU and memory usage for the named pod. The --containers flag is required to break the output down by container when a pod has more than one, and it works fine for single-container pods too, giving exactly the usage figures needed to spot throttling.

Why this answer

Live resource consumption for a running pod is exposed through the Metrics Server and surfaced by the kubectl top subcommand. Requesting a per-container breakdown with the --containers flag gives the developer actual CPU and memory numbers for the named pod. Comparing those numbers against the container's declared limits is how throttling or memory pressure is confirmed, which describe, get -o yaml, and logs cannot provide.

Exam trap

The trap here is assuming that kubectl describe reports live CPU and memory usage, when it only shows declared requests and limits plus events.

264
MCQeasy

You have a Deployment running a web server that takes 30 seconds to initialize. You want to ensure that the load balancer does not send traffic to the pod until it is ready. Which probe should you configure?

A.Readiness probe
B.Resource limit
C.Startup probe
D.Liveness probe
AnswerA

The readiness probe is the correct mechanism because it directly controls whether a pod is added to or removed from the endpoints of a Service. When the probe fails, the kubelet marks the pod as NotReady, and the endpoints controller immediately removes its IP from all backing Services, stopping new traffic. This is essential for deployments where the application needs time to warm up or load data before accepting requests, and it also enables zero-downtime rolling updates by holding back new pods until they are fully operational.

Why this answer

A Readiness probe is the correct choice because it determines whether a Pod is ready to serve traffic. In this scenario, the web server takes 30 seconds to initialize, so a Readiness probe (e.g., an HTTP GET on the application's health endpoint) will prevent the Service (and thus the load balancer) from sending requests until the probe succeeds, ensuring zero traffic is routed to an uninitialized Pod.

Exam trap

The trap here is that candidates confuse Startup probes with Readiness probes, thinking a Startup probe alone will gate traffic, but only the Readiness probe controls whether the Service routes traffic to the Pod.

How to eliminate wrong answers

Option B is wrong because a Resource limit (CPU/memory) controls resource usage and scheduling, not traffic routing; it does not prevent the load balancer from sending traffic to an unready Pod. Option C is wrong because a Startup probe checks if the application has started successfully and is used for slow-starting containers, but it does not control traffic routing from the load balancer; once the Startup probe succeeds, the Liveness and Readiness probes take over, and the Readiness probe is the one that gates traffic. Option D is wrong because a Liveness probe restarts the container if it fails, but it does not prevent traffic from being sent to an unready Pod; a Pod can be alive but not ready, and the Liveness probe would not stop traffic.

265
MCQmedium

You need to run a batch job that processes 10 items in parallel across 10 Pods, but the job should be considered complete only when all 10 Pods have succeeded. Which Job configuration is correct?

A.spec: completions: 10; parallelism: 1
B.spec: completions: 1; parallelism: 10
C.spec: completions: 10; parallelism: 10
D.spec: completions: 10; parallelism: 0
AnswerC

This is the correct specification because completions 10 and parallelism 10 work together to meet the requirement: the Job controller launches up to 10 Pods concurrently (parallelism), and the Job is considered successful only after 10 distinct Pods complete successfully (completions). Each Pod can handle one of the 10 items, all run in parallel, and the Job waits until every one has finished. The combination precisely matches the stated batch workload.

Why this answer

Setting `completions: 10` and `parallelism: 10` tells Kubernetes to run 10 Pods concurrently (parallelism) and consider the Job successful only after all 10 Pods have completed without error (completions). This matches the requirement of processing 10 items in parallel with a completion condition of all Pods succeeding.

Exam trap

The trap here is confusing `completions` (total successes required) with `parallelism` (concurrent Pods), leading candidates to pick Option B, which runs 10 Pods in parallel but only waits for one to succeed, missing the requirement that all 10 must succeed.

How to eliminate wrong answers

Option A is wrong because `completions: 10; parallelism: 1` runs Pods sequentially (one at a time), not in parallel, so items are processed one after another, not concurrently. Option B is wrong because `completions: 1; parallelism: 10` runs 10 Pods in parallel but the Job is considered complete after only one Pod succeeds, ignoring the other 9 items. Option D is wrong because `parallelism: 0` is invalid; Kubernetes requires parallelism to be a positive integer (or unset, defaulting to 1), and setting it to 0 would cause the Job to never start any Pods.

266
MCQmedium

You have a Deployment 'app' with the following strategy configuration: 'type: RollingUpdate', 'rollingUpdate: {maxSurge: 0, maxUnavailable: 1}'. You update the container image. What is the behavior during the update?

A.A new pod is created first, then the oldest pod is terminated.
B.Two old pods are terminated at a time, while new pods are created.
C.One old pod is terminated, then a new pod is created, repeating until all pods are updated.
D.All old pods are terminated simultaneously, then new pods are created.
AnswerC

With maxSurge=0, the desired replica count cannot be exceeded, and with maxUnavailable=1, at most one pod may be down during the update. This configuration forces a strictly sequential pattern: the controller first terminates an old pod, which counts as one unavailable pod, then creates a new pod to restore the replica count to the desired number. It then repeats this cycle for each remaining old replica, so one old pod is terminated, a new pod is created, and this continues until all pods are rolled over. This approach maintains availability without any temporary scaling up.

Why this answer

With `maxSurge: 0` and `maxUnavailable: 1`, the RollingUpdate strategy ensures that during the update, no extra pods beyond the desired replica count are created (surge is zero), and at most one pod can be unavailable at any time. The Deployment controller first terminates an old pod (making one unavailable), then creates a new pod to replace it, repeating this process until all pods are updated. This guarantees a controlled, sequential rollout with minimal disruption.

Exam trap

The trap is that candidates often confuse the Kubernetes rolling update parameters: `maxSurge: 0` means no extra pods can be created above the desired count, and `maxUnavailable: 1` means at most one pod can be unavailable at a time. This results in a sequential termination-then-creation process, not parallel or batch updates.

How to eliminate wrong answers

Option A is wrong because it describes a behavior where a new pod is created before terminating an old one, which would require `maxSurge: 1` or higher; with `maxSurge: 0`, no new pod can be created until an old pod is terminated. Option B is wrong because terminating two old pods at a time would violate `maxUnavailable: 1`, which limits the number of unavailable pods to one during the update. Option D is wrong because terminating all old pods simultaneously would make all pods unavailable at once, far exceeding the `maxUnavailable: 1` limit and causing a full service disruption.

267
MCQmedium

A developer wants to create a Job that runs exactly 3 pods in parallel. Which field should be set in the Job spec?

A.spec.ttlSecondsAfterFinished: 3
B.spec.backoffLimit: 3
C.spec.parallelism: 3
D.spec.completions: 3
AnswerC

Setting spec.parallelism: 3 tells the Job controller to run up to three Pods concurrently, meaning the Job will schedule three Pods at the same time rather than a single Pod. This field directly controls the degree of parallelism; for a fixed-completion Job, the controller keeps parallelism Pods active until the desired completions count is reached. To achieve exactly three Pods running in parallel, parallelism is the correct knob to use.

Why this answer

`spec.parallelism` in a Kubernetes Job spec defines the desired number of Pods that should run concurrently. Setting `spec.parallelism: 3` tells the Job controller to run exactly 3 Pods in parallel, meeting the requirement of running 3 pods simultaneously.

Exam trap

The trap here is confusing `spec.parallelism` with `spec.completions` — candidates often think completions controls concurrency, but it actually defines the total number of successful completions needed, not how many run at once.

How to eliminate wrong answers

Option A is wrong because `spec.ttlSecondsAfterFinished` controls how long a completed Job is retained before automatic cleanup, not the number of parallel pods. Option B is wrong because `spec.backoffLimit` sets the number of retries for a failed Pod before marking the Job as failed, not parallelism. Option D is wrong because `spec.completions` defines the total number of successful Pod completions required for the Job to be considered complete, not the number of pods running in parallel.

268
Multi-Selectmedium

Which TWO are correct about LimitRange?

Select 2 answers
A.LimitRange can set default resource requests for containers that don't specify them
B.LimitRange can be applied only to pods in the default namespace
C.LimitRange is a cluster-scoped resource
D.LimitRange can enforce quotas on total resource usage across all pods
E.LimitRange can set maximum resource limits for containers
AnswersA, E

LimitRange's spec.default section defines default resource requests and limits for containers that do not explicitly declare them. When a pod is created in a namespace with a LimitRange, any container lacking a request or limit for a resource specified in default is automatically assigned that value. This defaulting mechanism applies at admission time, so it does not retroactively modify existing pods, and it works alongside the min/max constraints to keep pods within acceptable boundaries.

Why this answer

A LimitRange can define default resource requests and limits for containers in a namespace. When a container is created without specifying resource requests or limits, the LimitRange admission controller automatically applies the default values defined in the LimitRange object. This ensures that containers have baseline resource guarantees even if the pod spec omits them.

Exam trap

The trap here is confusing LimitRange (per-container constraints and defaults) with ResourceQuota (aggregate namespace limits), leading candidates to incorrectly select option D.

269
Multi-Selecthard

A production pod named 'api-pod' runs a single container whose liveness probe has begun failing after a configuration change, causing repeated restarts. An engineer must determine whether the failures are caused by the probe configuration itself or by the application inside the container. Which TWO actions best provide that evidence? (Choose two.)

Select 2 answers
A.Run kubectl get pod api-pod -o yaml and confirm the container's imagePullPolicy is set to Always.
B.Run kubectl rollout restart deployment api-pod to force a fresh container image pull and clear the restart counter.
C.Run kubectl describe pod api-pod and inspect the Events section for Liveness probe failed messages with the probe's reported error and port.
D.Run kubectl top pod api-pod to compare CPU and memory consumption against the container's declared limits.
E.Run kubectl exec into the container and query the probe endpoint locally to see whether the application answers correctly from inside the pod network namespace.
AnswersC, E

Probe failures are surfaced as events on the pod, and the message includes the probe type, the failure detail, and the endpoint being tested. That directly shows whether the kubelet is dialing the wrong port or path, or whether the application is returning a failing status, which is exactly the distinction the engineer needs before changing anything.

Why this answer

Separating a bad probe definition from a broken application requires evidence from two directions. Pod events show what the kubelet observed when the probe ran, including the failing endpoint and error text, which exposes misconfigured ports, paths, or thresholds. Testing the same endpoint from inside the container shows whether the application actually responds, which rules the application in or out.

Together they localize the fault; resource metrics, image pull policy, and a forced restart do not.

Exam trap

The trap here is treating a restart of the workload as a diagnostic step, when it destroys the events and container state that reveal why the probe failed.

270
MCQeasy

You want to deny all incoming traffic to a set of pods except from pods with label 'role: frontend'. Which NetworkPolicy spec should you use?

A.spec: podSelector: matchLabels: app: myapp ingress: - from: - namespaceSelector: matchLabels: role: frontend
B.spec: podSelector: matchLabels: app: myapp egress: - to: - podSelector: matchLabels: role: frontend
C.spec: podSelector: {} ingress: - from: - podSelector: matchLabels: role: frontend
D.spec: podSelector: matchLabels: app: myapp ingress: - from: - podSelector: matchLabels: role: frontend
AnswerD

This is the correct NetworkPolicy because `spec.podSelector` matches only the protected pods labeled `app=myapp`, and the single `ingress` rule uses a `from` clause with a `podSelector` that matches source pods labeled `role=frontend`. By defining only this rule and no default `ingress` rules, the policy defaults to denying all other incoming traffic to those pods while explicitly permitting traffic from the intended frontend pods. The use of `podSelector` for both the target and the source ensures precise, pod-level control over allowed ingress.

Why this answer

It selects pods with label 'app: myapp' and defines an ingress rule that only allows traffic from pods with label 'role: frontend'. By default, NetworkPolicy denies all traffic not explicitly allowed, so this configuration ensures only frontend pods can reach the selected pods.

Exam trap

The trap here is confusing podSelector with namespaceSelector, or using an empty podSelector that applies the policy to all pods instead of a specific set, leading to unintended broad access or denial.

How to eliminate wrong answers

Option A is wrong because it uses a namespaceSelector with matchLabels, which selects namespaces (not pods) with the label 'role: frontend', allowing traffic from any pod in those namespaces rather than only pods with the label 'role: frontend'. Option B is wrong because it defines an egress rule (outgoing traffic) instead of an ingress rule (incoming traffic), and the question asks to deny incoming traffic. Option C is wrong because it uses an empty podSelector ({}) which selects all pods in the namespace, not just the intended set of pods, and the ingress rule allows traffic from pods with 'role: frontend' to all pods, which is too broad.

271
MCQhard

You have a Job that should retry up to 3 times if it fails, and should be considered failed after 4 failures total (including retries). Which YAML fields should you set?

A.spec.activeDeadlineSeconds: 4
B.spec.backoffLimit: 4
C.spec.restartPolicy: OnFailure and spec.backoffLimit: 3
D.spec.backoffLimit: 3
AnswerD

spec.backoffLimit: 3 is the correct field because it directly defines how many times the Job controller will re-create a pod after it fails. The initial pod run counts as the first attempt, and each subsequent re-creation is a retry, so with backoffLimit set to 3, there are exactly 3 retries and a total of 4 attempts. This precisely matches the requirement and is the standard approach for controlling retry attempts in a Kubernetes Job.

Why this answer

The `spec.backoffLimit` field in a Kubernetes Job defines the number of retries before considering the Job as failed. Setting it to 3 means the Job will retry up to 3 times after the initial failure, resulting in a total of 4 failures (1 initial + 3 retries), which matches the requirement.

Exam trap

The trap here is that candidates often confuse `spec.backoffLimit` with the total number of allowed failures. In Kubernetes Jobs, `spec.backoffLimit` sets the number of retries after an initial failure, so to allow 4 total failures (initial + up to 3 retries), the value must be 3, not 4.

How to eliminate wrong answers

Option A is wrong because `spec.activeDeadlineSeconds` sets a hard time limit for the Job's execution, not a retry count; it would terminate the Job after 4 seconds regardless of retries. Option B is wrong because setting `spec.backoffLimit: 4` would allow 4 retries, leading to a total of 5 failures (1 initial + 4 retries), exceeding the required 4 failures. Option C is wrong because `spec.restartPolicy: OnFailure` is not a valid field for a Job (Jobs use `spec.template.spec.restartPolicy` and only support `Never` or `OnFailure`), and even if corrected, `spec.backoffLimit: 3` alone is sufficient without needing to set `restartPolicy` explicitly.

272
Multi-Selecteasy

Which TWO of the following are valid uses of Kubernetes Annotations? (Select two.)

Select 2 answers
A.Defining the name of a Kubernetes resource.
B.Identifying which pods a Service should route traffic to.
C.Configuring ingress controllers with specific settings like rewrite rules.
D.Storing non-identifying metadata such as build information or release notes.
E.Enabling service discovery between microservices.
AnswersC, D

Configuring ingress controllers with specific settings like rewrite rules is a valid use of annotations because ingress controllers (e.g., NGINX, Traefik) are designed to read controller-specific annotations attached to the Ingress resource to customize routing behavior. For example, `nginx.ingress.kubernetes.io/rewrite-target` instructs the NGINX controller to rewrite request paths before proxying them to backend services. These annotations act as declarative configuration that the controller consumes, while the core Ingress spec remains portable across different controllers.

Why this answer

Kubernetes annotations are key-value pairs used to attach arbitrary non-identifying metadata to objects, and Ingress controllers commonly use specific annotations (e.g., nginx.ingress.kubernetes.io/rewrite-target) to configure behavior like URL rewriting. This allows operators to customize controller functionality without altering the core resource definition.

Exam trap

The trap here is confusing annotations with labels: candidates often think annotations can be used for selection or routing (like Services or Deployments), but labels are the only mechanism for identification and grouping in Kubernetes.

273
MCQhard

A Job has the following spec: apiVersion: batch/v1 kind: Job metadata: name: pi spec: template: spec: containers: - name: pi image: perl command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] restartPolicy: Never backoffLimit: 4 If the pod fails, how many times will Kubernetes retry the job before considering it failed?

A.4
B.1
C.0
D.5
AnswerA

In a Kubernetes Job, backoffLimit defines the number of retries before the Job is considered failed. The backoffLimit field is set to 4, meaning the controller can retry the Pod up to 4 times after a failure. After those 4 retries are exhausted, the Job transitions to the Failed condition. Thus, the correct number of retries is exactly 4.

Why this answer

The `backoffLimit` field in a Job spec specifies the number of retries before the Job is considered failed. In this YAML, `backoffLimit: 4` means Kubernetes will retry the Job up to 4 times after the initial failure, for a total of 5 attempts (1 initial + 4 retries). The question asks 'how many times will Kubernetes retry the job before considering it failed?', which directly corresponds to the `backoffLimit` value of 4.

Exam trap

The trap here is that candidates often confuse the `backoffLimit` value with the total number of attempts (including the initial one), leading them to pick 5 instead of 4, but the question specifically asks for the number of retries, not total attempts.

How to eliminate wrong answers

Option B is wrong because it suggests only 1 retry, but the `backoffLimit` is explicitly set to 4, not 1. Option C is wrong because it suggests 0 retries, which would only be the case if `backoffLimit` were set to 0 or omitted (default is 6), but here it is 4. Option D is wrong because it suggests 5 retries, which is a common misinterpretation: the total number of attempts (initial + retries) is 5, but the number of retries is 4, as defined by `backoffLimit`.

274
MCQmedium

You want to run a command inside a running container to check environment variables. Which command should you use?

A.kubectl logs pod-name
B.kubectl exec pod-name -- env
C.kubectl describe pod pod-name
D.kubectl exec -it pod-name -- /bin/bash
AnswerB

kubectl exec pod-name -- env executes the env binary as a separate process inside the container's namespaces, printing all environment variables visible to that process. The -- delimiter tells kubectl that everything after it is a command to run inside the container, not a flag for kubectl itself. This non-interactive, single-command invocation is exactly suited for checking environment variables.

Why this answer

`kubectl exec pod-name -- env` runs the `env` command inside the specified container, which prints all environment variables set in the container's runtime environment. This is the most direct and efficient way to inspect environment variables without entering an interactive shell.

Exam trap

The trap here is that candidates may choose Option D thinking they need an interactive shell to run `env`, but the question asks for the command to check environment variables directly, and `kubectl exec pod-name -- env` is the precise, non-interactive approach that works even in containers without a shell.

How to eliminate wrong answers

Option A is wrong because `kubectl logs pod-name` retrieves the container's stdout/stderr logs, not environment variables. Option C is wrong because `kubectl describe pod pod-name` shows the pod's specification and status, including environment variables defined in the pod spec, but it does not show runtime environment variables injected by the container runtime (e.g., from secrets, configmaps, or the platform). Option D is wrong because `kubectl exec -it pod-name -- /bin/bash` opens an interactive shell inside the container, which can then be used to run `env`, but it is not the direct command to check environment variables; it requires an extra step and assumes the container has a shell like bash.

275
MCQmedium

A NetworkPolicy allows egress traffic to pods with label 'db: mysql' in the same namespace. Which egress rule is correct?

A.egress: - to: - podSelector: matchLabels: db: mysql
B.egress: - to: - namespaceSelector: matchLabels: db: mysql
C.egress: - from: - podSelector: matchLabels: db: mysql
D.egress: - to: - ipBlock: cidr: 10.0.0.0/8
AnswerA

This is correct because the egress rule uses the 'to' field, which is the required selector for defining destination traffic, and the podSelector with matchLabels 'db: mysql' limits allowed destinations only to pods carrying that label. The spec is otherwise valid because it requires no namespaceSelector, meaning it selects pods in the same namespace as the NetworkPolicy, which is the expected scope for this scenario. The policy permits egress only to those labeled pods while implicitly denying all other destinations.

Why this answer

A NetworkPolicy egress rule uses the `to` field to specify destination pods, and a `podSelector` within the same namespace selects pods with the label `db: mysql`. This allows outbound traffic from any pod in the namespace to pods matching that label, which directly satisfies the requirement.

Exam trap

The trap here is that candidates often confuse the `from` field (used for ingress) with the `to` field (used for egress), or mistakenly use a `namespaceSelector` when a `podSelector` is required to target pods by label within the same namespace.

How to eliminate wrong answers

Option B is wrong because it uses a `namespaceSelector` instead of a `podSelector`, which would select all pods in namespaces with the label `db: mysql`, not pods with that label in the same namespace. Option C is wrong because it uses the `from` field, which is only valid in ingress rules, not egress; egress rules require the `to` field to specify destinations. Option D is wrong because it uses an `ipBlock` to allow traffic to a CIDR range, which does not select pods by label and would allow traffic to any IP in that range, not just pods with the label `db: mysql`.

276
MCQeasy

Which of the following commands creates a deployment named 'webapp' that runs the image 'nginx:1.25' with 3 replicas?

A.kubectl create deployment webapp --image=nginx:1.25 --replicas=3
B.kubectl run webapp --image=nginx:1.25 --replicas=3
C.kubectl create deployment webapp --image=nginx:1.25
D.kubectl expose deployment webapp --port=80
AnswerA

kubectl create deployment webapp --image=nginx:1.25 --replicas=3 is the canonical imperative command that generates a Deployment named 'webapp' with the specified container image and desired replica count. The --replicas flag is explicitly supported by kubectl create deployment, and the resulting Deployment object will manage three Pod replicas using the nginx:1.25 image. This fully satisfies the requirement to create a Deployment with those parameters.

Why this answer

The correct command to create a Deployment named 'webapp' with the nginx:1.25 image and 3 replicas is 'kubectl create deployment webapp --image=nginx:1.25 --replicas=3'. Option B uses 'kubectl run', which creates a Pod, not a Deployment, and does not support the --replicas flag in modern Kubernetes. Option C is missing the --replicas flag, so it creates a Deployment with only the default of 1 replica.

Option D uses 'kubectl expose', which creates a Service, not a Deployment.

Exam trap

The temptation is to choose an option that looks similar to the correct one, but pay close attention to the missing flags and the command verb.

How to eliminate wrong answers

Option A is wrong because `kubectl create deployment` does not support a `--replicas` flag; the correct flag is `--replicas` (note the spelling difference), and even with the correct flag, the command syntax is identical to D but the option is listed as incorrect due to the trap. Option B is wrong because `kubectl run` creates a Pod, not a Deployment; it does not support `--replicas` or `--port` flags in the same way, and using those flags would either be ignored or cause an error. Option C is wrong because it is a duplicate of the correct command but is marked as incorrect in the question's answer options; the question explicitly labels D as correct, so C is considered a distractor.

277
MCQhard

A CronJob is configured with concurrencyPolicy: Replace and a job execution takes 10 minutes. The schedule is */5 * * * *. Which statement is true about job executions?

A.Jobs will never overlap because the schedule is too frequent
B.Every 5 minutes, a new job is created, and if the previous job is still running, it is killed
C.The job will be skipped if the previous one hasn't finished
D.Jobs will overlap, with up to two jobs running concurrently
AnswerB

This is exactly what concurrencyPolicy: Replace does. When the CronJob controller fires a new schedule, it checks whether the Job from the previous invocation is still active; if so, it deletes that existing Job (terminating its Pods) and creates a fresh Job for the current run. This ensures the schedule is always honored and only one Job's worth of work executes at a time.

Why this answer

With `concurrencyPolicy: Replace`, if a new job is triggered by the schedule (every 5 minutes) while the previous job is still running (it takes 10 minutes), the running job is terminated and replaced by the new one. This ensures only one job runs at a time, and the new job starts immediately, even if the previous one hasn't finished.

Exam trap

The trap here is that candidates confuse 'Replace' with 'Forbid' or 'Allow', and mistakenly think the job is skipped or that overlap is allowed, when in fact 'Replace' actively terminates the running job to start a new one.

How to eliminate wrong answers

Option A is wrong because the schedule is every 5 minutes, but the job takes 10 minutes, so jobs would overlap if not for the concurrency policy; the statement 'too frequent' is irrelevant as the policy explicitly handles overlap. Option C is wrong because 'Replace' does not skip jobs; it kills the running job and starts the new one, unlike 'Forbid' which would skip. Option D is wrong because 'Replace' prevents overlapping by terminating the existing job, so up to two jobs never run concurrently.

278
MCQeasy

Which command lists all Helm releases in the current namespace?

A.helm list
B.helm get all
C.helm status
D.helm show
AnswerA

helm list is the correct command because it queries the Helm storage backend in the current Kubernetes namespace and returns all installed releases with their name, status, revision, update time, and chart version. You can filter with flags like --namespace and --all-namespaces, and by default it excludes uninstalled releases.

Why this answer

The `helm list` command is the correct way to list all Helm releases in the current namespace. It queries the Helm release storage (typically Secrets in the cluster) and returns the release names, status, chart versions, and other metadata for the namespace set in the current kubeconfig context.

Exam trap

The trap here is that candidates confuse `helm list` with `helm get all` or `helm status`, mistakenly thinking those commands can list multiple releases, when in fact they operate on a single release name.

How to eliminate wrong answers

Option B is wrong because `helm get all` is not a valid Helm command; the correct command to retrieve all information about a specific release is `helm get all <release-name>`, which fetches manifests, values, and notes for a single release, not a list. Option C is wrong because `helm status <release-name>` shows the status of a single named release (e.g., deployed, failed), not a list of all releases. Option D is wrong because `helm show` is used to display information about a chart (e.g., `helm show chart`, `helm show values`) from a repository or local path, not to list releases.

279
MCQhard

You want to perform a rolling update of a Deployment. The Deployment has a maxSurge=1 and maxUnavailable=0. How many extra pods can be created above the desired count during the update?

A.Unlimited
B.0
C.1
D.Desired replicas
AnswerC

A `maxSurge` value of 1 correctly indicates that exactly one pod may be created above the desired replica count during a rolling update. This allows the Deployment controller to bring up a new pod before terminating an old one, reducing downtime while keeping the surge limited to a single extra pod. Kubernetes interprets this as an absolute number, so the controller ensures the total pod count never exceeds `replicas + 1` during the update.

Why this answer

In a rolling update with `maxSurge=1` and `maxUnavailable=0`, Kubernetes ensures that at most one extra pod can be created above the desired replica count during the update. This is controlled by the `maxSurge` field, which defines the maximum number of pods that can be created over the desired number, and here it is set to 1 (either an absolute number or a percentage, defaulting to 25%). Since `maxUnavailable=0`, no pods can be taken down before new ones are ready, so the surge allows exactly one additional pod to be created temporarily.

Exam trap

The trap here is that candidates often confuse `maxSurge` with `maxUnavailable` or assume that `maxSurge` allows unlimited pods, when in fact it is a strict integer or percentage cap that limits the number of extra pods created above the desired count.

How to eliminate wrong answers

Option A is wrong because 'Unlimited' is never allowed; Kubernetes enforces a hard limit via the `maxSurge` field, which caps the number of extra pods. Option B is wrong because 0 would mean no extra pods can be created, which would prevent any new pods from being rolled out if `maxUnavailable=0` (since you cannot delete old pods), effectively blocking the update. Option D is wrong because 'Desired replicas' would allow doubling the replica count, which is not the behavior of `maxSurge`; `maxSurge` is a separate limit (default 25% or 1) and does not equal the desired replica count.

280
MCQhard

You want to configure a pod so that it receives a SIGTERM signal and has 60 seconds to shut down gracefully before being forcefully killed. Which field should you set?

A.terminationGracePeriodSeconds: 60
B.lifecycle.preStop.exec.command with sleep 60
C.livenessProbe.initialDelaySeconds: 60
D.resources.limits.cpu
AnswerA

This field is the authoritative control for how long the kubelet will wait between sending SIGTERM and SIGKILL to a container during pod termination. Setting it to 60 explicitly grants the main process a 60-second window to handle the signal and shut down gracefully, whereas without it the default is only 30 seconds. This is the only direct mechanism for ensuring the pod receives SIGTERM and has time to react.

Why this answer

The `terminationGracePeriodSeconds` field in the Pod spec defines the duration (in seconds) that Kubernetes waits after sending a SIGTERM to the primary container process before sending a SIGKILL. Setting it to 60 gives the pod 60 seconds to shut down gracefully, which is exactly what the question requires.

Exam trap

The trap here is that candidates often confuse `lifecycle.preStop` with the grace period itself, thinking a `sleep` command in the preStop hook will extend the shutdown time, when in reality it only delays the SIGTERM and the total time before SIGKILL is still governed by `terminationGracePeriodSeconds`.

How to eliminate wrong answers

Option B is wrong because `lifecycle.preStop.exec.command` with `sleep 60` only adds a 60-second delay before the SIGTERM is sent, but does not extend the total grace period; if the grace period is shorter, the pod will still be killed after that shorter time. Option C is wrong because `livenessProbe.initialDelaySeconds: 60` controls how long to wait before starting the liveness probe, not the shutdown grace period. Option D is wrong because `resources.limits.cpu` sets a CPU resource limit for the container and has no effect on termination behavior.

281
Multi-Selecteasy

A developer wants to restrict a Pod's resource usage. Which two API resources can be used to enforce limits at the namespace level? (Choose two.)

Select 2 answers
A.PodSecurityPolicy
B.HorizontalPodAutoscaler
C.LimitRange
D.ResourceQuota
E.NetworkPolicy
AnswersC, D

A LimitRange is a namespaced Kubernetes object that sets minimum, maximum, and default values for CPU and memory requests and limits for individual containers or pods. When a container is created without explicit resources, the LimitRange admission plugin automatically injects defaults, and if the container's declared limits fall outside the configured range, the pod is rejected. This gives operators precise, per-pod control over how many resources each workload can consume.

Why this answer

LimitRange (C) is correct because it allows administrators to set default resource requests and limits, as well as minimum and maximum constraints, for Pods and containers within a namespace. This enforces resource boundaries at the namespace level, ensuring that individual Pods cannot exceed defined limits.

Exam trap

CNCF often tests the distinction between namespace-level resource enforcement (LimitRange and ResourceQuota) and cluster-level or scaling mechanisms, leading candidates to confuse HorizontalPodAutoscaler (which scales Pods) with resource limits.

282
MCQmedium

You have a multi-container pod with a main container and a sidecar container that collects logs. The sidecar container should start before the main container and must complete initialization tasks before the main container starts. Which type of container should you use for this purpose?

A.Ephemeral container
B.Init container
C.Job
D.Regular sidecar container
AnswerB

Init containers are special containers that run to completion sequentially before any regular containers in the pod start. Each init container must finish successfully before the next one begins, and the main container is only started after all init containers have succeeded. This makes them the correct choice for initialization tasks such as setting up volumes, waiting for dependencies, or performing migrations. If an init container fails, it is retried according to the pod's restartPolicy, ensuring the main container never starts prematurely.

Why this answer

Init containers run to completion before any regular containers in the pod start, making them ideal for prerequisites like initialization tasks or log setup. In this scenario, the sidecar must complete its initialization before the main container begins, which is exactly the behavior of an init container. Regular sidecar containers run concurrently with the main container, not before it.

Exam trap

Init containers are a key concept in CKAD. Candidates often mistakenly think a regular sidecar container can be configured to start before the main container, but Kubernetes does not support ordering among regular containers in a pod. Only init containers guarantee completion before other containers start.

How to eliminate wrong answers

Option A is wrong because ephemeral containers are temporary containers injected into a running pod for debugging purposes, not for initialization tasks. Option C is wrong because a Job is a standalone Kubernetes resource that runs a task to completion, not a container type within a pod, and cannot enforce ordering relative to other containers in the same pod. Option D is wrong because a regular sidecar container runs concurrently with the main container and does not guarantee completion before the main container starts.

283
MCQeasy

Which of the following is a valid way to expose a Secret as an environment variable in a Pod?

A.env: - name: DB_PASSWORD valueFrom: configMapKeyRef: ...
B.env: - name: DB_PASSWORD value: $(DB_PASSWORD_SECRET)
C.env: - name: DB_PASSWORD valueFrom: fieldRef: ...
D.env: - name: DB_PASSWORD valueFrom: secretKeyRef: ...
AnswerD

The `secretKeyRef` field is the correct and standard mechanism for referencing a key from a Kubernetes Secret object and injecting its value as an environment variable. It requires the Secret to exist in the same namespace and the referenced key to be present; otherwise, the container creation fails. This approach keeps sensitive data out of the Pod manifest and centralizes it in the Secret API, which is the intended and secure pattern.

Why this answer

`secretKeyRef` is the Kubernetes API field used to reference a specific key from a Secret object and expose its value as an environment variable in a Pod. This is defined in the Pod spec under `env[].valueFrom.secretKeyRef`, which requires the `name` of the Secret and the `key` within that Secret.

Exam trap

CNCF often tests the distinction between `configMapKeyRef`, `secretKeyRef`, and `fieldRef`, and the trap here is that candidates confuse `configMapKeyRef` (for non-sensitive data) with `secretKeyRef` (for sensitive data), or think that variable substitution like `$(VAR_NAME)` can directly pull from a Secret.

How to eliminate wrong answers

Option A is wrong because `configMapKeyRef` references a ConfigMap, not a Secret; ConfigMaps are for non-sensitive data, while Secrets are for sensitive data like passwords. Option B is wrong because `$(DB_PASSWORD_SECRET)` is a variable substitution syntax used for referencing other environment variables or container arguments, not for directly exposing a Secret's value. Option C is wrong because `fieldRef` is used to expose Pod metadata (e.g., `metadata.name`, `status.podIP`) via the downward API, not Secret data.

284
MCQeasy

Which of the following is NOT a valid restart policy for a Pod?

A.OnFailure
B.Always
C.Never
D.UnlessStopped
AnswerD

UnlessStopped is not a recognized value for the restartPolicy field in Kubernetes; the only valid values are Always, OnFailure, and Never. It might sound familiar from Docker's own restart policies, but Kubernetes deliberately does not implement it. Attempting to use UnlessStopped in a Pod manifest will cause the API server to reject the definition with an invalid value error.

Why this answer

Kubernetes supports exactly three restart policies for Pods: Always, OnFailure, and Never. 'UnlessStopped' is not a valid restart policy in the Kubernetes API; it is a fabricated option designed to test your knowledge of the allowed values for the `restartPolicy` field in a Pod spec.

Exam trap

The trap here is that candidates may confuse Kubernetes restart policies with Docker's restart policies (which include 'unless-stopped'), assuming they are identical, but Kubernetes only supports the three explicit policies defined in the PodSpec.

How to eliminate wrong answers

Option A is wrong because 'OnFailure' is a valid restart policy that restarts the container only when the container exits with a non-zero exit code. Option B is wrong because 'Always' is the default restart policy and is valid; it automatically restarts the container regardless of the exit code. Option C is wrong because 'Never' is a valid restart policy that never restarts the container after it exits.

285
MCQmedium

You want to add an annotation to a pod without modifying the pod template. Which approach should you use?

A.kubectl annotate deployment my-deployment key=value
B.kubectl label pod my-pod key=value
C.kubectl edit pod my-pod and add annotation manually
D.kubectl annotate pod my-pod key=value
AnswerD

This is the precise imperative command to add an annotation to a Pod object in the cluster. `kubectl annotate pod my-pod key=value` directly updates the `metadata.annotations` map of the specified Pod, and the change is immediately visible to the API server. This approach works for any Pod, but it is especially appropriate when the Pod is statically created or when you intentionally want to modify only the live object. For controller-managed Pods, remember that this change is ephemeral — if the Pod is recreated by its Deployment or ReplicaSet, the annotation will be lost unless the Pod template is also updated.

Why this answer

'kubectl annotate pod my-pod key=value' adds an annotation directly to the existing pod without modifying the pod template. Option A uses 'kubectl annotate deployment', which adds an annotation to the Deployment object itself, not to the pod. Option B uses 'kubectl label', which adds labels, not annotations.

Option C uses 'kubectl edit', which is not a direct annotation command and may be less efficient.

286
MCQmedium

Your team manages a microservices application on a Kubernetes cluster. A critical service 'order-service' is deployed with 3 replicas. Lately, customers have reported occasional timeouts when placing orders. You suspect that the service is overloaded during peak hours. You have configured a HorizontalPodAutoscaler (HPA) based on CPU utilization, but the autoscaler does not appear to be scaling up quickly enough. Upon inspection, you notice that the HPA is configured with a target CPU utilization of 80%, and the current CPU usage of the pods is around 70%. However, the pods' memory usage is high and growing. The application is also logging slow database queries. Which action is most likely to improve the responsiveness of the service during peak load?

A.Modify the HPA to also scale based on memory utilization, setting a target average value for memory.
B.Reduce the number of replicas to 2 to force the HPA to react more aggressively.
C.Increase the CPU target utilization to 90% so the HPA triggers earlier.
D.Optimize the database queries to reduce response time.
AnswerA

Relying solely on CPU utilization can miss memory-bound workloads, where pods degrade due to memory pressure long before CPU approaches its target. Adding a memory metric to the HPA—using targetAverageValue or targetAverageUtilization—makes the autoscaler react to actual resource exhaustion. Since memory is a non-compressible resource, Kubernetes cannot throttle it as it does with CPU, so the only effective mitigation is to add replicas when average memory consumption exceeds the configured threshold.

Why this answer

The HPA is configured only for CPU, but the symptom (high memory usage, slow DB queries) indicates memory pressure is the bottleneck. Adding a memory-based metric to the HPA allows it to scale when memory exceeds the target, addressing the root cause of overload during peak hours. The current CPU at 70% is below the 80% threshold, so the HPA won't trigger on CPU alone, but memory scaling can react to the actual resource constraint.

Exam trap

The trap here is that candidates often assume CPU is the only metric for HPA scaling, but the CKAD exam tests the ability to identify when other metrics (like memory) are more relevant based on application behavior and symptoms.

How to eliminate wrong answers

Option B is wrong because reducing replicas to 2 would decrease capacity, worsening the overload and timeouts, not improving responsiveness. Option C is wrong because increasing the CPU target to 90% would make the HPA trigger later (at higher CPU), not earlier, and CPU is already below 80%, so this change would not help. Option D is wrong because while optimizing database queries is a valid long-term fix, it does not address the immediate scaling issue; the HPA should be configured to scale based on the actual bottleneck (memory) to handle peak load now.

287
MCQmedium

You have a Service named 'web-svc' of type ClusterIP. You want to test connectivity to it from a temporary pod. Which command would you use to launch a temporary interactive pod with the image 'busybox' and then run 'wget' against the Service?

A.kubectl run tmp --image=busybox --restart=Always --rm -it -- wget -qO- http://web-svc
B.kubectl exec -it tmp --image=busybox -- wget -qO- http://web-svc
C.kubectl run tmp --image=busybox --restart=Never --rm -it -- wget -qO- http://web-svc
D.kubectl create pod tmp --image=busybox --rm -it -- wget -qO- http://web-svc
AnswerC

This command creates a temporary pod named 'tmp' using the busybox image, sets restart policy to Never, attaches interactively, and removes the pod after exit. The '--' separates the kubectl arguments from the command to run in the container, which is 'wget -qO- http://web-svc'. This is the correct way to launch an interactive pod and execute a command.

Why this answer

The correct command uses 'kubectl run' with '--restart=Never' to create a standalone pod, '--rm' to delete it after exit, and '-it' for interactive terminal. The '--' separates kubectl flags from the command to run in the container. Other options misuse 'kubectl exec', use an invalid restart policy, or use a non-existent 'kubectl create pod' command.

Exam trap

The trap here is confusing 'kubectl run' with 'kubectl exec'; only 'run' creates a new pod, while 'exec' requires an existing pod.

288
Multi-Selecthard

Which three security contexts can be set at the pod level (as opposed to container level)? (Select THREE.)

Select 3 answers
A.readOnlyRootFilesystem
B.fsGroup
C.runAsGroup
D.capabilities
E.runAsUser
AnswersB, C, E

fsGroup is a pod-level securityContext field that specifies the group ID for volume ownership. When set, Kubernetes changes the group ownership of volumes mounted into the pod (except Secrets and ConfigMaps) to that GID, and files created in those volumes will also inherit this group. This ensures containers have consistent group-based access to shared volumes, even when runAsGroup differs, because fsGroup applies at the mount layer.

Why this answer

B is correct because `fsGroup` is a Pod-level security context field that applies a supplemental group ID to all containers in the Pod, ensuring that volumes mounted with that group ownership are accessible. It is set under `spec.securityContext.fsGroup`, not at the container level, making it a Pod-scoped setting.

Exam trap

The trap here is that candidates confuse Pod-level and container-level security contexts, often selecting `capabilities` or `readOnlyRootFilesystem` because they are commonly used, but they are only valid at the container level in the Kubernetes API.

289
Multi-Selecthard

Which THREE configurations are part of Pod Security Admission's 'restricted' profile? (Select THREE.)

Select 3 answers
A.runAsNonRoot: true
B.seccompProfile.type: RuntimeDefault
C.capabilities must drop ALL
D.allowPrivilegeEscalation: true
E.Privileged containers allowed
AnswersA, B, C

Setting `runAsNonRoot: true` forces the kubelet to refuse container startup if the image resolves to UID 0, satisfying the restricted profile's mandate that containers never run as root. This directly enforces the non-root user constraint, one of the three baseline hardening controls the restricted profile requires.

Why this answer

Option A (runAsNonRoot: true) is correct because the restricted profile requires containers to run as a non-root user, enforcing runAsNonRoot=true in the security context. Option B (seccompProfile.type: RuntimeDefault) is correct because restricted mandates a seccomp profile, and RuntimeDefault is the minimum accepted value. Option C (capabilities must drop ALL) is correct because restricted requires dropping all Linux capabilities, allowing only NET_BIND_SERVICE to be added back.

Option D is incorrect because allowPrivilegeEscalation must be false under restricted, not true. Option E is incorrect because privileged containers are explicitly disallowed by the restricted profile.

Exam trap

The trap here is that candidates often confuse the 'restricted' profile with the 'baseline' profile, mistakenly thinking that options like `allowPrivilegeEscalation: true` or privileged containers are acceptable, when in fact the restricted profile explicitly prohibits them.

290
MCQmedium

You have deployed an application using Helm. You want to see the history of revisions for the release 'frontend' in the 'web' namespace. Which command should you use?

A.helm status frontend --namespace web
B.helm list frontend --namespace web
C.helm get manifest frontend --namespace web
D.helm history frontend --namespace web
AnswerD

helm history frontend --namespace web is the correct command to display the full revision history for the release named 'frontend' in the 'web' namespace. It outputs a table with each revision number, the chart and app version used, the status (e.g., superseded, failed, deployed), a description of the action (install, upgrade, rollback, or test), and the timestamp of the operation. This provides an audit trail that lets you verify when changes occurred, investigate unexpected behavior, and choose a revision for potential rollback, making it the appropriate command for the question.

Why this answer

The command 'helm history frontend --namespace web' lists all revisions for the release 'frontend' in the 'web' namespace.

291
MCQhard

A Pod is configured with automountServiceAccountToken: false. The application inside the pod needs to access the Kubernetes API. What should be done?

A.Create a new Secret of type kubernetes.io/dockerconfigjson
B.Mount the service account token manually by adding a volume and volumeMount
C.The application cannot access the API; the setting is final
D.Add a ConfigMap with the token
AnswerB

Setting automountServiceAccountToken: false only disables the automatic mounting of the service account token; it does not prevent you from mounting it explicitly. You can add a projected volume in the Pod spec with the serviceAccountToken source, specifying the service account name, path, audience, and expiration seconds. Then add a volumeMount at an application-accessible path (e.g., /var/run/secrets/token) so the container reads the token from that file. This is the correct way to restore API access while keeping the automatic mount disabled.

Why this answer

Setting automountServiceAccountToken: false prevents automatic mounting of the service account token. To still access the Kubernetes API, you must manually mount the token by adding a volume of type projected (or secret) containing the service account token, and a corresponding volumeMount in the container. This allows the application to authenticate with the API server using the mounted token.

Exam trap

The trap here is that candidates assume automountServiceAccountToken: false permanently blocks API access, but the CKAD exam tests that you can override this by manually mounting the token, often using a projected volume or a secret reference.

How to eliminate wrong answers

Option A is wrong because a Secret of type kubernetes.io/dockerconfigjson is used for pulling images from private registries, not for API authentication. Option C is wrong because the application can still access the API if the token is manually mounted; the setting is not final. Option D is wrong because ConfigMaps store non-sensitive configuration data, not service account tokens, which are sensitive and must be stored in Secrets or projected volumes.

292
MCQmedium

You have a pod that is in a 'Pending' state. You run 'kubectl describe pod' and see the event: '0/3 nodes are available: 3 Insufficient cpu'. What is the most likely cause?

A.The pod's CPU request is larger than the available CPU on any node
B.The pod requires more memory than any node can provide
C.The pod's liveness probe is failing
D.All nodes are tainted and the pod does not tolerate the taints
AnswerA

When a pod's CPU request exceeds the total allocatable CPU capacity on every node in the cluster, the kube-scheduler cannot find a feasible node and leaves the pod in Pending state. The scheduler compares each node's allocatable CPU against the sum of requests for all pods, and a `FailedScheduling` event with `Insufficient cpu` is recorded. This is a scheduling failure, not a runtime failure, so the pod remains Pending until a node with enough free CPU becomes available.

Why this answer

The event '0/3 nodes are available: 3 Insufficient cpu' indicates that the Kubernetes scheduler attempted to place the pod on each of the three nodes but found that none had enough allocatable CPU capacity to satisfy the pod's CPU request. This means the sum of CPU requests across all pods on each node, plus the new pod's request, exceeds the node's CPU capacity. The pod remains in 'Pending' because the scheduler cannot find a suitable node until CPU resources are freed or the request is reduced.

Exam trap

CNCF often tests the distinction between resource requests (used for scheduling) and resource limits (used for throttling), and candidates mistakenly think 'Insufficient cpu' refers to limits or actual usage rather than the guaranteed request that the scheduler evaluates.

How to eliminate wrong answers

Option B is wrong because the event explicitly mentions 'Insufficient cpu', not memory; a memory shortage would produce 'Insufficient memory'. Option C is wrong because liveness probe failures occur after the pod is running (in 'Running' state), not while it is still 'Pending' and before scheduling. Option D is wrong because taints and tolerations produce events like '0/3 nodes are available: 3 node(s) had taint {key:value} that the pod didn't tolerate', not 'Insufficient cpu'.

293
Multi-Selectmedium

Which TWO commands can be used to view the logs of a pod that has crashed?

Select 2 answers
A.kubectl logs <pod> --tail=0 -f
B.kubectl logs <pod> -c <container>
C.kubectl logs <pod> --previous
D.kubectl logs <pod> -p
E.kubectl logs <pod>
AnswersC, D

The --previous flag explicitly instructs kubectl to retrieve the logs written by the most recent terminated container instance of the pod. When a container has crashed or restarted, this shows the complete stdout/stderr from the old instance, which is often the only source of diagnostic information about the failure. It is the straightforward, unambiguous long-form command for viewing previous container logs.

Why this answer

`kubectl logs <pod> --previous` retrieves logs from the previous instance of a container in a pod that has crashed and been restarted. This is essential for debugging crash loops, as the current container may have no logs or only post-crash output. The `--previous` flag accesses the terminated container's logs stored by the kubelet.

Exam trap

CNCF often tests the distinction between `--previous` (or `-p`) and `-c` flags, where candidates mistakenly think `-c` retrieves logs from a crashed container instead of specifying a container name in a multi-container pod.

294
Multi-Selectmedium

Which TWO statements about headless services are correct?

Select 2 answers
A.They require a selector to match pods
B.DNS returns the pod IPs directly
C.They are used for StatefulSets to provide stable network identities
D.They provide load balancing across pods
E.They have a ClusterIP assigned
AnswersB, C

In a headless service, the DNS A record query resolves directly to the IP addresses of all pods backing the service, rather than to a single ClusterIP virtual IP. Because clusterIP is set to None, no load-balanced IP exists, and the DNS server returns a set of A records, each corresponding to an individual pod endpoint, allowing clients to contact those pods directly.

Why this answer

Headless services are created by setting `clusterIP: None` in the service spec. When a DNS lookup is performed for a headless service, the DNS server returns the IP addresses of the matching pods directly, rather than a single virtual ClusterIP. This is because there is no ClusterIP to load-balance traffic, so DNS returns all pod IPs (A/AAAA records) for the service name, enabling direct pod-to-pod communication.

Exam trap

The trap here is that candidates often confuse headless services with regular ClusterIP services, assuming they still provide load balancing or have a virtual IP, when in fact headless services are designed for direct pod access and stable network identities, not traffic distribution.

295
MCQmedium

You are performing a blue-green deployment. You have two Deployments: 'app-blue' (current) and 'app-green' (new). Both have labels 'app: myapp' and 'version: blue' or 'version: green' respectively. The Service 'myapp-svc' selects pods with 'app: myapp, version: blue'. How do you switch traffic to the green deployment?

A.Add an additional label 'traffic: enabled' to the 'app-green' pods and update the Service to select 'traffic: enabled'
B.Update the Service selector to 'app: myapp; version: green'
C.Update the 'app-green' Deployment to have label 'version: blue'
D.Update the Service selector to 'app: myapp, version: green'
AnswerD

This is the textbook blue-green cutover. By changing the Service's selector to 'app: myapp, version: green', the Service will match only the pods belonging to the green Deployment, since those pods carry both labels. The blue pods remain running but are no longer selected, so all incoming traffic is instantly redirected to the green version. This is a declarative, reversible change that requires no pod restarts, making it the simplest and standard approach.

Why this answer

Updating the Service's selector to 'app: myapp, version: green' directs traffic to the green pods. Option B uses a semicolon instead of a comma, which is invalid syntax. Option A adds a label mismatch and does not change the Service selector.

Option C would change the green deployment's label to 'blue', causing both deployments to have the same version label, which is not a proper blue-green switch.

296
MCQmedium

You need to allow ingress traffic to pods in namespace 'api' only from pods in namespace 'frontend' that have label 'role: proxy'. Which NetworkPolicy ingress rule correctly implements this?

A.ingress: - from: - namespaceSelector: matchLabels: name: frontend
B.ingress: - from: - namespaceSelector: matchLabels: name: frontend podSelector: matchLabels: role: proxy
C.ingress: - from: - ipBlock: cidr: 0.0.0.0/0 - podSelector: matchLabels: role: proxy
D.ingress: - from: - podSelector: matchLabels: role: proxy
AnswerB

This rule correctly combines a namespaceSelector and a podSelector within the same ingress peer, and in NetworkPolicy semantics, these two selectors are ANDed when they appear together in a single peer. Thus, only pods that simultaneously satisfy both labels—role=proxy on the pod itself, and the pod's namespace having name=frontend—are allowed as sources. This exactly matches the stated requirement, ensuring no other pods from the frontend namespace, and no proxies from other namespaces, can connect.

Why this answer

It combines a namespaceSelector (to match the 'frontend' namespace) with a podSelector (to match pods with label 'role: proxy') in the same ingress rule. This ensures that only traffic from pods in the 'frontend' namespace that also have the label 'role: proxy' is allowed, fulfilling the requirement precisely.

Exam trap

The trap here is that candidates often forget that when namespaceSelector and podSelector are combined in the same 'from' block, they are ANDed, not ORed, leading them to pick options that are too broad (like A or D) or that mix unrelated rules (like C).

How to eliminate wrong answers

Option A is wrong because it only uses a namespaceSelector to match the 'frontend' namespace, allowing all pods in that namespace regardless of their labels, which is too permissive. Option C is wrong because it includes an ipBlock rule for 0.0.0.0/0 (all traffic) combined with a podSelector for 'role: proxy', which would allow traffic from any source IP (including outside the cluster) as long as the source pod has that label, violating the namespace restriction. Option D is wrong because it only uses a podSelector for 'role: proxy' without a namespaceSelector, which would allow traffic from any namespace (including the same namespace) as long as the source pod has that label, failing to restrict to the 'frontend' namespace.

297
MCQeasy

In a Deployment, what is the purpose of the 'maxUnavailable' field in the rolling update strategy?

A.The maximum number of pods that can be terminated at once.
B.The maximum number of pods that can be unavailable during the update.
C.The maximum time allowed for the rollout to complete.
D.The maximum number of pods that can be created above the desired replicas.
AnswerB

This is the exact definition. During a rolling update, the Deployment controller ensures that at most maxUnavailable pods (default 25% of desired replicas, rounded to an integer) are out of service at any moment. It gives you control over the trade-off between update speed and service availability, allowing you to keep most of your workload serving traffic while the rest are replaced. This setting is evaluated continuously, so even if one pod fails to become ready, the controller pauses further changes to maintain the unavailability limit.

Why this answer

In a Deployment's rolling update strategy, the 'maxUnavailable' field specifies the maximum number of Pods that can be unavailable during the update process. This ensures that the Deployment maintains a certain level of availability by controlling how many Pods can be taken down at any given time, relative to the desired replica count. It is defined as either an absolute number or a percentage of the desired Pods, and it works alongside 'maxSurge' to manage the update's pace and safety.

Exam trap

The trap here is that candidates often confuse 'maxUnavailable' with 'maxSurge', thinking it controls the number of Pods created above the desired count, when in fact 'maxUnavailable' governs the number of Pods that can be unavailable, while 'maxSurge' controls the number of extra Pods created above the desired replicas.

How to eliminate wrong answers

Option A is wrong because 'maxUnavailable' does not limit the number of Pods that can be terminated at once; that behavior is governed by the combination of 'maxUnavailable' and 'maxSurge', but 'maxUnavailable' specifically caps the number of Pods that can be in an unavailable state, not the termination rate. Option C is wrong because there is no 'maxUnavailable' field for rollout completion time; Kubernetes uses 'progressDeadlineSeconds' to set a timeout for the rollout to complete, not 'maxUnavailable'. Option D is wrong because the maximum number of Pods that can be created above the desired replicas is controlled by the 'maxSurge' field, not 'maxUnavailable'; 'maxUnavailable' deals with unavailability, not overshooting the replica count.

298
MCQhard

You need to debug a pod that has no running container because it crashed. The pod is in CrashLoopBackOff. Which command allows you to start a temporary container in the same pod for debugging?

A.kubectl debug <pod> -it --image=busybox
B.kubectl attach <pod>
C.kubectl run debug --image=busybox
D.kubectl exec -it <pod> -- /bin/bash
AnswerA

kubectl debug with an explicit image creates an ephemeral container that is injected directly into the existing Pod, even when its primary container is not running. This ephemeral container shares the Pod’s network, storage, and optionally its process namespace, letting you inspect crashed processes or mounted volumes from inside the Pod context. The interactive -it session gives you a shell without ever needing the original container to be alive, which is precisely why it succeeds where exec, attach, or a separate run would fail.

Why this answer

`kubectl debug` can create an ephemeral container in an existing pod for debugging purposes, even when the original container is in CrashLoopBackOff. The `-it` flag provides an interactive terminal, and `--image=busybox` supplies a lightweight debugging image. This allows you to inspect the pod's filesystem, network, or environment without restarting the failing container.

Exam trap

The trap here is that candidates assume `kubectl exec` can debug any pod, but it requires a running container, whereas `kubectl debug` is the correct tool for pods in CrashLoopBackOff.

How to eliminate wrong answers

Option B is wrong because `kubectl attach` connects to a running container's stdin/stdout/stderr; it cannot start a new container or debug a crashed pod. Option C is wrong because `kubectl run debug --image=busybox` creates a separate, standalone pod, not a temporary container inside the existing pod, so it cannot share the same network namespace or volumes. Option D is wrong because `kubectl exec` requires a running container to execute commands against; it fails when the container is in CrashLoopBackOff.

299
MCQeasy

Which Dockerfile instruction is used to specify the base image for a build?

A.COPY
B.RUN
C.FROM
D.CMD
AnswerC

FROM declares the base image that subsequent build stages start from, pulling it from a registry or referencing a prior build stage. It must be the first instruction in a stage, establishing the filesystem and environment on which RUN, COPY, and other instructions operate.

Why this answer

The FROM instruction initializes a new build stage and sets the base image for subsequent instructions. In Docker, every Dockerfile must start with a FROM (or ARG before FROM) to specify an existing image, such as `FROM ubuntu:22.04` or `FROM alpine:3.18`, from which the new image is built. Without FROM, the build has no foundation and will fail.

Exam trap

A common trap in the Dockerfile section of the CKAD exam is confusing build-time instructions (FROM, RUN, COPY) with runtime instructions (CMD, ENTRYPOINT). Candidates often select CMD (which sets the default command) instead of FROM, which is required to specify the base image.

How to eliminate wrong answers

Option A is wrong because COPY is used to copy files or directories from the build context into the container filesystem, not to specify the base image. Option B is wrong because RUN executes commands in a new layer on top of the current image during the build, such as installing packages, and does not define the base image. Option D is wrong because CMD provides default arguments for the container's entrypoint at runtime, not the base image for the build.

300
MCQeasy

What is the purpose of the 'kubectl describe pod' command?

A.Display detailed information about a pod, including recent events
B.Execute a command inside a pod
C.Display resource usage of a pod
D.Show the logs of a pod
AnswerA

kubectl describe pod outputs a detailed, human-readable summary of a pod's current state, including its metadata, spec, status, conditions, container states, restart counts, and, notably, a tail of recent events from the Kubernetes event stream. This event history is essential for debugging because it reveals scheduler decisions, image pull outcomes, and liveness/readiness probe failures that are not visible in the pod's YAML or its logs.

Why this answer

The 'kubectl describe pod' command retrieves detailed metadata about a specific pod, including its current state, labels, annotations, container specifications, volumes, and a chronological list of recent events (e.g., image pull failures, container restarts, scheduling decisions). This aggregated information is essential for debugging pod lifecycle issues because it surfaces both static configuration and dynamic cluster-level events that are not shown in the pod's YAML manifest or logs.

Exam trap

CNCF often tests the distinction between 'describe' (detailed metadata + events) and 'get' (summary or YAML output), so the trap here is confusing 'kubectl describe' with 'kubectl logs' or 'kubectl exec', especially when a pod is failing and candidates instinctively reach for logs instead of first checking events for scheduling or image-related errors.

How to eliminate wrong answers

Option B is wrong because executing a command inside a pod is done with 'kubectl exec', not 'kubectl describe'. Option C is wrong because resource usage (CPU/memory) is displayed by 'kubectl top pod', which relies on the metrics-server, not by 'kubectl describe'. Option D is wrong because showing logs is the purpose of 'kubectl logs', which streams stdout/stderr from containers, whereas 'kubectl describe' provides configuration and event data, not log output.

Page 3

Page 4 of 12

Page 5