CKAD · Question #10
Please complete the following: Update the app deployment in the kdpd00202 namespace with a maxSurge of 5% and a maxUnavailable of 25%. Perform a rolling update of the web1 deployment, changing the…
The exam requires the test-taker to execute specific kubectl commands in a web terminal to manage Kubernetes deployments, including modifying rolling update strategies, updating container images, and rolling back deployments.
Question
- Update the app deployment in the kdpd00202 namespace with a maxSurge of 5% and a maxUnavailable of 25%.
- Perform a rolling update of the web1 deployment, changing the lfccncl/ngmx image version to 1.13
- Roll back the app deployment to the previous version
Exhibit
Explanation
The exam requires the test-taker to execute specific kubectl commands in a web terminal to manage Kubernetes deployments, including modifying rolling update strategies, updating container images, and rolling back deployments.
Approach. The correct approach involves typing the following kubectl commands sequentially into the provided web terminal:
-
Update the app deployment's rolling update strategy:
- Command:
kubectl edit deployment app -n kdpd00202 - Interaction: This command will open the YAML definition of the
appdeployment in thekdpd00202namespace using a text editor (e.g.,vi/vim). The test-taker must navigate to thespec.strategysection. IfstrategyorrollingUpdateblocks are not present, they need to be added. Underspec.strategy.rollingUpdate, add or modify the following lines:
After making these changes, save and exit the editor (e.g.,spec: strategy: type: RollingUpdate rollingUpdate: maxSurge: 5% maxUnavailable: 25%:wqinvim). - Reasoning:
kubectl editallows for direct, interactive modification of live Kubernetes objects. ModifyingmaxSurgeandmaxUnavailableunderspec.strategy.rollingUpdatedirectly controls how a rolling update behaves, ensuring a specific percentage of new pods can be created above the desired count and how many old pods can be unavailable during the update.
- Command:
-
Perform a rolling update of
web1deployment with a new image version:- Command:
kubectl set image deployment/web1 web1=lfccncl/ngmx:1.13 - Interaction: Type this command directly into the terminal and press Enter.
- Reasoning:
kubectl set imageis the most direct and idiomatic command to perform a rolling update by changing the container image.deployment/web1targets the specific deployment.web1=lfccncl/ngmx:1.13specifies that the container namedweb1within that deployment should have its image updated tolfccncl/ngmx:1.13. (It's assumed the container runninglfccncl/ngmximage is namedweb1. If not, the container's actual name should be used, e.g.,<container-name>=lfccncl/ngmx:1.13). This command automatically initiates a rolling update.
- Command:
-
Roll back the
appdeployment to the previous version:- Command:
kubectl rollout undo deployment/app -n kdpd00202 - Interaction: Type this command directly into the terminal and press Enter.
- Reasoning:
kubectl rollout undois the command used to revert a deployment to its immediately preceding revision.deployment/appspecifies the target deployment, and-n kdpd00202ensures the rollback happens in the correct namespace (assuming it refers to the sameappdeployment from task 1).
- Command:
Common mistakes.
- common_mistake. Common mistakes include:
- Incorrect
kubectlcommands or syntax: Forgettingdeployment/prefix or typos in deployment names, image names, or percentages (e.g.,5instead of5%). - Not specifying the namespace (
-n kdpd00202): Tasks 1 and 3 explicitly mention thekdpd00202namespace. If the currentkubectlcontext's namespace is different, omitting-nwill lead to the command failing with 'deployment not found' or incorrectly modifying a deployment in the default namespace. - Modifying the image directly via
kubectl editfor Task 2: While technically possible,kubectl set imageis the more precise and recommended command for image updates, as it explicitly signals an image change that should trigger a new rollout revision. - Using
kubectl apply -fwith a manually generated YAML file for Task 1: This is a more cumbersome and error-prone approach for interactive changes compared tokubectl edit, which directly pulls and pushes the live object's definition. - Not knowing the container name for
kubectl set image: If the container running thelfccncl/ngmximage inside theweb1deployment is not namedweb1, the commandkubectl set image deployment/web1 web1=lfccncl/ngmx:1.13would fail. The test-taker might need to first usekubectl describe deployment web1orkubectl get deployment web1 -o yamlto identify the correct container name. - Attempting to apply the
nginx_resources.ymlfrom the exhibit images: The exhibit images show an example file and commands unrelated to the actual tasks. Applying or modifying thatnginx_resources.ymlwould be irrelevant to solving the problem.
Concept tested. The core concepts tested are Kubernetes Deployment management, including:
- Understanding and configuring rolling update strategies (
maxSurge,maxUnavailable). - Performing rolling updates by updating container images within a Deployment.
- Rolling back a Deployment to a previous revision.
- Proficiency with
kubectlcommands (kubectl edit,kubectl set image,kubectl rollout undo). - Understanding of Kubernetes object definitions (specifically Deployment YAML structure).
- Awareness of Kubernetes namespaces and how to specify them in
kubectlcommands.
Topics
Community Discussion
No community discussion yet for this question.
