
Answer-first summary for fast verification
Answer: Edit the number of replicas in the YAML file and rerun the kubectl apply. `kubectl apply -f app-deployment.yaml`
The correct answer is to edit the number of replicas in the YAML file and rerun the `kubectl apply`. This approach ensures that the desired state configuration is updated in the YAML file, preserving the intended state of the Kubernetes cluster. Other methods, such as using `kubectl scale` or enabling autoscaling, do not update the YAML file and could lead to the replicas being scaled back to the original number if the YAML file is reapplied without the replica change. References: [Kubernetes Deployment Scaling](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#scaling-a-deployment), [Kubernetes Autoscaling](https://kubernetes.io/blog/2016/07/autoscaling-in-kubernetes/), [Managing Deployments](https://kubernetes.io/docs/concepts/cluster-administration/manage-deployment/#in-place-updates-of-resources).
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
Your team is working towards using the desired state configuration for your application deployed on the GKE cluster. You have YAML files for the Kubernetes Deployment and Service objects. Your application is designed to have 2 pods, which is defined by the replicas parameter in app-deployment.yaml. Your service uses GKE Load Balancer which is defined in app-service.yaml. You created the Kubernetes resources by running kubectl apply -f app-deployment.yaml and kubectl apply -f app-service.yaml. Your deployment is now serving live traffic but is suffering from performance issues. You want to increase the number of replicas to 5. What should you do in order to update the replicas in existing Kubernetes deployment objects?
A
Disregard the YAML file. Enable autoscaling on the deployment to trigger on CPU usage and set max pods to 5. kubectl autoscale myapp --max=5 --cpu-percent=80
B
Edit the number of replicas in the YAML file and rerun the kubectl apply. kubectl apply -f app-deployment.yaml
C
Disregard the YAML file. Use the kubectl scale command to scale the replicas to 5. kubectl scale --replicas=5 -f app-deployment.yaml
D
Modify the current configuration of the deployment by using kubectl edit to open the YAML file of the current configuration, modify and save the configuration. kubectl edit deployment/app-deployment -o yaml --save-config