ASSOCIATE-CLOUD-ENGINEER practice question 19 of 35
You created a Kubernetes deployment by running kubectl run nginx image=nginx replicas=1. After a few days, you decided you no longer want this…
Full set: 332 questionsA Kubernetes Deployment is a controller that manages the lifecycle of Pods via a ReplicaSet. The Deployment's primary responsibility is to ensure that the actual state of the cluster matches the desired state defined in its configuration (e.g., replicas=1). When you manually delete a Pod managed by a Deployment, the ReplicaSet detects the deviation from the desired state and automatically creates a new Pod to replace it. To permanently remove the application and stop the Pods from being recreated, you must delete the controlling object, which is the Deployment itself. The command kubectl delete deployment nginx correctly targets and deletes the nginx Deployment, which then cascades the deletion to its underlying ReplicaSet and Pods.
B. kubectl delete –deployment=nginx is syntactically incorrect. The kubectl delete command expects the resource type and name as arguments, not as a flag.
C. kubectl delete pod nginx-84748895c4-k6bzl –no-restart 2 is syntactically invalid. The kubectl delete pod command has no --no-restart flag, and deleting the pod is the wrong approach anyway.
D. kubectl delete inginx is incorrect due to a typo (inginx instead of nginx) and because it omits the mandatory resource type (e.g., deployment, pod).
1. Kubernetes Documentation
"Deployments": "A Deployment provides declarative updates for Pods and ReplicaSets... When you delete a Deployment
it cleans up the ReplicaSets and Pods it created. You can delete a Deployment by using kubectl delete." This is demonstrated with the example: kubectl delete deployment nginx-deployment.
Source: Kubernetes Documentation - Deployments
2. Kubernetes Documentation
kubectl Cheat Sheet: The syntax for deleting resources is shown as kubectl delete ([-f FILENAME] | TYPE [(NAME | -l label | --all)]). This confirms that kubectl delete deployment nginx is the correct format
where deployment is the TYPE and nginx is the NAME.
Source: Kubernetes Documentation - kubectl Cheat Sheet
3. Google Cloud Documentation
"Deploying a containerized web application": In the "Cleaning up" section of this tutorial
the command to remove the deployment is kubectl delete deployment hello-web
reinforcing that the deployment object must be the target of the delete operation.
Source: Google Cloud Documentation - Deploying a containerized web application
Keep practicing
Take the free ASSOCIATE-CLOUD-ENGINEER practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other ASSOCIATE-CLOUD-ENGINEER practice questions
- Question 1You need to verify that a Google Cloud Platform service account was created at a particul…
- Question 2You are building a new version of an application hosted in an App Engine environment. You…
- Question 3You need to create a new billing account and then link it with an existing Google Cloud P…
- Question 4You want to configure 10 Compute Engine instances for availability when maintenance occur…
- Question 5You need to create a custom VPC with a single subnet. The subnet’s range must be as large…
- Question 6You significantly changed a complex Deployment Manager template and want to confirm that …
