Courseiva

CCNA Ckad Deployment Questions

13 of 163 questions · Page 3/3 · Ckad Deployment topic · Answers revealed

151
MCQmedium

You run 'kubectl rollout undo deployment/app'. What happens?

A.It rolls back the Deployment to the previous revision
B.It pauses the rollout
C.It shows the rollout history
D.It deletes the Deployment
AnswerA

`kubectl rollout undo deployment app` reverts the Deployment's pod template to the previous revision, which the Deployment controller uses to create a new ReplicaSet with that older specification. The current ReplicaSet is scaled down to zero while the previous one is scaled up, effectively rolling back the application state without deleting the Deployment object or its history.

Why this answer

The 'kubectl rollout undo' command rolls back a Deployment to the previous revision. By default, it reverts to the immediate prior revision (revision 1 less than current).

152
MCQhard

You are implementing a canary deployment for a microservice named 'api'. The stable version is deployed as 'api-stable' with label 'version: stable'. You create a canary Deployment 'api-canary' with label 'version: canary'. Both Deployments have the same label 'app: api'. You want a Service 'api-svc' to route 90% of traffic to stable and 10% to canary. Which Service configuration achieves this?

A.Add annotation 'traffic-weight: 90' to stable and 'traffic-weight: 10' to canary
B.selector: {app: api} and adjust the number of replicas in each Deployment to achieve the desired ratio (e.g., 9 stable, 1 canary)
C.selector: {app: api, version: stable}
D.Create two separate Services, each targeting one version, and rely on DNS weighting
AnswerB

Using a single Service with the broad selector `app: api` is the correct native Kubernetes approach because it makes the Service's Endpoints object include pods from both the stable and canary Deployments simultaneously. The kube-proxy component (or the in-cluster DNS/round-robin mechanism) then picks endpoints for each new connection uniformly, so the fraction of traffic each version receives is directly proportional to the number of ready pods it contributes—for 9 stable and 1 canary pod, roughly 90% of connections go to stable and 10% to canary. This ratio can be tuned by scaling the `replicas` field in each Deployment, but you cannot get fine-grained percentages because each pod is an equal unit and there is no weighting factor beyond pod count.

Why this answer

Kubernetes Services distribute traffic based on the number of ready Pods matching the selector. By setting 9 replicas for 'api-stable' and 1 replica for 'api-canary', both with the same selector 'app: api', the Service will route approximately 90% of requests to stable and 10% to canary, achieving the desired canary deployment ratio without native traffic splitting.

Exam trap

The trap here is that candidates may think annotations or custom selectors can control traffic weight, but Kubernetes Services only distribute traffic proportionally to the number of ready Pods matching the selector.

How to eliminate wrong answers

Option A is wrong because Kubernetes Services do not support a 'traffic-weight' annotation; traffic distribution is based on the number of ready Pods, not annotations. Option C is wrong because using selector '{app: api, version: stable}' would route 100% of traffic to the stable Deployment, ignoring the canary entirely. Option D is wrong because creating two separate Services with DNS weighting is not a native Kubernetes feature and would require external tools or manual DNS management, which is not a standard Service configuration.

153
MCQeasy

The exhibit shows a Deployment manifest. When applied, the pods are created but show 'CrashLoopBackOff'. What is the most likely cause?

A.The selector does not match the pod labels
B.The liveness probe targets port 8080, but the container only listens on port 80
C.The initialDelaySeconds is too short, starting probes before the app is ready
D.The container image nginx:1.21 does not exist
AnswerB

The livenessProbe sends an HTTP GET to port 8080 on the container's IP. Nginx by default listens on port 80 inside the container, so the kubelet's request to 8080 will get a connection refused error. Since the probe never succeeds, the kubelet marks the container unhealthy and after three consecutive failures kills the container. The container then restarts, but the same probe failure repeats, resulting in CrashLoopBackOff.

Why this answer

The liveness probe is configured to check port 8080, but the container (nginx) only listens on port 80 by default. Since the probe never receives a successful HTTP response, Kubernetes restarts the container repeatedly, causing the CrashLoopBackOff state. The probe must target the same port the application is serving on.

Exam trap

CNCF often tests the distinction between probe misconfiguration (wrong port/path) and other failure modes like image errors or selector mismatches, tempting candidates to overthink with options like initialDelaySeconds.

How to eliminate wrong answers

Option A is wrong because if the selector did not match pod labels, the Deployment would not manage the pods at all; pods would be created but not controlled, and they would not enter CrashLoopBackOff. Option C is wrong because a short initialDelaySeconds might cause temporary failures, but the pod would eventually succeed once the app is ready; CrashLoopBackOff indicates persistent failure, not just early probes. Option D is wrong because if the image nginx:1.21 did not exist, the pods would fail with ImagePullBackOff, not CrashLoopBackOff.

154
MCQmedium

You have a Kustomize overlay that sets 'replicas: 5' in a patch, but the base Deployment has 'replicas: 3'. What is the final number of replicas after applying 'kubectl apply -k overlay/'?

A.3
B.8
C.It depends on the strategy
D.5
AnswerD

The overlay explicitly sets replicas: 5 in its patch, so Kustomize uses exactly that value in the final output. Since overlays take precedence over base values, the base's original replica count is overwritten. This is the core of how Kustomize enables environment-specific customizations: the overlay's patch always wins for fields it specifies, making 5 the correct and deterministic result.

Why this answer

In Kustomize, overlays are applied on top of the base, and patches override the base values. Since the overlay explicitly sets 'replicas: 5' via a patch, it replaces the base value of 3. The final Deployment will have 5 replicas, making D correct.

Exam trap

The trap here is that candidates mistakenly think Kustomize merges or adds values from base and overlay, similar to Helm's merge behavior, when in fact Kustomize patches override scalar fields completely.

How to eliminate wrong answers

Option A is wrong because the base value of 3 is overridden by the overlay patch, not preserved. Option B is wrong because Kustomize patches replace values by default, not merge or add them; replicas are not summed. Option C is wrong because there is no 'strategy' that changes the override behavior; Kustomize's patch mechanism is deterministic and always applies the patch value.

155
MCQhard

You are asked to implement a blue-green deployment using Kubernetes Deployments and Services. You have a blue Deployment with label 'version: blue' and a green Deployment with label 'version: green'. Both have selector 'app: myapp'. You need a Service that initially points to blue. How should you configure the Service to switch to green without downtime?

A.Change the blue Deployment's pod label to 'version: green' and delete green Deployment
B.Update the Service's label selector to 'app: myapp, version: green'
C.Delete the Service and recreate it with the new selector
D.Update the Service's cluster IP to point to green pods
AnswerB

Updating the Service's label selector to 'app: myapp, version: green' is the canonical blue-green switch: the Endpoints controller immediately recalculates the endpoint set to include only green pods, so new traffic flows to green while blue receives no new connections. Because this is a single atomic change (e.g., kubectl patch), there is zero downtime, and the blue Deployment remains intact for instant rollback if green fails.

Why this answer

Updating the Service's label selector to 'app: myapp, version: green' causes the Service to immediately route traffic to green pods without any downtime. The Service uses the selector to dynamically discover pods with matching labels, so changing the selector seamlessly shifts traffic to the green Deployment while the blue Deployment remains untouched.

Exam trap

The trap here is that candidates think they must delete and recreate the Service to change its selector, not realizing that Kubernetes allows live updates to the selector field without downtime.

How to eliminate wrong answers

Option A is wrong because changing the blue Deployment's pod label to 'version: green' would cause both blue and green pods to have the same label, making them indistinguishable and breaking the blue-green isolation; deleting the green Deployment is unnecessary and would cause downtime. Option C is wrong because deleting and recreating the Service introduces a window where no Service exists, leading to downtime; Kubernetes allows live updates to the selector without deletion. Option D is wrong because the Service's cluster IP is a virtual IP assigned by Kubernetes and cannot be manually changed to point to specific pods; traffic routing is controlled by the selector, not the cluster IP.

156
MCQhard

A Deployment has replicas: 5. During a rolling update, the developer sets maxSurge: 2 and maxUnavailable: 1. What is the maximum number of pods that can be running during the update?

A.7
B.5
C.8
D.6
AnswerA

With maxSurge=2, the Deployment controller may temporarily create up to 2 extra pods beyond the desired replica count of 5. This means the total number of pods running simultaneously during a rolling update can reach 7. The controller enforces this ceiling to maintain availability while rolling out changes, and 7 is therefore the absolute maximum possible.

Why this answer

During a rolling update, the total number of pods running is the sum of the desired replicas (5) plus the maxSurge (2), which equals 7. The maxUnavailable setting (1) controls how many pods can be down, not the upper limit of running pods. Kubernetes ensures that the number of pods above the desired count does not exceed maxSurge, so the maximum running pods is 5 + 2 = 7.

Exam trap

The trap here is that candidates often confuse maxSurge and maxUnavailable, mistakenly adding both to the desired replicas or thinking maxUnavailable increases the maximum running pods, when in fact maxSurge alone determines the upper limit of running pods during the update.

How to eliminate wrong answers

Option B is wrong because it assumes no surge is allowed, ignoring the maxSurge setting of 2, which permits additional pods beyond the desired replicas. Option C is wrong because it incorrectly adds both maxSurge and maxUnavailable to the desired replicas (5+2+1=8), but maxUnavailable does not increase the running pod count; it limits how many can be unavailable. Option D is wrong because it suggests a total of 6, which might come from adding only maxUnavailable (5+1=6) or misinterpreting maxSurge as 1, but the correct calculation is replicas + maxSurge = 5+2=7.

157
MCQeasy

A developer wants to ensure that a critical application always runs on every node in the cluster. Which resource should they use?

A.StatefulSet
B.ReplicaSet
C.Deployment
D.DaemonSet
AnswerD

DaemonSet is the correct controller because it automatically ensures a copy of the pod runs on every node in the cluster, including nodes added after the DaemonSet is created. It is designed for cluster-level daemons such as logging agents, monitoring exporters, and network proxies that need node-local presence. DaemonSet respects scheduling constraints like nodeSelectors and tolerations, but by default it provides the per-node coverage the requirement demands.

Why this answer

A DaemonSet ensures that a pod runs on every node in the cluster, or on a subset of nodes based on a node selector. This is the correct resource for deploying a critical application that must be present on all nodes, such as a logging agent or a monitoring daemon.

Exam trap

The trap here is that candidates often confuse DaemonSet with Deployment or ReplicaSet, thinking that setting a high replica count in a Deployment will achieve the same effect, but only DaemonSet guarantees a pod on every node regardless of scaling or scheduling constraints.

How to eliminate wrong answers

Option A is wrong because a StatefulSet is designed for stateful applications that require stable network identities and persistent storage, not for running a pod on every node. Option B is wrong because a ReplicaSet ensures a specified number of pod replicas are running, but it does not guarantee placement on every node; it uses a scheduler to distribute replicas across available nodes. Option C is wrong because a Deployment manages ReplicaSets to provide declarative updates, but like a ReplicaSet, it does not enforce that a pod runs on every node; it only maintains a desired replica count.

158
Multi-Selecthard

Which THREE components are essential for setting up Horizontal Pod Autoscaling (HPA) based on CPU utilization? (Select three)

Select 3 answers
A.A readiness probe on the pod
B.A Service of type LoadBalancer
C.An HPA resource targeting the Deployment
D.metrics-server installed in the cluster
E.CPU resource requests set on the container
AnswersC, D, E

The HPA controller reconciles a HorizontalPodAutoscaler object against a scalable target, so the HPA resource must reference the Deployment as its scaleTargetRef. Without it, no autoscaling logic runs, regardless of metrics availability or container resource requests.

Why this answer

Option C is correct because the HPA controller scales a target workload, and in this scenario the HPA resource must be created with a scaleTargetRef pointing to the Deployment so it can adjust the replica count. Option D is correct because CPU utilization-based HPA relies on the metrics.k8s.io API provided by metrics-server; without metrics-server installed and registered, the HPA cannot retrieve pod CPU usage and will report unknown metrics. Option E is correct because HPA calculates CPU utilization as a percentage of the container's CPU request, so each container in the target pods must have resources.requests.cpu set for the utilization target to be computed.

Option A is not required because readiness probes affect traffic routing and pod availability, not the HPA's ability to read CPU metrics. Option B is not required because a LoadBalancer Service only exposes the workload externally and has no role in HPA metric collection or scaling decisions.

159
MCQhard

You have a Deployment named 'frontend' with 3 replicas. You run 'kubectl rollout history deployment/frontend' and see revision 1 and revision 2. You want to rollback to revision 1. What command should you use?

A.kubectl rollout undo deployment/frontend --to-revision=1
B.kubectl set image deployment/frontend app=nginx:1.19
C.kubectl rollout undo deployment/frontend revision=1
D.kubectl rollout history deployment/frontend --revision=1
AnswerA

The command `kubectl rollout undo deployment/frontend --to-revision=1` is the correct rollback mechanism: it instructs the Deployment controller to revert the current pod template to the exact spec stored in revision 1 of its rollout history. This is the idiomatic way to undo a bad change, because it creates a new rollout (incrementing the revision number) while applying the old template, thereby preserving auditability. Using `--to-revision` explicitly targets a specific historical revision, ensuring the rollback is deterministic rather than merely undoing the most recent change.

Why this answer

The 'kubectl rollout undo' command with the --to-revision flag rolls back to a specific revision. Option A is correct.

160
MCQmedium

You have a Deployment with strategy type: Recreate. You update the container image. What behavior will occur during the update?

A.The update is performed in-place without pod termination.
B.New pods are created before old ones are terminated.
C.The deployment is paused automatically.
D.Old pods are terminated, then new pods are created.
AnswerD

The Recreate strategy is defined by this exact sequence: the Deployment controller first scales down all old ReplicaSets to zero, terminating every existing pod, and only then scales up the new ReplicaSet to the desired number of replicas. This ensures that no old and new versions ever run at the same time, but it also means there is a brief period of downtime. This behavior is explicitly set via `strategy.type: Recreate` in the Deployment manifest.

Why this answer

With the Recreate strategy, the Deployment controller first scales down all existing pods to zero, ensuring they are fully terminated, and then creates new pods with the updated container image. This behavior guarantees that only one version of the application runs at any time, avoiding concurrent old and new pod execution.

Exam trap

The trap here is that candidates often confuse the Recreate strategy with the RollingUpdate strategy, mistakenly thinking new pods are created before old ones are terminated, but the Recreate strategy strictly terminates all old pods first.

How to eliminate wrong answers

Option A is wrong because the Recreate strategy does not perform in-place updates; it terminates all old pods before creating new ones. Option B is wrong because the Recreate strategy explicitly terminates old pods before creating new ones, unlike the RollingUpdate strategy which creates new pods before terminating old ones. Option C is wrong because the Recreate strategy does not pause the Deployment; it proceeds with the termination and creation cycle automatically.

161
Multi-Selectmedium

Which THREE are valid ways to expose a canary deployment for testing? (Select three)

Select 3 answers
A.Create a separate Service for the canary with a different selector and provide its endpoint to testers.
B.Use an Ingress with traffic splitting via annotations (e.g., nginx.ingress.kubernetes.io/canary).
C.Use a DaemonSet instead of Deployment for canary.
D.Use a NetworkPolicy to restrict canary pods from receiving traffic.
E.Use a single Service that selects both stable and canary pods based on a common label.
AnswersA, B, E

You can expose canary pods by creating a dedicated Service whose selector matches only the canary version label—e.g., version=canary. This Service gets its own stable ClusterIP (or LoadBalancer) and routes exclusively to canary pods, providing a direct endpoint for testers, QA teams, or automated verification pipelines. This approach is valid because it gives controlled access to the canary without mixing it into the production traffic path, but it does not automatically shift user traffic—it is for manual or targeted testing.

Why this answer

Option A is correct because creating a dedicated Service whose selector matches only the canary pods' labels gives testers a stable, isolated endpoint (ClusterIP/NodePort/LoadBalancer) that routes exclusively to the canary, without touching production traffic. Option B is correct because an Ingress controller such as NGINX supports canary annotations (e.g., nginx.ingress.kubernetes.io/canary: "true", canary-weight, canary-by-header, canary-by-cookie) to split or conditionally route a percentage or specific requests to the canary backend. Option E is correct because a single Service selecting both stable and canary pods via a shared common label will load-balance across all matching endpoints, which is a simple way to expose the canary alongside stable for testing (albeit without fine-grained control).

Option C is not valid because a DaemonSet schedules one pod per node for node-level agents, not for canary traffic exposure. Option D is not valid because a NetworkPolicy only filters pod ingress/egress traffic; it restricts rather than exposes the canary and provides no routing mechanism to testers.

Exam trap

CKAD often tests the misconception that DaemonSets or NetworkPolicies can be used for canary exposure, when in reality canary testing depends on Service selectors, Ingress annotations, or shared-label Services.

162
Multi-Selectmedium

Which TWO statements about labels and selectors are correct? (Select TWO.)

Select 2 answers
A.Services use selectors to determine which pods receive traffic.
B.Labels are key-value pairs that can be attached to Kubernetes objects.
C.Selectors are used to identify a single object based on its labels.
D.Selectors must be defined in the resource definition itself.
E.Labels cannot be added after an object is created.
AnswersA, B

Correct. A Service's spec.selector is an equality-based label selector. When you create a Service, its selector matches Pods that carry the specified labels, and the Service's Endpoints object is populated with those Pods, enabling traffic distribution. The selector must exactly match the labels on the Pod template at creation time.

Why this answer

A is correct because Services use label selectors in their spec.selector field to determine which Pods receive traffic. B is correct because labels are key-value pairs that can be attached to Kubernetes objects for identification and grouping. C is incorrect because selectors return a set of objects matching the given labels, not a single object.

D is false because selectors are not required to be defined in the resource definition itself; they are used in controllers and Services to select objects. E is false because labels can be added or modified after creation.

Exam trap

The trap here is that candidates may confuse selectors as a required field in the object definition itself (like a label), when in fact selectors are a query mechanism defined in controllers or Services to match labels on other objects, and labels can be modified at any time after creation.

163
MCQhard

You are performing a canary deployment using two Deployments: 'app-stable' (replicas: 9) and 'app-canary' (replicas: 1), both with label 'app: myapp'. A Service selects pods with 'app: myapp' and 'version: stable'. How can you route traffic to the canary?

A.Update the canary Deployment's image to a different version.
B.Change the Service's selector to 'version: canary'.
C.Add label 'version: stable' to the canary Deployment's pod template, so both Deployments have the same label, and keep the Service selector as is.
D.Add label 'version: canary' to the canary Deployment's template and update the Service selector to 'version: stable || version: canary'.
AnswerC

Adding the label 'version: stable' to the canary Deployment's pod template ensures that its pods are selected by the existing Service selector (which is already set to 'version: stable'). The Service then load-balances across all matching pods from both Deployments, distributing traffic proportionally to their replica counts. For example, with 9 stable and 1 canary pod, the canary receives about 10% of traffic, enabling controlled rollout while both versions share the same label and the Service selector remains unchanged.

Why this answer

Adding the label 'version: stable' to the canary Deployment's pod template makes its pods match the Service's selector ('app: myapp' and 'version: stable'). This allows the Service to include both stable and canary pods, distributing traffic according to the replica ratio (9:1). The canary image can be different from stable, but the label ensures the Service routes traffic to both sets of pods.

Exam trap

The trap here is that candidates think they must change the Service's selector to include the canary, but the correct approach is to make the canary pods match the existing selector by adding the required labels, keeping the Service unchanged.

How to eliminate wrong answers

Option A is wrong because changing the canary's image does not affect the Service's selector; without matching labels, the canary pods remain unselected and receive no traffic. Option B is wrong because changing the Service's selector to 'version: canary' would exclude the stable pods, breaking the canary deployment pattern and routing all traffic to the single canary pod. Option D is wrong because Kubernetes selectors do not support logical OR operators (like '||'); selectors are based on equality or set-based matching (e.g., 'In'), and the proposed syntax is invalid, so the Service would fail to select any pods.

← PreviousPage 3 of 3 · 163 questions total

Ready to test yourself?

Try a timed practice session using only Ckad Deployment questions.